Skip to content

Commit e452352

Browse files
authored
Metric Schema and config name changes
In this commit, we are removing RemoteTarget and replacing with RemoteResourceIdentifier and RemoteResourceType. Further, we are formatting RemoteService, and the content of the RemoteResource attributes such that they align with AWS Cloud Control resource names. In addition to these changes, we are modifying the code and config names used for enabling and configuring Application Signals to use the full feature name, "application.signals"/"Application Signals". By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
2 parents a7d7adf + b61037f commit e452352

File tree

12 files changed

+504
-501
lines changed

12 files changed

+504
-501
lines changed

appsignals-tests/contract-tests/src/test/java/software/amazon/opentelemetry/appsignals/test/awssdk/base/AwsSdkBaseTest.java

Lines changed: 217 additions & 108 deletions
Large diffs are not rendered by default.

appsignals-tests/contract-tests/src/test/java/software/amazon/opentelemetry/appsignals/test/awssdk/v1/AwsSdkV1Test.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -57,26 +57,6 @@ protected String getKinesisSpanNamePrefix() {
5757
return "Kinesis";
5858
}
5959

60-
@Override
61-
protected String getS3ServiceName() {
62-
return "AWS.SDK.Amazon S3";
63-
}
64-
65-
@Override
66-
protected String getDynamoDbServiceName() {
67-
return "AWS.SDK.AmazonDynamoDBv2";
68-
}
69-
70-
@Override
71-
protected String getSqsServiceName() {
72-
return "AWS.SDK.AmazonSQS";
73-
}
74-
75-
@Override
76-
protected String getKinesisServiceName() {
77-
return "AWS.SDK.AmazonKinesis";
78-
}
79-
8060
protected String getS3RpcServiceName() {
8161
return "Amazon S3";
8262
}

appsignals-tests/contract-tests/src/test/java/software/amazon/opentelemetry/appsignals/test/awssdk/v2/AwsSdkV2Test.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,6 @@ protected String getKinesisSpanNamePrefix() {
5656
return "Kinesis";
5757
}
5858

59-
@Override
60-
protected String getS3ServiceName() {
61-
return "AWS.SDK.S3";
62-
}
63-
64-
@Override
65-
protected String getDynamoDbServiceName() {
66-
return "AWS.SDK.DynamoDb";
67-
}
68-
69-
@Override
70-
protected String getSqsServiceName() {
71-
return "AWS.SDK.Sqs";
72-
}
73-
74-
protected String getKinesisServiceName() {
75-
return "AWS.SDK.Kinesis";
76-
}
77-
7859
@Override
7960
protected String getS3RpcServiceName() {
8061
return "S3";

appsignals-tests/contract-tests/src/test/java/software/amazon/opentelemetry/appsignals/test/base/ContractTestBase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@ public abstract class ContractTestBase {
7878
.waitingFor(getApplicationWaitCondition())
7979
.withEnv("JAVA_TOOL_OPTIONS", "-javaagent:/opentelemetry-javaagent-all.jar")
8080
.withEnv("OTEL_METRIC_EXPORT_INTERVAL", "100") // 100 ms
81-
.withEnv("OTEL_AWS_APP_SIGNALS_ENABLED", "true")
81+
.withEnv("OTEL_AWS_APPLICATION_SIGNALS_ENABLED", "true")
8282
.withEnv("OTEL_METRICS_EXPORTER", "none")
8383
.withEnv("OTEL_BSP_SCHEDULE_DELAY", "0") // Don't wait to export spans to the collector
8484
.withEnv(
85-
"OTEL_AWS_APP_SIGNALS_EXPORTER_ENDPOINT",
85+
"OTEL_AWS_APPLICATION_SIGNALS_EXPORTER_ENDPOINT",
8686
"http://" + COLLECTOR_HOSTNAME + ":" + COLLECTOR_PORT)
8787
.withEnv(
8888
"OTEL_EXPORTER_OTLP_TRACES_ENDPOINT",

appsignals-tests/contract-tests/src/test/java/software/amazon/opentelemetry/appsignals/test/utils/AppSignalsConstants.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public class AppSignalsConstants {
2929
public static final String AWS_LOCAL_OPERATION = "aws.local.operation";
3030
public static final String AWS_REMOTE_SERVICE = "aws.remote.service";
3131
public static final String AWS_REMOTE_OPERATION = "aws.remote.operation";
32-
public static final String AWS_REMOTE_TARGET = "aws.remote.target";
32+
public static final String AWS_REMOTE_RESOURCE_TYPE = "aws.remote.resource.type";
33+
public static final String AWS_REMOTE_RESOURCE_IDENTIFIER = "aws.remote.resource.identifier";
3334
public static final String AWS_SPAN_KIND = "aws.span.kind";
3435
}
Lines changed: 55 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -52,54 +52,69 @@
5252
* </ul>
5353
*
5454
* <p>You can control when these customizations are applied using the property
55-
* otel.aws.app.signals.enabled or the environment variable OTEL_AWS_APP_SIGNALS_ENABLED. This flag
56-
* is disabled by default.
55+
* otel.aws.application.signals.enabled or the environment variable
56+
* OTEL_AWS_APPLICATION_SIGNALS_ENABLED. This flag is disabled by default.
5757
*/
58-
public class AwsAppSignalsCustomizerProvider implements AutoConfigurationCustomizerProvider {
58+
public class AwsApplicationSignalsCustomizerProvider
59+
implements AutoConfigurationCustomizerProvider {
5960
private static final Duration DEFAULT_METRIC_EXPORT_INTERVAL = Duration.ofMinutes(1);
6061
private static final Logger logger =
61-
Logger.getLogger(AwsAppSignalsCustomizerProvider.class.getName());
62+
Logger.getLogger(AwsApplicationSignalsCustomizerProvider.class.getName());
63+
64+
private static final String SMP_ENABLED_CONFIG = "otel.smp.enabled";
65+
private static final String APP_SIGNALS_ENABLED_CONFIG = "otel.aws.app.signals.enabled";
66+
private static final String APPLICATION_SIGNALS_ENABLED_CONFIG =
67+
"otel.aws.application.signals.enabled";
68+
private static final String SMP_EXPORTER_ENDPOINT_CONFIG = "otel.aws.smp.exporter.endpoint";
69+
private static final String APP_SIGNALS_EXPORTER_ENDPOINT_CONFIG =
70+
"otel.aws.app.signals.exporter.endpoint";
71+
private static final String APPLICATION_SIGNALS_EXPORTER_ENDPOINT_CONFIG =
72+
"otel.aws.application.signals.exporter.endpoint";
6273

6374
public void customize(AutoConfigurationCustomizer autoConfiguration) {
6475
autoConfiguration.addSamplerCustomizer(this::customizeSampler);
6576
autoConfiguration.addTracerProviderCustomizer(this::customizeTracerProviderBuilder);
6677
autoConfiguration.addSpanExporterCustomizer(this::customizeSpanExporter);
6778
}
6879

69-
private boolean isAppSignalsEnabled(ConfigProperties configProps) {
80+
private boolean isApplicationSignalsEnabled(ConfigProperties configProps) {
7081
return configProps.getBoolean(
71-
"otel.aws.app.signals.enabled", configProps.getBoolean("otel.smp.enabled", false));
82+
APPLICATION_SIGNALS_ENABLED_CONFIG,
83+
configProps.getBoolean(
84+
APP_SIGNALS_ENABLED_CONFIG, configProps.getBoolean(SMP_ENABLED_CONFIG, false)));
7285
}
7386

7487
private Sampler customizeSampler(Sampler sampler, ConfigProperties configProps) {
75-
if (isAppSignalsEnabled(configProps)) {
88+
if (isApplicationSignalsEnabled(configProps)) {
7689
return AlwaysRecordSampler.create(sampler);
7790
}
7891
return sampler;
7992
}
8093

8194
private SdkTracerProviderBuilder customizeTracerProviderBuilder(
8295
SdkTracerProviderBuilder tracerProviderBuilder, ConfigProperties configProps) {
83-
if (isAppSignalsEnabled(configProps)) {
84-
logger.info("AWS AppSignals enabled");
96+
if (isApplicationSignalsEnabled(configProps)) {
97+
logger.info("AWS Application Signals enabled");
8598
Duration exportInterval =
8699
configProps.getDuration("otel.metric.export.interval", DEFAULT_METRIC_EXPORT_INTERVAL);
87100
logger.log(
88-
Level.FINE, String.format("AppSignals Metrics export interval: %s", exportInterval));
101+
Level.FINE,
102+
String.format("AWS Application Signals Metrics export interval: %s", exportInterval));
89103
// Cap export interval to 60 seconds. This is currently required for metrics-trace correlation
90104
// to work correctly.
91105
if (exportInterval.compareTo(DEFAULT_METRIC_EXPORT_INTERVAL) > 0) {
92106
exportInterval = DEFAULT_METRIC_EXPORT_INTERVAL;
93107
logger.log(
94108
Level.INFO,
95-
String.format("AWS AppSignals metrics export interval capped to %s", exportInterval));
109+
String.format(
110+
"AWS Application Signals metrics export interval capped to %s", exportInterval));
96111
}
97112
// Construct and set local and remote attributes span processor
98113
tracerProviderBuilder.addSpanProcessor(
99114
AttributePropagatingSpanProcessorBuilder.create().build());
100115
// Construct meterProvider
101116
MetricExporter metricsExporter =
102-
AppSignalsExporterProvider.INSTANCE.createExporter(configProps);
117+
ApplicationSignalsExporterProvider.INSTANCE.createExporter(configProps);
103118

104119
MetricReader metricReader =
105120
PeriodicMetricReader.builder(metricsExporter).setInterval(exportInterval).build();
@@ -109,7 +124,7 @@ private SdkTracerProviderBuilder customizeTracerProviderBuilder(
109124
.setResource(ResourceHolder.getResource())
110125
.registerMetricReader(metricReader)
111126
.build();
112-
// Construct and set AppSignals metrics processor
127+
// Construct and set application signals metrics processor
113128
SpanProcessor spanMetricsProcessor =
114129
AwsSpanMetricsProcessorBuilder.create(meterProvider, ResourceHolder.getResource())
115130
.build();
@@ -120,7 +135,7 @@ private SdkTracerProviderBuilder customizeTracerProviderBuilder(
120135

121136
private SpanExporter customizeSpanExporter(
122137
SpanExporter spanExporter, ConfigProperties configProps) {
123-
if (isAppSignalsEnabled(configProps)) {
138+
if (isApplicationSignalsEnabled(configProps)) {
124139
return AwsMetricAttributesSpanExporterBuilder.create(
125140
spanExporter, ResourceHolder.getResource())
126141
.build();
@@ -129,40 +144,52 @@ private SpanExporter customizeSpanExporter(
129144
return spanExporter;
130145
}
131146

132-
private enum AppSignalsExporterProvider {
147+
private enum ApplicationSignalsExporterProvider {
133148
INSTANCE;
134149

135150
public MetricExporter createExporter(ConfigProperties configProps) {
136151
String protocol =
137152
OtlpConfigUtil.getOtlpProtocol(OtlpConfigUtil.DATA_TYPE_METRICS, configProps);
138-
logger.log(Level.FINE, String.format("AppSignals export protocol: %s", protocol));
153+
logger.log(
154+
Level.FINE, String.format("AWS Application Signals export protocol: %s", protocol));
139155

140-
String appSignalsEndpoint;
156+
String applicationSignalsEndpoint;
141157
if (protocol.equals(OtlpConfigUtil.PROTOCOL_HTTP_PROTOBUF)) {
142-
appSignalsEndpoint =
158+
applicationSignalsEndpoint =
143159
configProps.getString(
144-
"otel.aws.app.signals.exporter.endpoint",
160+
APPLICATION_SIGNALS_EXPORTER_ENDPOINT_CONFIG,
145161
configProps.getString(
146-
"otel.aws.smp.exporter.endpoint", "http://localhost:4316/v1/metrics"));
147-
logger.log(Level.FINE, String.format("AppSignals export endpoint: %s", appSignalsEndpoint));
162+
APP_SIGNALS_EXPORTER_ENDPOINT_CONFIG,
163+
configProps.getString(
164+
SMP_EXPORTER_ENDPOINT_CONFIG, "http://localhost:4316/v1/metrics")));
165+
logger.log(
166+
Level.FINE,
167+
String.format(
168+
"AWS Application Signals export endpoint: %s", applicationSignalsEndpoint));
148169
return OtlpHttpMetricExporter.builder()
149-
.setEndpoint(appSignalsEndpoint)
170+
.setEndpoint(applicationSignalsEndpoint)
150171
.setDefaultAggregationSelector(this::getAggregation)
151172
.setAggregationTemporalitySelector(AggregationTemporalitySelector.deltaPreferred())
152173
.build();
153174
} else if (protocol.equals(OtlpConfigUtil.PROTOCOL_GRPC)) {
154-
appSignalsEndpoint =
175+
applicationSignalsEndpoint =
155176
configProps.getString(
156-
"otel.aws.app.signals.exporter.endpoint",
157-
configProps.getString("otel.aws.smp.exporter.endpoint", "http://localhost:4315"));
158-
logger.log(Level.FINE, String.format("AppSignals export endpoint: %s", appSignalsEndpoint));
177+
APPLICATION_SIGNALS_EXPORTER_ENDPOINT_CONFIG,
178+
configProps.getString(
179+
APP_SIGNALS_EXPORTER_ENDPOINT_CONFIG,
180+
configProps.getString(SMP_EXPORTER_ENDPOINT_CONFIG, "http://localhost:4315")));
181+
logger.log(
182+
Level.FINE,
183+
String.format(
184+
"AWS Application Signals export endpoint: %s", applicationSignalsEndpoint));
159185
return OtlpGrpcMetricExporter.builder()
160-
.setEndpoint(appSignalsEndpoint)
186+
.setEndpoint(applicationSignalsEndpoint)
161187
.setDefaultAggregationSelector(this::getAggregation)
162188
.setAggregationTemporalitySelector(AggregationTemporalitySelector.deltaPreferred())
163189
.build();
164190
}
165-
throw new ConfigurationException("Unsupported AppSignals export protocol: " + protocol);
191+
throw new ConfigurationException(
192+
"Unsupported AWS Application Signals export protocol: " + protocol);
166193
}
167194

168195
private Aggregation getAggregation(InstrumentType instrumentType) {

awsagentprovider/src/main/java/software/amazon/opentelemetry/javaagent/providers/AwsAttributeKeys.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,25 @@ private AwsAttributeKeys() {}
3535
static final AttributeKey<String> AWS_REMOTE_OPERATION =
3636
AttributeKey.stringKey("aws.remote.operation");
3737

38-
static final AttributeKey<String> AWS_REMOTE_TARGET = AttributeKey.stringKey("aws.remote.target");
38+
static final AttributeKey<String> AWS_REMOTE_RESOURCE_IDENTIFIER =
39+
AttributeKey.stringKey("aws.remote.resource.identifier");
40+
41+
static final AttributeKey<String> AWS_REMOTE_RESOURCE_TYPE =
42+
AttributeKey.stringKey("aws.remote.resource.type");
3943

4044
static final AttributeKey<String> AWS_SDK_DESCENDANT =
4145
AttributeKey.stringKey("aws.sdk.descendant");
4246

47+
static final AttributeKey<String> AWS_CONSUMER_PARENT_SPAN_KIND =
48+
AttributeKey.stringKey("aws.consumer.parent.span.kind");
49+
4350
// use the same AWS Resource attribute name defined by OTel java auto-instr for aws_sdk_v_1_1
4451
// TODO: all AWS specific attributes should be defined in semconv package and reused cross all
4552
// otel packages. Related sim -
4653
// https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/8710
47-
4854
static final AttributeKey<String> AWS_BUCKET_NAME = AttributeKey.stringKey("aws.bucket.name");
4955
static final AttributeKey<String> AWS_QUEUE_URL = AttributeKey.stringKey("aws.queue.url");
5056
static final AttributeKey<String> AWS_QUEUE_NAME = AttributeKey.stringKey("aws.queue.name");
5157
static final AttributeKey<String> AWS_STREAM_NAME = AttributeKey.stringKey("aws.stream.name");
5258
static final AttributeKey<String> AWS_TABLE_NAME = AttributeKey.stringKey("aws.table.name");
53-
static final AttributeKey<String> AWS_CONSUMER_PARENT_SPAN_KIND =
54-
AttributeKey.stringKey("aws.consumer.parent.span.kind");
5559
}

0 commit comments

Comments
 (0)