-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: create MetricsContext for ksql metrics reporters #5528
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
import com.google.common.base.Splitter; | ||
import com.google.common.collect.ImmutableList; | ||
import com.google.common.collect.ImmutableMap; | ||
import com.google.common.collect.ImmutableSet; | ||
import io.confluent.ksql.config.ConfigItem; | ||
import io.confluent.ksql.config.KsqlConfigResolver; | ||
import io.confluent.ksql.configdef.ConfigValidators; | ||
|
@@ -66,6 +67,12 @@ public class KsqlConfig extends AbstractConfig { | |
public static final String METRIC_REPORTER_CLASSES_DOC = | ||
CommonClientConfigs.METRIC_REPORTER_CLASSES_DOC; | ||
|
||
private static final String METRIC_REPORTERS_PREFIX = "metric.reporters"; | ||
public static final String METRIC_CONTEXT_PREFIX = CommonClientConfigs.METRICS_CONTEXT_PREFIX; | ||
private static final String TELEMETRY_PREFIX = "confluent.telemetry"; | ||
private static final Set<String> REPORTER_CONFIGS_PREFIXES = | ||
ImmutableSet.of(METRIC_REPORTERS_PREFIX, TELEMETRY_PREFIX, METRIC_CONTEXT_PREFIX); | ||
|
||
public static final String KSQL_INTERNAL_TOPIC_REPLICAS_PROPERTY = "ksql.internal.topic.replicas"; | ||
|
||
public static final String KSQL_INTERNAL_TOPIC_MIN_INSYNC_REPLICAS_PROPERTY = | ||
|
@@ -768,15 +775,25 @@ public Map<String, Object> getKsqlStreamConfigProps() { | |
for (final ConfigValue config : ksqlStreamConfigProps.values()) { | ||
props.put(config.key, config.value); | ||
} | ||
|
||
props.putAll(getConfigsForPrefix(REPORTER_CONFIGS_PREFIXES)); | ||
return Collections.unmodifiableMap(props); | ||
} | ||
|
||
public Map<String, Object> getKsqlAdminClientConfigProps() { | ||
return getConfigsFor(AdminClientConfig.configNames()); | ||
final Map<String, Object> map = new HashMap<>(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you want ksql cluster id and application propagate to AdminClient, you should add as part of admin client properties: Because in KafkaAdminClient, we treat properties as metrics reporter properties if it starts with metrics.context: https://github.com/confluentinc/ce-kafka/blob/0f61da6b355f2f34e1b6d2f30072bb47f600bdae/clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java#L495 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I updated it so that |
||
map.putAll(getConfigsFor(AdminClientConfig.configNames())); | ||
|
||
map.putAll(getConfigsForPrefix(REPORTER_CONFIGS_PREFIXES)); | ||
return Collections.unmodifiableMap(map); | ||
} | ||
|
||
public Map<String, Object> getProducerClientConfigProps() { | ||
return getConfigsFor(ProducerConfig.configNames()); | ||
final Map<String, Object> map = new HashMap<>(); | ||
map.putAll(getConfigsFor(ProducerConfig.configNames())); | ||
|
||
map.putAll(getConfigsForPrefix(REPORTER_CONFIGS_PREFIXES)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comments as AdminClient |
||
return Collections.unmodifiableMap(map); | ||
} | ||
|
||
public Map<String, Object> getProcessingLogConfigProps() { | ||
|
@@ -791,6 +808,14 @@ private Map<String, Object> getConfigsFor(final Set<String> configs) { | |
return Collections.unmodifiableMap(props); | ||
} | ||
|
||
private Map<String, Object> getConfigsForPrefix(final Set<String> configs) { | ||
final Map<String, Object> props = new HashMap<>(); | ||
ksqlStreamConfigProps.values().stream() | ||
.filter(configValue -> configs.stream().anyMatch(configValue.key::startsWith)) | ||
.forEach(configValue -> props.put(configValue.key, configValue.value)); | ||
return Collections.unmodifiableMap(props); | ||
} | ||
|
||
public Map<String, Object> getKsqlFunctionsConfigProps(final String functionName) { | ||
final Map<String, Object> udfProps = originalsWithPrefix( | ||
KSQL_FUNCTIONS_PROPERTY_PREFIX + functionName.toLowerCase(), false); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need this. According to KIP-606, "kafka.cluster.id" is for kafka broker. For client of TelemetryReporter, you only need resource.cluster.id
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed