Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ public final class ConfigPropertiesBackedDeclarativeConfigProperties
SPECIAL_MAPPINGS.put(
"general.http.server.response_captured_headers",
"otel.instrumentation.http.server.capture-response-headers");
SPECIAL_MAPPINGS.put(
"java.common.messaging.receive_telemetry/development.enabled",
"otel.instrumentation.messaging.experimental.receive-telemetry.enabled");
SPECIAL_MAPPINGS.put(
"java.common.messaging.capture_headers/development",
"otel.instrumentation.messaging.experimental.capture-headers");
}

private final ConfigProperties configProperties;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,25 @@ public final class DeclarativeConfigUtil {

private DeclarativeConfigUtil() {}

public static ExtendedDeclarativeConfigProperties get(OpenTelemetry openTelemetry) {
DeclarativeConfigProperties javaConfig = empty();
public static ExtendedDeclarativeConfigProperties getInstrumentationConfig(
OpenTelemetry openTelemetry, String instrumentationName) {
return getConfig(openTelemetry).get("java").get(instrumentationName);
}

public static ExtendedDeclarativeConfigProperties getGeneralInstrumentationConfig(
OpenTelemetry openTelemetry) {
return getConfig(openTelemetry).get("general");
}
Comment on lines +22 to +30
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currently proposed naming from open-telemetry/opentelemetry-java#7927


private static ExtendedDeclarativeConfigProperties getConfig(OpenTelemetry openTelemetry) {
if (openTelemetry instanceof ExtendedOpenTelemetry) {
ExtendedOpenTelemetry extendedOpenTelemetry = (ExtendedOpenTelemetry) openTelemetry;
DeclarativeConfigProperties instrumentationConfig =
extendedOpenTelemetry.getConfigProvider().getInstrumentationConfig();
if (instrumentationConfig != null) {
javaConfig = instrumentationConfig.getStructured("java", empty());
return new ExtendedDeclarativeConfigProperties(instrumentationConfig);
}
}
return new ExtendedDeclarativeConfigProperties(javaConfig);
return new ExtendedDeclarativeConfigProperties(empty());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ private static final class Configuration {
private final boolean addOperationNameToSpanName;

Configuration(OpenTelemetry openTelemetry) {
ExtendedDeclarativeConfigProperties config = DeclarativeConfigUtil.get(openTelemetry);
ExtendedDeclarativeConfigProperties config =
DeclarativeConfigUtil.getInstrumentationConfig(openTelemetry, "graphql");

this.captureQuery = config.get("graphql").getBoolean("capture_query", true);
this.querySanitizerEnabled =
config.get("graphql").get("query_sanitizer").getBoolean("enabled", true);
this.captureQuery = config.getBoolean("capture_query", true);
this.querySanitizerEnabled = config.get("query_sanitizer").getBoolean("enabled", true);
this.addOperationNameToSpanName =
config.get("graphql").get("add_operation_name_to_span_name").getBoolean("enabled", false);
config.get("add_operation_name_to_span_name").getBoolean("enabled", false);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@ private static final class Configuration {
private final boolean addOperationNameToSpanName;

Configuration(OpenTelemetry openTelemetry) {
ExtendedDeclarativeConfigProperties config = DeclarativeConfigUtil.get(openTelemetry);
ExtendedDeclarativeConfigProperties config =
DeclarativeConfigUtil.getInstrumentationConfig(openTelemetry, "graphql");

this.captureQuery = config.get("graphql").getBoolean("capture_query", true);
this.sanitizeQuery = config.get("graphql").get("query_sanitizer").getBoolean("enabled", true);
this.dataFetcherEnabled =
config.get("graphql").get("data_fetcher").getBoolean("enabled", false);
this.captureQuery = config.getBoolean("capture_query", true);
this.sanitizeQuery = config.get("query_sanitizer").getBoolean("enabled", true);
this.dataFetcherEnabled = config.get("data_fetcher").getBoolean("enabled", false);
this.trivialDataFetcherEnabled =
config.get("graphql").get("trivial_data_fetcher").getBoolean("enabled", false);
config.get("trivial_data_fetcher").getBoolean("enabled", false);
this.addOperationNameToSpanName =
config.get("graphql").get("add_operation_name_to_span_name").getBoolean("enabled", false);
config.get("add_operation_name_to_span_name").getBoolean("enabled", false);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public final class ExperimentalConfig {
private static final ExperimentalConfig instance =
new ExperimentalConfig(GlobalOpenTelemetry.get());

private final ExtendedDeclarativeConfigProperties config;
private final ExtendedDeclarativeConfigProperties commonConfig;
private final List<String> messagingHeaders;

/** Returns the global agent configuration. */
Expand All @@ -31,35 +31,28 @@ public static ExperimentalConfig get() {
}

public ExperimentalConfig(OpenTelemetry openTelemetry) {
this.config = DeclarativeConfigUtil.get(openTelemetry);
this.commonConfig = DeclarativeConfigUtil.getInstrumentationConfig(openTelemetry, "common");
this.messagingHeaders =
config
commonConfig
.get("messaging")
Comment on lines +36 to 37
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the common messaging configuration under .instrumentation.java.common.messaging.

.getScalarList("capture_headers/development", String.class, emptyList());
}

public boolean controllerTelemetryEnabled() {
return config
.get("common")
.get("controller_telemetry/development")
.getBoolean("enabled", false);
return commonConfig.get("controller_telemetry/development").getBoolean("enabled", false);
}

public boolean viewTelemetryEnabled() {
return config.get("common").get("view_telemetry/development").getBoolean("enabled", false);
return commonConfig.get("view_telemetry/development").getBoolean("enabled", false);
}

public boolean messagingReceiveInstrumentationEnabled() {
return config
return commonConfig
.get("messaging")
Comment on lines +50 to 51
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

.get("receive_telemetry/development")
.getBoolean("enabled", false);
}

public boolean indyEnabled() {
return config.get("agent").getBoolean("indy/development", false);
}

Comment on lines -59 to -62
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed this from ExperimentalConfig because it really belongs in some kind of "distribution config" which deserves a different abstraction, related to open-telemetry/opentelemetry-specification#4800 (comment)

public List<String> getMessagingHeaders() {
return messagingHeaders;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import static java.util.Collections.unmodifiableSet;
import static net.bytebuddy.matcher.ElementMatchers.any;

import io.opentelemetry.javaagent.bootstrap.internal.ExperimentalConfig;
import io.opentelemetry.javaagent.bootstrap.internal.AgentInstrumentationConfig;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import io.opentelemetry.sdk.autoconfigure.spi.Ordered;
import java.util.Collections;
Expand Down Expand Up @@ -161,7 +161,8 @@ private static class IndyConfigurationHolder {
private static final boolean indyEnabled;

static {
indyEnabled = ExperimentalConfig.get().indyEnabled();
indyEnabled =
AgentInstrumentationConfig.get().getBoolean("otel.javaagent.experimental.indy", false);
Comment on lines +164 to +165
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will come back to this an create some kind of "distribution config" abstraction

not saying we should, but even if we decide to keep it under .instrumentation.java.agent.* (and not use the .distribution.*), I still don't think this property belongs in ExperimentalConfig with the other .instrumentation.java.common.* properties

if (indyEnabled) {
logger.info("Enabled indy for instrumentation modules");
}
Expand Down
Loading