Skip to content

Commit a3d6e5a

Browse files
authored
Emit schema url from HTTP instrumentations (#15144)
1 parent 7e1ee7d commit a3d6e5a

File tree

16 files changed

+99
-15
lines changed
  • instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/builder/internal
  • instrumentation
    • netty/netty-3.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v3_8/client
    • opentelemetry-api
      • opentelemetry-api-1.10/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_10/metrics
      • opentelemetry-api-1.15/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_15/metrics
      • opentelemetry-api-1.31/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_31/metrics
      • opentelemetry-api-1.32/javaagent/src
        • incubatorTest/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_32/incubator/metrics
        • test/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_32/metrics
      • opentelemetry-api-1.37/javaagent/src
        • incubatorTest/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_37/incubator/metrics
        • oldAndNewIncubatorTest/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_37/incubator/metrics
        • test/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_37/metrics
      • opentelemetry-api-1.38/javaagent/src
        • incubatorTest/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_38/incubator/metrics
        • test/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_38/metrics
  • testing-common/src/main/java/io/opentelemetry/instrumentation/testing

16 files changed

+99
-15
lines changed

instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/builder/internal/DefaultHttpClientInstrumenterBuilder.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import io.opentelemetry.instrumentation.api.semconv.http.HttpSpanNameExtractor;
3232
import io.opentelemetry.instrumentation.api.semconv.http.HttpSpanNameExtractorBuilder;
3333
import io.opentelemetry.instrumentation.api.semconv.http.HttpSpanStatusExtractor;
34+
import io.opentelemetry.semconv.SchemaUrls;
3435
import java.util.ArrayList;
3536
import java.util.Collection;
3637
import java.util.List;
@@ -245,7 +246,8 @@ public Instrumenter<REQUEST, RESPONSE> build() {
245246
statusExtractorTransformer.apply(HttpSpanStatusExtractor.create(attributesGetter)))
246247
.addAttributesExtractor(httpAttributesExtractorBuilder.build())
247248
.addAttributesExtractors(additionalExtractors)
248-
.addOperationMetrics(HttpClientMetrics.get());
249+
.addOperationMetrics(HttpClientMetrics.get())
250+
.setSchemaUrl(SchemaUrls.V1_37_0);
249251
if (emitExperimentalHttpClientTelemetry) {
250252
builder
251253
.addAttributesExtractor(HttpExperimentalAttributesExtractor.create(attributesGetter))
@@ -263,7 +265,9 @@ public Instrumenter<REQUEST, RESPONSE> build() {
263265
public <BUILDERREQUEST, BUILDERRESPONSE>
264266
InstrumenterBuilder<BUILDERREQUEST, BUILDERRESPONSE> instrumenterBuilder(
265267
SpanNameExtractor<? super BUILDERREQUEST> spanNameExtractor) {
266-
return Instrumenter.builder(openTelemetry, instrumentationName, spanNameExtractor);
268+
return Instrumenter.<BUILDERREQUEST, BUILDERRESPONSE>builder(
269+
openTelemetry, instrumentationName, spanNameExtractor)
270+
.setSchemaUrl(SchemaUrls.V1_37_0);
267271
}
268272

269273
@CanIgnoreReturnValue

instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/builder/internal/DefaultHttpServerInstrumenterBuilder.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import io.opentelemetry.instrumentation.api.semconv.http.HttpSpanNameExtractor;
2727
import io.opentelemetry.instrumentation.api.semconv.http.HttpSpanNameExtractorBuilder;
2828
import io.opentelemetry.instrumentation.api.semconv.http.HttpSpanStatusExtractor;
29+
import io.opentelemetry.semconv.SchemaUrls;
2930
import java.util.ArrayList;
3031
import java.util.Collection;
3132
import java.util.List;
@@ -207,7 +208,8 @@ public InstrumenterBuilder<REQUEST, RESPONSE> instrumenterBuilder() {
207208
.addAttributesExtractor(httpAttributesExtractorBuilder.build())
208209
.addAttributesExtractors(additionalExtractors)
209210
.addContextCustomizer(httpServerRouteBuilder.build())
210-
.addOperationMetrics(HttpServerMetrics.get());
211+
.addOperationMetrics(HttpServerMetrics.get())
212+
.setSchemaUrl(SchemaUrls.V1_37_0);
211213
if (emitExperimentalHttpServerTelemetry) {
212214
builder
213215
.addAttributesExtractor(HttpExperimentalAttributesExtractor.create(attributesGetter))

instrumentation/netty/netty-3.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v3_8/client/NettyClientSingletons.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import io.opentelemetry.javaagent.bootstrap.internal.AgentCommonConfig;
1616
import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpClientInstrumenters;
1717
import io.opentelemetry.javaagent.instrumentation.netty.v3_8.HttpRequestAndChannel;
18+
import io.opentelemetry.semconv.SchemaUrls;
1819
import org.jboss.netty.channel.Channel;
1920
import org.jboss.netty.handler.codec.http.HttpResponse;
2021

@@ -45,6 +46,7 @@ public final class NettyClientSingletons {
4546
HttpClientPeerServiceAttributesExtractor.create(
4647
NettyConnectHttpAttributesGetter.INSTANCE,
4748
AgentCommonConfig.get().getPeerServiceResolver()))
49+
.setSchemaUrl(SchemaUrls.V1_37_0)
4850
.buildInstrumenter(SpanKindExtractor.alwaysClient());
4951
}
5052

instrumentation/opentelemetry-api/opentelemetry-api-1.10/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_10/metrics/MeterTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ void longCounter() {
7272
.hasInstrumentationScope(
7373
InstrumentationScopeInfo.builder(instrumentationName)
7474
.setVersion("1.2.3")
75+
.setSchemaUrl("http://schema.org")
7576
.build())
7677
.hasLongSumSatisfying(
7778
sum ->
@@ -106,6 +107,7 @@ void observableLongCounter() throws InterruptedException {
106107
.hasInstrumentationScope(
107108
InstrumentationScopeInfo.builder(instrumentationName)
108109
.setVersion("1.2.3")
110+
.setSchemaUrl("http://schema.org")
109111
.build())
110112
.hasLongSumSatisfying(
111113
sum ->
@@ -147,6 +149,7 @@ void doubleCounter() {
147149
.hasInstrumentationScope(
148150
InstrumentationScopeInfo.builder(instrumentationName)
149151
.setVersion("1.2.3")
152+
.setSchemaUrl("http://schema.org")
150153
.build())
151154
.hasDoubleSumSatisfying(
152155
sum ->
@@ -182,6 +185,7 @@ void observableDoubleCounter() throws InterruptedException {
182185
.hasInstrumentationScope(
183186
InstrumentationScopeInfo.builder(instrumentationName)
184187
.setVersion("1.2.3")
188+
.setSchemaUrl("http://schema.org")
185189
.build())
186190
.hasDoubleSumSatisfying(
187191
sum ->
@@ -223,6 +227,7 @@ void longUpDownCounter() {
223227
.hasInstrumentationScope(
224228
InstrumentationScopeInfo.builder(instrumentationName)
225229
.setVersion("1.2.3")
230+
.setSchemaUrl("http://schema.org")
226231
.build())
227232
.hasLongSumSatisfying(
228233
sum ->
@@ -257,6 +262,7 @@ void observableLongUpDownCounter() throws InterruptedException {
257262
.hasInstrumentationScope(
258263
InstrumentationScopeInfo.builder(instrumentationName)
259264
.setVersion("1.2.3")
265+
.setSchemaUrl("http://schema.org")
260266
.build())
261267
.hasLongSumSatisfying(
262268
sum ->
@@ -298,6 +304,7 @@ void doubleUpDownCounter() {
298304
.hasInstrumentationScope(
299305
InstrumentationScopeInfo.builder(instrumentationName)
300306
.setVersion("1.2.3")
307+
.setSchemaUrl("http://schema.org")
301308
.build())
302309
.hasDoubleSumSatisfying(
303310
sum ->
@@ -333,6 +340,7 @@ void observableDoubleUpDownCounter() throws InterruptedException {
333340
.hasInstrumentationScope(
334341
InstrumentationScopeInfo.builder(instrumentationName)
335342
.setVersion("1.2.3")
343+
.setSchemaUrl("http://schema.org")
336344
.build())
337345
.hasDoubleSumSatisfying(
338346
sum ->
@@ -374,6 +382,7 @@ void longHistogram() {
374382
.hasInstrumentationScope(
375383
InstrumentationScopeInfo.builder(instrumentationName)
376384
.setVersion("1.2.3")
385+
.setSchemaUrl("http://schema.org")
377386
.build())
378387
.hasHistogramSatisfying(
379388
histogram ->
@@ -405,6 +414,7 @@ void doubleHistogram() {
405414
.hasInstrumentationScope(
406415
InstrumentationScopeInfo.builder(instrumentationName)
407416
.setVersion("1.2.3")
417+
.setSchemaUrl("http://schema.org")
408418
.build())
409419
.hasHistogramSatisfying(
410420
histogram ->
@@ -439,6 +449,7 @@ void longGauge() throws InterruptedException {
439449
.hasInstrumentationScope(
440450
InstrumentationScopeInfo.builder(instrumentationName)
441451
.setVersion("1.2.3")
452+
.setSchemaUrl("http://schema.org")
442453
.build())
443454
.hasLongGaugeSatisfying(
444455
gauge ->
@@ -481,6 +492,7 @@ void doubleGauge() throws InterruptedException {
481492
.hasInstrumentationScope(
482493
InstrumentationScopeInfo.builder(instrumentationName)
483494
.setVersion("1.2.3")
495+
.setSchemaUrl("http://schema.org")
484496
.build())
485497
.hasDoubleGaugeSatisfying(
486498
gauge ->

instrumentation/opentelemetry-api/opentelemetry-api-1.15/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_15/metrics/MeterTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ void batchLongCounter() throws InterruptedException {
6767
.hasInstrumentationScope(
6868
InstrumentationScopeInfo.builder(instrumentationName)
6969
.setVersion("1.2.3")
70+
.setSchemaUrl("http://schema.org")
7071
.build())
7172
.hasLongSumSatisfying(
7273
sum ->
@@ -112,6 +113,7 @@ void batchDoubleCounter() throws InterruptedException {
112113
.hasInstrumentationScope(
113114
InstrumentationScopeInfo.builder(instrumentationName)
114115
.setVersion("1.2.3")
116+
.setSchemaUrl("http://schema.org")
115117
.build())
116118
.hasDoubleSumSatisfying(
117119
sum ->
@@ -157,6 +159,7 @@ void batchLongUpDownCounter() throws InterruptedException {
157159
.hasInstrumentationScope(
158160
InstrumentationScopeInfo.builder(instrumentationName)
159161
.setVersion("1.2.3")
162+
.setSchemaUrl("http://schema.org")
160163
.build())
161164
.hasLongSumSatisfying(
162165
sum ->
@@ -207,6 +210,7 @@ void batchDoubleUpDownCounter() throws InterruptedException {
207210
.hasInstrumentationScope(
208211
InstrumentationScopeInfo.builder(instrumentationName)
209212
.setVersion("1.2.3")
213+
.setSchemaUrl("http://schema.org")
210214
.build())
211215
.hasDoubleSumSatisfying(
212216
sum ->
@@ -252,6 +256,7 @@ void batchLongGauge() throws InterruptedException {
252256
.hasInstrumentationScope(
253257
InstrumentationScopeInfo.builder(instrumentationName)
254258
.setVersion("1.2.3")
259+
.setSchemaUrl("http://schema.org")
255260
.build())
256261
.hasLongGaugeSatisfying(
257262
gauge ->
@@ -296,6 +301,7 @@ void batchDoubleGauge() throws InterruptedException {
296301
.hasInstrumentationScope(
297302
InstrumentationScopeInfo.builder(instrumentationName)
298303
.setVersion("1.2.3")
304+
.setSchemaUrl("http://schema.org")
299305
.build())
300306
.hasDoubleGaugeSatisfying(
301307
gauge ->

instrumentation/opentelemetry-api/opentelemetry-api-1.31/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_31/metrics/MeterTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ void longCounter() {
9191
.hasInstrumentationScope(
9292
InstrumentationScopeInfo.builder(instrumentationName)
9393
.setVersion("1.2.3")
94+
.setSchemaUrl("http://schema.org")
9495
.build())
9596
.hasLongSumSatisfying(
9697
sum ->
@@ -128,6 +129,7 @@ void doubleCounter() {
128129
.hasInstrumentationScope(
129130
InstrumentationScopeInfo.builder(instrumentationName)
130131
.setVersion("1.2.3")
132+
.setSchemaUrl("http://schema.org")
131133
.build())
132134
.hasDoubleSumSatisfying(
133135
sum ->
@@ -165,6 +167,7 @@ void longUpDownCounter() {
165167
.hasInstrumentationScope(
166168
InstrumentationScopeInfo.builder(instrumentationName)
167169
.setVersion("1.2.3")
170+
.setSchemaUrl("http://schema.org")
168171
.build())
169172
.hasLongSumSatisfying(
170173
sum ->
@@ -203,6 +206,7 @@ void doubleUpDownCounter() {
203206
.hasInstrumentationScope(
204207
InstrumentationScopeInfo.builder(instrumentationName)
205208
.setVersion("1.2.3")
209+
.setSchemaUrl("http://schema.org")
206210
.build())
207211
.hasDoubleSumSatisfying(
208212
sum ->
@@ -241,6 +245,7 @@ void longHistogram() {
241245
.hasInstrumentationScope(
242246
InstrumentationScopeInfo.builder(instrumentationName)
243247
.setVersion("1.2.3")
248+
.setSchemaUrl("http://schema.org")
244249
.build())
245250
.hasHistogramSatisfying(
246251
histogram ->
@@ -279,6 +284,7 @@ void doubleHistogram() {
279284
.hasInstrumentationScope(
280285
InstrumentationScopeInfo.builder(instrumentationName)
281286
.setVersion("1.2.3")
287+
.setSchemaUrl("http://schema.org")
282288
.build())
283289
.hasHistogramSatisfying(
284290
histogram ->
@@ -316,6 +322,7 @@ void longGauge() throws InterruptedException {
316322
.hasInstrumentationScope(
317323
InstrumentationScopeInfo.builder(instrumentationName)
318324
.setVersion("1.2.3")
325+
.setSchemaUrl("http://schema.org")
319326
.build())
320327
.hasLongGaugeSatisfying(
321328
gauge ->
@@ -360,6 +367,7 @@ void syncLongGauge() throws InterruptedException {
360367
.hasInstrumentationScope(
361368
InstrumentationScopeInfo.builder(instrumentationName)
362369
.setVersion("1.2.3")
370+
.setSchemaUrl("http://schema.org")
363371
.build())
364372
.hasLongGaugeSatisfying(
365373
gauge ->
@@ -403,6 +411,7 @@ void doubleGauge() throws InterruptedException {
403411
.hasInstrumentationScope(
404412
InstrumentationScopeInfo.builder(instrumentationName)
405413
.setVersion("1.2.3")
414+
.setSchemaUrl("http://schema.org")
406415
.build())
407416
.hasDoubleGaugeSatisfying(
408417
gauge ->
@@ -446,6 +455,7 @@ void syncDoubleGauge() throws InterruptedException {
446455
.hasInstrumentationScope(
447456
InstrumentationScopeInfo.builder(instrumentationName)
448457
.setVersion("1.2.3")
458+
.setSchemaUrl("http://schema.org")
449459
.build())
450460
.hasDoubleGaugeSatisfying(
451461
gauge ->

instrumentation/opentelemetry-api/opentelemetry-api-1.32/javaagent/src/incubatorTest/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_32/incubator/metrics/MeterTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ void longCounter() {
9191
.hasInstrumentationScope(
9292
InstrumentationScopeInfo.builder(instrumentationName)
9393
.setVersion("1.2.3")
94+
.setSchemaUrl("http://schema.org")
9495
.build())
9596
.hasLongSumSatisfying(
9697
sum ->
@@ -128,6 +129,7 @@ void doubleCounter() {
128129
.hasInstrumentationScope(
129130
InstrumentationScopeInfo.builder(instrumentationName)
130131
.setVersion("1.2.3")
132+
.setSchemaUrl("http://schema.org")
131133
.build())
132134
.hasDoubleSumSatisfying(
133135
sum ->
@@ -165,6 +167,7 @@ void longUpDownCounter() {
165167
.hasInstrumentationScope(
166168
InstrumentationScopeInfo.builder(instrumentationName)
167169
.setVersion("1.2.3")
170+
.setSchemaUrl("http://schema.org")
168171
.build())
169172
.hasLongSumSatisfying(
170173
sum ->
@@ -203,6 +206,7 @@ void doubleUpDownCounter() {
203206
.hasInstrumentationScope(
204207
InstrumentationScopeInfo.builder(instrumentationName)
205208
.setVersion("1.2.3")
209+
.setSchemaUrl("http://schema.org")
206210
.build())
207211
.hasDoubleSumSatisfying(
208212
sum ->
@@ -241,6 +245,7 @@ void longHistogram() {
241245
.hasInstrumentationScope(
242246
InstrumentationScopeInfo.builder(instrumentationName)
243247
.setVersion("1.2.3")
248+
.setSchemaUrl("http://schema.org")
244249
.build())
245250
.hasHistogramSatisfying(
246251
histogram ->
@@ -279,6 +284,7 @@ void doubleHistogram() {
279284
.hasInstrumentationScope(
280285
InstrumentationScopeInfo.builder(instrumentationName)
281286
.setVersion("1.2.3")
287+
.setSchemaUrl("http://schema.org")
282288
.build())
283289
.hasHistogramSatisfying(
284290
histogram ->
@@ -316,6 +322,7 @@ void longGauge() throws InterruptedException {
316322
.hasInstrumentationScope(
317323
InstrumentationScopeInfo.builder(instrumentationName)
318324
.setVersion("1.2.3")
325+
.setSchemaUrl("http://schema.org")
319326
.build())
320327
.hasLongGaugeSatisfying(
321328
gauge ->
@@ -360,6 +367,7 @@ void syncLongGauge() throws InterruptedException {
360367
.hasInstrumentationScope(
361368
InstrumentationScopeInfo.builder(instrumentationName)
362369
.setVersion("1.2.3")
370+
.setSchemaUrl("http://schema.org")
363371
.build())
364372
.hasLongGaugeSatisfying(
365373
gauge ->
@@ -403,6 +411,7 @@ void doubleGauge() throws InterruptedException {
403411
.hasInstrumentationScope(
404412
InstrumentationScopeInfo.builder(instrumentationName)
405413
.setVersion("1.2.3")
414+
.setSchemaUrl("http://schema.org")
406415
.build())
407416
.hasDoubleGaugeSatisfying(
408417
gauge ->
@@ -446,6 +455,7 @@ void syncDoubleGauge() throws InterruptedException {
446455
.hasInstrumentationScope(
447456
InstrumentationScopeInfo.builder(instrumentationName)
448457
.setVersion("1.2.3")
458+
.setSchemaUrl("http://schema.org")
449459
.build())
450460
.hasDoubleGaugeSatisfying(
451461
gauge ->

0 commit comments

Comments
 (0)