Skip to content

Commit

Permalink
Enable AWS Resource detector.
Browse files Browse the repository at this point in the history
  • Loading branch information
zzhlogin committed Dec 16, 2024
1 parent 8b4a4d9 commit 3558887
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ protected void assertSemanticConventionsSpanAttributes(
});
}

// some sementic attributes has been removed:
//
// https://github.com/open-telemetry/opentelemetry-java-instrumentation/commit/7cd705b55594f17f821c16181bb2f12d093e6680
protected void assertSemanticConventionsAttributes(
List<KeyValue> attributesList, String method, String route, String target, long status_code) {
assertThat(attributesList)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@ public class JMXMetricsConstants {
TOMCAT_REQUEST_COUNT,
TOMCAT_MAX_TIME,
TOMCAT_PROCESSING_TIME,
TOMCAT_TRAFFIC,
TOMCAT_THREADS);
// TODO: Pending on root cause why tomcat.threads can be negative
// TOMCAT_THREADS,
TOMCAT_TRAFFIC);

// Kafka Metrics
public static final String KAFKA_MESSAGE_COUNT = "kafka.message.count";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ public class SemanticConventionsConstants {
// kafka
public static final String MESSAGING_CLIENT_ID = "messaging.client_id";
public static final String MESSAGING_DESTINATION_NAME = "messaging.destination.name";
// Rename `messaging.kafka.destination.partition` to `messaging.destination.partition.id`
//
// https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/57c7cf2ad5f7272c1eb83b9816e652bf832c91d4/CHANGELOG.md?plain=1#L430C3-L430C89
public static final String MESSAGING_DESTINATION_PARTITION_ID =
"messaging.destination.partition.id";
public static final String MESSAGING_KAFKA_MESSAGE_OFFSET = "messaging.kafka.message.offset";
Expand Down
1 change: 0 additions & 1 deletion awsagentprovider/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ dependencies {

tasks {
val shadowJar by existing(ShadowJar::class) {
// You can configure the existing task here
archiveClassifier.set("")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ public class AwsApplicationSignalsCustomizerProvider
"otel.aws.app.signals.enabled";
private static final String APPLICATION_SIGNALS_ENABLED_CONFIG =
"otel.aws.application.signals.enabled";

private static final String OTEL_RESOURCE_PROVIDERS_AWS_ENABLED =
"otel.resource.providers.aws.enabled";
private static final String APPLICATION_SIGNALS_RUNTIME_ENABLED_CONFIG =
"otel.aws.application.signals.runtime.enabled";
private static final String DEPRECATED_SMP_EXPORTER_ENDPOINT_CONFIG =
Expand Down Expand Up @@ -132,19 +135,23 @@ private boolean isApplicationSignalsRuntimeEnabled(ConfigProperties configProps)
}

private Map<String, String> customizeProperties(ConfigProperties configProps) {
if (isApplicationSignalsRuntimeEnabled(configProps)) {
List<String> list = configProps.getList(OTEL_JMX_TARGET_SYSTEM_CONFIG);
if (list.contains("jvm")) {
logger.log(Level.INFO, "Found jmx in {0}", OTEL_JMX_TARGET_SYSTEM_CONFIG);
return Collections.emptyMap();
} else {
logger.log(Level.INFO, "Configure jmx in {0}", OTEL_JMX_TARGET_SYSTEM_CONFIG);
List<String> jmxTargets = new ArrayList<>(list);
jmxTargets.add("jvm");
Map<String, String> propsOverride = new HashMap<>(1);
propsOverride.put(OTEL_JMX_TARGET_SYSTEM_CONFIG, String.join(",", jmxTargets));
return propsOverride;
if (isApplicationSignalsEnabled(configProps)) {
Map<String, String> propsOverride = new HashMap<>();
// Enable AWS Resource Providers
propsOverride.put(OTEL_RESOURCE_PROVIDERS_AWS_ENABLED, "true");

if (isApplicationSignalsRuntimeEnabled(configProps)) {
List<String> list = configProps.getList(OTEL_JMX_TARGET_SYSTEM_CONFIG);
if (list.contains("jvm")) {
logger.log(Level.INFO, "Found jmx in {0}", OTEL_JMX_TARGET_SYSTEM_CONFIG);
} else {
logger.log(Level.INFO, "Configure jmx in {0}", OTEL_JMX_TARGET_SYSTEM_CONFIG);
List<String> jmxTargets = new ArrayList<>(list);
jmxTargets.add("jvm");
propsOverride.put(OTEL_JMX_TARGET_SYSTEM_CONFIG, String.join(",", jmxTargets));
}
}
return propsOverride;
}
return Collections.emptyMap();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ public ExportTraceServiceRequest deserialize(
.withEnv("OTEL_INSTRUMENTATION_COMMON_EXPERIMENTAL_CONTROLLER_TELEMETRY_ENABLED", "true")
.withEnv("OTEL_EXPORTER_OTLP_ENDPOINT", "http://backend:8080");

// Suppressing controller and/or view spans:
// https://opentelemetry.io/docs/zero-code/java/agent/disable/#suppressing-controller-andor-view-spans
@Container
private static final GenericContainer<?> applicationXraySampler =
new GenericContainer<>("public.ecr.aws/aws-otel-test/aws-otel-java-smoketests-springboot:v2")
Expand Down

0 comments on commit 3558887

Please sign in to comment.