Deprecate multi argument InstrumentationScopeInfo create method (#4710)

* Deprecate multi argument InstrumentationScopeInfo create method

* PR feedback
This commit is contained in:
jack-berg 2022-08-24 13:35:31 -05:00 committed by GitHub
parent 8445642052
commit 2bc88f45c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
52 changed files with 262 additions and 166 deletions

View File

@ -2,6 +2,8 @@ Comparing source compatibility of against
**** MODIFIED CLASS: PUBLIC ABSTRACT io.opentelemetry.sdk.common.InstrumentationScopeInfo (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
+++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.sdk.common.InstrumentationScopeInfoBuilder builder(java.lang.String)
=== UNCHANGED METHOD: PUBLIC STATIC io.opentelemetry.sdk.common.InstrumentationScopeInfo create(java.lang.String, java.lang.String, java.lang.String)
+++ NEW ANNOTATION: java.lang.Deprecated
+++* NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.api.common.Attributes getAttributes()
+++ NEW CLASS: PUBLIC(+) FINAL(+) io.opentelemetry.sdk.common.InstrumentationScopeInfoBuilder (not serializable)
+++ CLASS FILE FORMAT VERSION: 52.0 <- n.a.

View File

@ -83,7 +83,9 @@ class JaegerThriftSpanExporterTest {
.setTotalRecordedLinks(0)
.setTotalRecordedEvents(0)
.setInstrumentationScopeInfo(
InstrumentationScopeInfo.create("io.opentelemetry.auto", "1.0.0", null))
InstrumentationScopeInfo.builder("io.opentelemetry.auto")
.setVersion("1.0.0")
.build())
.setResource(
Resource.create(
Attributes.of(
@ -158,7 +160,9 @@ class JaegerThriftSpanExporterTest {
.setTotalRecordedLinks(0)
.setTotalRecordedEvents(0)
.setInstrumentationScopeInfo(
InstrumentationScopeInfo.create("io.opentelemetry.auto", "1.0.0", null))
InstrumentationScopeInfo.builder("io.opentelemetry.auto")
.setVersion("1.0.0")
.build())
.setResource(
Resource.create(
Attributes.of(
@ -181,7 +185,9 @@ class JaegerThriftSpanExporterTest {
.setTotalRecordedLinks(0)
.setTotalRecordedEvents(0)
.setInstrumentationScopeInfo(
InstrumentationScopeInfo.create("io.opentelemetry.auto", "1.0.0", null))
InstrumentationScopeInfo.builder("io.opentelemetry.auto")
.setVersion("1.0.0")
.build())
.setResource(
Resource.create(
Attributes.of(

View File

@ -126,7 +126,9 @@ class JaegerGrpcSpanExporterTest {
.setTotalRecordedLinks(0)
.setTotalRecordedEvents(0)
.setInstrumentationScopeInfo(
InstrumentationScopeInfo.create("io.opentelemetry.auto", "1.0.0", null))
InstrumentationScopeInfo.builder("io.opentelemetry.auto")
.setVersion("1.0.0")
.build())
.setResource(
Resource.create(
Attributes.of(
@ -177,7 +179,9 @@ class JaegerGrpcSpanExporterTest {
.setTotalRecordedLinks(0)
.setTotalRecordedEvents(0)
.setInstrumentationScopeInfo(
InstrumentationScopeInfo.create("io.opentelemetry.auto", "1.0.0", null))
InstrumentationScopeInfo.builder("io.opentelemetry.auto")
.setVersion("1.0.0")
.build())
.setResource(
Resource.create(
Attributes.of(
@ -202,7 +206,9 @@ class JaegerGrpcSpanExporterTest {
.setTotalRecordedLinks(0)
.setTotalRecordedEvents(0)
.setInstrumentationScopeInfo(
InstrumentationScopeInfo.create("io.opentelemetry.auto", "1.0.0", null))
InstrumentationScopeInfo.builder("io.opentelemetry.auto")
.setVersion("1.0.0")
.build())
.setResource(
Resource.create(
Attributes.of(

View File

@ -61,7 +61,7 @@ class OtlpJsonLoggingLogExporterTest {
TestLogData.builder()
.setResource(RESOURCE)
.setInstrumentationScopeInfo(
InstrumentationScopeInfo.create("instrumentation2", "2", null))
InstrumentationScopeInfo.builder("instrumentation2").setVersion("2").build())
.setBody("body2")
.setSeverity(Severity.INFO)
.setSeverityText("INFO")

View File

@ -53,7 +53,7 @@ class OtlpJsonLoggingMetricExporterTest {
private static final MetricData METRIC2 =
ImmutableMetricData.createDoubleSum(
RESOURCE,
InstrumentationScopeInfo.create("instrumentation2", "2", null),
InstrumentationScopeInfo.builder("instrumentation2").setVersion("2").build(),
"metric2",
"metric2 description",
"s",

View File

@ -86,7 +86,7 @@ class OtlpJsonLoggingSpanExporterTest {
.setKind(SpanKind.CLIENT)
.setResource(RESOURCE)
.setInstrumentationScopeInfo(
InstrumentationScopeInfo.create("instrumentation2", "2", null))
InstrumentationScopeInfo.builder("instrumentation2").setVersion("2").build())
.build();
@RegisterExtension

View File

@ -63,7 +63,7 @@ class LoggingMetricExporterTest {
long nowEpochNanos = System.currentTimeMillis() * 1000 * 1000;
Resource resource = Resource.create(Attributes.of(stringKey("host"), "localhost"));
InstrumentationScopeInfo instrumentationScopeInfo =
InstrumentationScopeInfo.create("manualInstrumentation", "1.0", null);
InstrumentationScopeInfo.builder("manualInstrumentation").setVersion("1.0").build();
exporter.export(
Arrays.asList(
ImmutableMetricData.createDoubleSummary(

View File

@ -82,7 +82,8 @@ class LoggingSpanExporterTest {
.setStatus(StatusData.error())
.setName("testSpan2")
.setKind(SpanKind.CLIENT)
.setInstrumentationScopeInfo(InstrumentationScopeInfo.create("tracer2", "1.0", null))
.setInstrumentationScopeInfo(
InstrumentationScopeInfo.builder("tracer2").setVersion("1.0").build())
.build();
@RegisterExtension

View File

@ -53,7 +53,8 @@ class SystemOutLogExporterTest {
private static LogData sampleLog(long timestamp) {
return TestLogData.builder()
.setResource(Resource.empty())
.setInstrumentationScopeInfo(InstrumentationScopeInfo.create("logTest", "1.0", null))
.setInstrumentationScopeInfo(
InstrumentationScopeInfo.builder("logTest").setVersion("1.0").build())
.setAttributes(Attributes.of(stringKey("cheese"), "cheddar", longKey("amount"), 1L))
.setBody("message")
.setSeverity(Severity.ERROR3)

View File

@ -347,7 +347,10 @@ class OtlpHttpSpanExporterTest {
.setTotalRecordedLinks(0)
.setTotalRecordedEvents(0)
.setInstrumentationScopeInfo(
InstrumentationScopeInfo.create("testLib", "1.0", "http://url"))
InstrumentationScopeInfo.builder("testLib")
.setVersion("1.0")
.setSchemaUrl("http://url")
.build())
.build();
}
}

View File

@ -78,7 +78,10 @@ class OtlpGrpcSpanExporterTest extends AbstractGrpcTelemetryExporterTest<SpanDat
.setTotalRecordedLinks(0)
.setTotalRecordedEvents(0)
.setInstrumentationScopeInfo(
InstrumentationScopeInfo.create("testLib", "1.0", "http://url"))
InstrumentationScopeInfo.builder("testLib")
.setVersion("1.0")
.setSchemaUrl("http://url")
.build())
.build();
}

View File

@ -86,7 +86,10 @@ class OtlpGrpcNettySpanExporterTest
.setTotalRecordedLinks(0)
.setTotalRecordedEvents(0)
.setInstrumentationScopeInfo(
InstrumentationScopeInfo.create("testLib", "1.0", "http://url"))
InstrumentationScopeInfo.builder("testLib")
.setVersion("1.0")
.setSchemaUrl("http://url")
.build())
.build();
}

View File

@ -74,7 +74,10 @@ class OtlpGrpcNettyShadedSpanExporterTest
.setTotalRecordedLinks(0)
.setTotalRecordedEvents(0)
.setInstrumentationScopeInfo(
InstrumentationScopeInfo.create("testLib", "1.0", "http://url"))
InstrumentationScopeInfo.builder("testLib")
.setVersion("1.0")
.setSchemaUrl("http://url")
.build())
.build();
}

View File

@ -74,7 +74,10 @@ class OtlpGrpcOkHttpSpanExporterTest
.setTotalRecordedLinks(0)
.setTotalRecordedEvents(0)
.setInstrumentationScopeInfo(
InstrumentationScopeInfo.create("testLib", "1.0", "http://url"))
InstrumentationScopeInfo.builder("testLib")
.setVersion("1.0")
.setSchemaUrl("http://url")
.build())
.build();
}

View File

@ -103,7 +103,7 @@ class LogsRequestMarshalerTest {
.setResource(
Resource.create(Attributes.builder().put("testKey", "testValue").build()))
.setInstrumentationScopeInfo(
InstrumentationScopeInfo.create("instrumentation", "1", null))
InstrumentationScopeInfo.builder("instrumentation").setVersion("1").build())
.setBody(BODY)
.setSeverity(Severity.INFO)
.setSeverityText("INFO")
@ -137,7 +137,7 @@ class LogsRequestMarshalerTest {
.setResource(
Resource.create(Attributes.builder().put("testKey", "testValue").build()))
.setInstrumentationScopeInfo(
InstrumentationScopeInfo.create("instrumentation", "1", null))
InstrumentationScopeInfo.builder("instrumentation").setVersion("1").build())
.setEpoch(12345, TimeUnit.NANOSECONDS)
.build()));

View File

@ -342,7 +342,10 @@ class OtlpHttpLogExporterTest {
return TestLogData.builder()
.setResource(Resource.getDefault())
.setInstrumentationScopeInfo(
InstrumentationScopeInfo.create("testLib", "1.0", "http://url"))
InstrumentationScopeInfo.builder("testLib")
.setVersion("1.0")
.setSchemaUrl("http://url")
.build())
.setBody("log body")
.setAttributes(Attributes.builder().put("key", "value").build())
.setSeverity(Severity.INFO)

View File

@ -58,7 +58,8 @@ class OtlpGrpcLogExporterTest extends AbstractGrpcTelemetryExporterTest<LogData,
protected LogData generateFakeTelemetry() {
return TestLogData.builder()
.setResource(Resource.create(Attributes.builder().put("testKey", "testValue").build()))
.setInstrumentationScopeInfo(InstrumentationScopeInfo.create("instrumentation", "1", null))
.setInstrumentationScopeInfo(
InstrumentationScopeInfo.builder("instrumentation").setVersion("1").build())
.setEpoch(Instant.now())
.setSeverity(Severity.ERROR)
.setSeverityText("really severe")

View File

@ -66,7 +66,8 @@ class OtlpGrpcNettyLogExporterTest
protected LogData generateFakeTelemetry() {
return TestLogData.builder()
.setResource(Resource.create(Attributes.builder().put("testKey", "testValue").build()))
.setInstrumentationScopeInfo(InstrumentationScopeInfo.create("instrumentation", "1", null))
.setInstrumentationScopeInfo(
InstrumentationScopeInfo.builder("instrumentation").setVersion("1").build())
.setEpoch(Instant.now())
.setSeverity(Severity.ERROR)
.setSeverityText("really severe")

View File

@ -54,7 +54,8 @@ class OtlpGrpcNettyShadedLogExporterTest
protected LogData generateFakeTelemetry() {
return TestLogData.builder()
.setResource(Resource.create(Attributes.builder().put("testKey", "testValue").build()))
.setInstrumentationScopeInfo(InstrumentationScopeInfo.create("instrumentation", "1", null))
.setInstrumentationScopeInfo(
InstrumentationScopeInfo.builder("instrumentation").setVersion("1").build())
.setEpoch(Instant.now())
.setSeverity(Severity.ERROR)
.setSeverityText("really severe")

View File

@ -54,7 +54,8 @@ class OtlpGrpcNettyOkHttpLogExporterTest
protected LogData generateFakeTelemetry() {
return TestLogData.builder()
.setResource(Resource.create(Attributes.builder().put("testKey", "testValue").build()))
.setInstrumentationScopeInfo(InstrumentationScopeInfo.create("instrumentation", "1", null))
.setInstrumentationScopeInfo(
InstrumentationScopeInfo.builder("instrumentation").setVersion("1").build())
.setEpoch(Instant.now())
.setSeverity(Severity.ERROR)
.setSeverityText("really severe")

View File

@ -52,7 +52,7 @@ class MetricAdapterTest {
private static final MetricData MONOTONIC_CUMULATIVE_DOUBLE_SUM =
ImmutableMetricData.createDoubleSum(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationScopeInfo.create("full", "version", null),
InstrumentationScopeInfo.builder("full").setVersion("version").build(),
"instrument.name",
"description",
"1",
@ -65,7 +65,7 @@ class MetricAdapterTest {
private static final MetricData NON_MONOTONIC_CUMULATIVE_DOUBLE_SUM =
ImmutableMetricData.createDoubleSum(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationScopeInfo.create("full", "version", null),
InstrumentationScopeInfo.builder("full").setVersion("version").build(),
"instrument.name",
"description",
"1",
@ -78,7 +78,7 @@ class MetricAdapterTest {
private static final MetricData MONOTONIC_DELTA_DOUBLE_SUM =
ImmutableMetricData.createDoubleSum(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationScopeInfo.create("full", "version", null),
InstrumentationScopeInfo.builder("full").setVersion("version").build(),
"instrument.name",
"description",
"1",
@ -91,7 +91,7 @@ class MetricAdapterTest {
private static final MetricData NON_MONOTONIC_DELTA_DOUBLE_SUM =
ImmutableMetricData.createDoubleSum(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationScopeInfo.create("full", "version", null),
InstrumentationScopeInfo.builder("full").setVersion("version").build(),
"instrument.name",
"description",
"1",
@ -104,7 +104,7 @@ class MetricAdapterTest {
private static final MetricData MONOTONIC_CUMULATIVE_LONG_SUM =
ImmutableMetricData.createLongSum(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationScopeInfo.create("full", "version", null),
InstrumentationScopeInfo.builder("full").setVersion("version").build(),
"instrument.name",
"description",
"1",
@ -117,7 +117,7 @@ class MetricAdapterTest {
private static final MetricData NON_MONOTONIC_CUMULATIVE_LONG_SUM =
ImmutableMetricData.createLongSum(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationScopeInfo.create("full", "version", null),
InstrumentationScopeInfo.builder("full").setVersion("version").build(),
"instrument.name",
"description",
"1",
@ -130,7 +130,7 @@ class MetricAdapterTest {
private static final MetricData MONOTONIC_DELTA_LONG_SUM =
ImmutableMetricData.createLongSum(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationScopeInfo.create("full", "version", null),
InstrumentationScopeInfo.builder("full").setVersion("version").build(),
"instrument.name",
"description",
"1",
@ -143,7 +143,7 @@ class MetricAdapterTest {
private static final MetricData NON_MONOTONIC_DELTA_LONG_SUM =
ImmutableMetricData.createLongSum(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationScopeInfo.create("full", "version", null),
InstrumentationScopeInfo.builder("full").setVersion("version").build(),
"instrument.name",
"description",
"1",
@ -157,7 +157,7 @@ class MetricAdapterTest {
private static final MetricData DOUBLE_GAUGE =
ImmutableMetricData.createDoubleGauge(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationScopeInfo.create("full", "version", null),
InstrumentationScopeInfo.builder("full").setVersion("version").build(),
"instrument.name",
"description",
"1",
@ -168,7 +168,7 @@ class MetricAdapterTest {
private static final MetricData LONG_GAUGE =
ImmutableMetricData.createLongGauge(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationScopeInfo.create("full", "version", null),
InstrumentationScopeInfo.builder("full").setVersion("version").build(),
"instrument.name",
"description",
"1",
@ -179,7 +179,7 @@ class MetricAdapterTest {
private static final MetricData SUMMARY =
ImmutableMetricData.createDoubleSummary(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationScopeInfo.create("full", "version", null),
InstrumentationScopeInfo.builder("full").setVersion("version").build(),
"instrument.name",
"description",
"1",
@ -197,7 +197,7 @@ class MetricAdapterTest {
private static final MetricData HISTOGRAM =
ImmutableMetricData.createDoubleHistogram(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationScopeInfo.create("full", "version", null),
InstrumentationScopeInfo.builder("full").setVersion("version").build(),
"instrument.name",
"description",
"1",

View File

@ -79,7 +79,7 @@ class PrometheusCollectorTest {
return ImmutableList.of(
ImmutableMetricData.createLongSum(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationScopeInfo.create("grpc", "version", null),
InstrumentationScopeInfo.builder("grpc").setVersion("version").build(),
"grpc.name",
"long_description",
"1",
@ -94,7 +94,7 @@ class PrometheusCollectorTest {
5)))),
ImmutableMetricData.createDoubleSum(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationScopeInfo.create("http", "version", null),
InstrumentationScopeInfo.builder("http").setVersion("version").build(),
"http.name",
"double_description",
"1",

View File

@ -173,7 +173,7 @@ class PrometheusHttpServerTest {
return ImmutableList.of(
ImmutableMetricData.createLongSum(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationScopeInfo.create("grpc", "version", null),
InstrumentationScopeInfo.builder("grpc").setVersion("version").build(),
"grpc.name",
"long_description",
"1",
@ -185,7 +185,7 @@ class PrometheusHttpServerTest {
123, 456, Attributes.of(stringKey("kp"), "vp"), 5)))),
ImmutableMetricData.createDoubleSum(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationScopeInfo.create("http", "version", null),
InstrumentationScopeInfo.builder("http").setVersion("version").build(),
"http.name",
"double_description",
"1",

View File

@ -43,7 +43,7 @@ class SerializerTest {
private static final MetricData MONOTONIC_CUMULATIVE_DOUBLE_SUM =
ImmutableMetricData.createDoubleSum(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationScopeInfo.create("full", "version", null),
InstrumentationScopeInfo.builder("full").setVersion("version").build(),
"instrument.name",
"description",
"1",
@ -59,7 +59,7 @@ class SerializerTest {
private static final MetricData NON_MONOTONIC_CUMULATIVE_DOUBLE_SUM =
ImmutableMetricData.createDoubleSum(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationScopeInfo.create("full", "version", null),
InstrumentationScopeInfo.builder("full").setVersion("version").build(),
"instrument.name",
"description",
"1",
@ -75,7 +75,7 @@ class SerializerTest {
private static final MetricData MONOTONIC_DELTA_DOUBLE_SUM =
ImmutableMetricData.createDoubleSum(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationScopeInfo.create("full", "version", null),
InstrumentationScopeInfo.builder("full").setVersion("version").build(),
"instrument.name",
"unused",
"1",
@ -91,7 +91,7 @@ class SerializerTest {
private static final MetricData NON_MONOTONIC_DELTA_DOUBLE_SUM =
ImmutableMetricData.createDoubleSum(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationScopeInfo.create("full", "version", null),
InstrumentationScopeInfo.builder("full").setVersion("version").build(),
"instrument.name",
"unused",
"1",
@ -107,7 +107,7 @@ class SerializerTest {
private static final MetricData MONOTONIC_CUMULATIVE_LONG_SUM =
ImmutableMetricData.createLongSum(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationScopeInfo.create("full", "version", null),
InstrumentationScopeInfo.builder("full").setVersion("version").build(),
"instrument.name",
"unused",
"1",
@ -123,7 +123,7 @@ class SerializerTest {
private static final MetricData NON_MONOTONIC_CUMULATIVE_LONG_SUM =
ImmutableMetricData.createLongSum(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationScopeInfo.create("full", "version", null),
InstrumentationScopeInfo.builder("full").setVersion("version").build(),
"instrument.name",
"unused",
"1",
@ -139,7 +139,7 @@ class SerializerTest {
private static final MetricData MONOTONIC_DELTA_LONG_SUM =
ImmutableMetricData.createLongSum(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationScopeInfo.create("full", "version", null),
InstrumentationScopeInfo.builder("full").setVersion("version").build(),
"instrument.name",
"unused",
"1",
@ -155,7 +155,7 @@ class SerializerTest {
private static final MetricData NON_MONOTONIC_DELTA_LONG_SUM =
ImmutableMetricData.createLongSum(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationScopeInfo.create("full", "version", null),
InstrumentationScopeInfo.builder("full").setVersion("version").build(),
"instrument.name",
"unused",
"1",
@ -172,7 +172,7 @@ class SerializerTest {
private static final MetricData DOUBLE_GAUGE =
ImmutableMetricData.createDoubleGauge(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationScopeInfo.create("full", "version", null),
InstrumentationScopeInfo.builder("full").setVersion("version").build(),
"instrument.name",
"unused",
"1",
@ -183,7 +183,7 @@ class SerializerTest {
private static final MetricData LONG_GAUGE =
ImmutableMetricData.createLongGauge(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationScopeInfo.create("full", "version", null),
InstrumentationScopeInfo.builder("full").setVersion("version").build(),
"instrument.name",
"unused",
"1",
@ -194,7 +194,7 @@ class SerializerTest {
private static final MetricData SUMMARY =
ImmutableMetricData.createDoubleSummary(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationScopeInfo.create("full", "version", null),
InstrumentationScopeInfo.builder("full").setVersion("version").build(),
"instrument.name",
"unused",
"1",
@ -212,7 +212,7 @@ class SerializerTest {
private static final MetricData HISTOGRAM_NO_ATTRIBUTES =
ImmutableMetricData.createDoubleHistogram(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationScopeInfo.create("full", "version", null),
InstrumentationScopeInfo.builder("full").setVersion("version").build(),
"instrument.name",
"unused",
"1",
@ -241,7 +241,7 @@ class SerializerTest {
private static final MetricData HISTOGRAM_SINGLE_ATTRIBUTE =
ImmutableMetricData.createDoubleHistogram(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationScopeInfo.create("full", "version", null),
InstrumentationScopeInfo.builder("full").setVersion("version").build(),
"instrument.name",
"unused",
"1",
@ -270,7 +270,7 @@ class SerializerTest {
private static final MetricData DOUBLE_GAUGE_NO_ATTRIBUTES =
ImmutableMetricData.createDoubleGauge(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationScopeInfo.create("full", "version", null),
InstrumentationScopeInfo.builder("full").setVersion("version").build(),
"instrument.name",
"unused",
"1",
@ -281,7 +281,7 @@ class SerializerTest {
private static final MetricData DOUBLE_GAUGE_MULTIPLE_ATTRIBUTES =
ImmutableMetricData.createDoubleGauge(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationScopeInfo.create("full", "version", null),
InstrumentationScopeInfo.builder("full").setVersion("version").build(),
"instrument.name",
"unused",
"1",

View File

@ -205,7 +205,9 @@ class OtelToZipkinSpanTransformerTest {
SpanData data =
spanBuilder()
.setInstrumentationScopeInfo(
InstrumentationScopeInfo.create("io.opentelemetry.auto", "1.0.0", null))
InstrumentationScopeInfo.builder("io.opentelemetry.auto")
.setVersion("1.0.0")
.build())
.setKind(SpanKind.CLIENT)
.build();

View File

@ -37,8 +37,7 @@ class CounterTest {
metric ->
assertThat(metric)
.hasName("testCounter")
.hasInstrumentationScope(
InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null))
.hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME))
.hasDescription("This is a test counter")
.hasUnit("items")
.hasDoubleSumSatisfying(

View File

@ -38,8 +38,7 @@ class DistributionSummaryTest {
metric ->
assertThat(metric)
.hasName("testSummary")
.hasInstrumentationScope(
InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null))
.hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME))
.hasDescription("This is a test distribution summary")
.hasUnit("things")
.hasHistogramSatisfying(
@ -102,8 +101,7 @@ class DistributionSummaryTest {
metric ->
assertThat(metric)
.hasName("testSummary")
.hasInstrumentationScope(
InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null))
.hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME))
.hasDescription("This is a test distribution summary")
.hasUnit("things")
.hasHistogramSatisfying(
@ -175,8 +173,7 @@ class DistributionSummaryTest {
metric ->
assertThat(metric)
.hasName("testSummary")
.hasInstrumentationScope(
InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null))
.hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME))
.hasDescription("This is a test distribution summary")
.hasUnit("things")
.hasHistogramSatisfying(

View File

@ -40,8 +40,7 @@ class FunctionCounterTest {
metric ->
assertThat(metric)
.hasName("testFunctionCounter")
.hasInstrumentationScope(
InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null))
.hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME))
.hasDescription("This is a test function counter")
.hasUnit("items")
.hasDoubleSumSatisfying(

View File

@ -57,8 +57,7 @@ class FunctionTimerSecondsTest {
metric ->
assertThat(metric)
.hasName("testFunctionTimerSeconds.count")
.hasInstrumentationScope(
InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null))
.hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME))
.hasDescription("This is a test function timer")
.hasUnit("1")
.hasLongSumSatisfying(
@ -72,8 +71,7 @@ class FunctionTimerSecondsTest {
metric ->
assertThat(metric)
.hasName("testFunctionTimerSeconds.sum")
.hasInstrumentationScope(
InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null))
.hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME))
.hasDescription("This is a test function timer")
.hasUnit("s")
.hasDoubleSumSatisfying(

View File

@ -52,8 +52,7 @@ class FunctionTimerTest {
metric ->
assertThat(metric)
.hasName("testFunctionTimer.count")
.hasInstrumentationScope(
InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null))
.hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME))
.hasDescription("This is a test function timer")
.hasUnit("1")
.hasLongSumSatisfying(
@ -67,8 +66,7 @@ class FunctionTimerTest {
metric ->
assertThat(metric)
.hasName("testFunctionTimer.sum")
.hasInstrumentationScope(
InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null))
.hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME))
.hasDescription("This is a test function timer")
.hasUnit("ms")
.hasDoubleSumSatisfying(

View File

@ -38,8 +38,7 @@ class GaugeTest {
metric ->
assertThat(metric)
.hasName("testGauge")
.hasInstrumentationScope(
InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null))
.hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME))
.hasDescription("This is a test gauge")
.hasUnit("items")
.hasDoubleGaugeSatisfying(

View File

@ -54,8 +54,7 @@ class LongTaskTimerHistogramTest {
metric ->
assertThat(metric)
.hasName("testLongTaskTimerHistogram.active")
.hasInstrumentationScope(
InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null))
.hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME))
.hasDescription("This is a test timer")
.hasUnit("tasks")
.hasLongSumSatisfying(
@ -66,8 +65,7 @@ class LongTaskTimerHistogramTest {
metric ->
assertThat(metric)
.hasName("testLongTaskTimerHistogram.duration")
.hasInstrumentationScope(
InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null))
.hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME))
.hasDescription("This is a test timer")
.hasUnit("ms")
.hasDoubleSumSatisfying(
@ -84,8 +82,7 @@ class LongTaskTimerHistogramTest {
metric ->
assertThat(metric)
.hasName("testLongTaskTimerHistogram.histogram")
.hasInstrumentationScope(
InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null))
.hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME))
.hasDoubleGaugeSatisfying(
gauge ->
gauge.hasPointsSatisfying(
@ -106,8 +103,7 @@ class LongTaskTimerHistogramTest {
metric ->
assertThat(metric)
.hasName("testLongTaskTimerHistogram.active")
.hasInstrumentationScope(
InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null))
.hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME))
.hasDescription("This is a test timer")
.hasUnit("tasks")
.hasLongSumSatisfying(
@ -118,8 +114,7 @@ class LongTaskTimerHistogramTest {
metric ->
assertThat(metric)
.hasName("testLongTaskTimerHistogram.duration")
.hasInstrumentationScope(
InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null))
.hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME))
.hasDescription("This is a test timer")
.hasUnit("ms")
.hasDoubleSumSatisfying(

View File

@ -47,8 +47,7 @@ class LongTaskTimerSecondsTest {
metric ->
assertThat(metric)
.hasName("testLongTaskTimerSeconds.active")
.hasInstrumentationScope(
InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null))
.hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME))
.hasDescription("This is a test long task timer")
.hasUnit("tasks")
.hasLongSumSatisfying(
@ -62,8 +61,7 @@ class LongTaskTimerSecondsTest {
metric ->
assertThat(metric)
.hasName("testLongTaskTimerSeconds.duration")
.hasInstrumentationScope(
InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null))
.hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME))
.hasDescription("This is a test long task timer")
.hasUnit("s")
.hasDoubleSumSatisfying(

View File

@ -36,8 +36,7 @@ class LongTaskTimerTest {
metric ->
assertThat(metric)
.hasName("testLongTaskTimer.active")
.hasInstrumentationScope(
InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null))
.hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME))
.hasDescription("This is a test long task timer")
.hasUnit("tasks")
.hasLongSumSatisfying(

View File

@ -52,8 +52,7 @@ class MeterTest {
metric ->
assertThat(metric)
.hasName("testMeter.total")
.hasInstrumentationScope(
InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null))
.hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME))
.hasDescription("This is a test meter")
.hasUnit("things")
.hasDoubleSumSatisfying(

View File

@ -67,8 +67,7 @@ class NamingConventionTest {
metric ->
assertThat(metric)
.hasName("test.renamedCounter")
.hasInstrumentationScope(
InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null))
.hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME))
.hasDoubleSumSatisfying(
sum ->
sum.hasPointsSatisfying(

View File

@ -62,8 +62,7 @@ class PrometheusModeTest {
metric ->
assertThat(metric)
.hasName("testPrometheusCounter.items")
.hasInstrumentationScope(
InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null))
.hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME))
.hasDescription("This is a test counter")
.hasUnit("items")
.hasDoubleSumSatisfying(
@ -96,8 +95,7 @@ class PrometheusModeTest {
metric ->
assertThat(metric)
.hasName("testPrometheusSummary.items")
.hasInstrumentationScope(
InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null))
.hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME))
.hasDescription("This is a test summary")
.hasUnit("items")
.hasHistogramSatisfying(
@ -111,8 +109,7 @@ class PrometheusModeTest {
metric ->
assertThat(metric)
.hasName("testPrometheusSummary.items.max")
.hasInstrumentationScope(
InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null))
.hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME))
.hasDescription("This is a test summary")
.hasUnit("items")
.hasDoubleGaugeSatisfying(
@ -146,8 +143,7 @@ class PrometheusModeTest {
metric ->
assertThat(metric)
.hasName("testPrometheusFunctionTimer.seconds.count")
.hasInstrumentationScope(
InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null))
.hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME))
.hasDescription("This is a test function timer")
.hasUnit("1")
.hasLongSumSatisfying(
@ -161,8 +157,7 @@ class PrometheusModeTest {
metric ->
assertThat(metric)
.hasName("testPrometheusFunctionTimer.seconds.sum")
.hasInstrumentationScope(
InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null))
.hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME))
.hasDescription("This is a test function timer")
.hasUnit("s")
.hasDoubleSumSatisfying(
@ -189,8 +184,7 @@ class PrometheusModeTest {
metric ->
assertThat(metric)
.hasName("testPrometheusGauge.items")
.hasInstrumentationScope(
InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null))
.hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME))
.hasDescription("This is a test gauge")
.hasUnit("items")
.hasDoubleGaugeSatisfying(
@ -220,8 +214,7 @@ class PrometheusModeTest {
metric ->
assertThat(metric)
.hasName("testPrometheusLongTaskTimer.seconds.active")
.hasInstrumentationScope(
InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null))
.hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME))
.hasDescription("This is a test long task timer")
.hasUnit("tasks")
.hasLongSumSatisfying(
@ -235,8 +228,7 @@ class PrometheusModeTest {
metric ->
assertThat(metric)
.hasName("testPrometheusLongTaskTimer.seconds.duration")
.hasInstrumentationScope(
InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null))
.hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME))
.hasDescription("This is a test long task timer")
.hasUnit("s")
.hasDoubleSumSatisfying(
@ -300,8 +292,7 @@ class PrometheusModeTest {
metric ->
assertThat(metric)
.hasName("testPrometheusTimer.seconds")
.hasInstrumentationScope(
InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null))
.hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME))
.hasDescription("This is a test timer")
.hasUnit("s")
.hasHistogramSatisfying(
@ -315,8 +306,7 @@ class PrometheusModeTest {
metric ->
assertThat(metric)
.hasName("testPrometheusTimer.seconds.max")
.hasInstrumentationScope(
InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null))
.hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME))
.hasDescription("This is a test timer")
.hasUnit("s")
.hasDoubleGaugeSatisfying(

View File

@ -47,8 +47,7 @@ class TimerSecondsTest {
metric ->
assertThat(metric)
.hasName("testTimerSeconds")
.hasInstrumentationScope(
InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null))
.hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME))
.hasDescription("This is a test timer")
.hasUnit("s")
.hasHistogramSatisfying(
@ -80,8 +79,7 @@ class TimerSecondsTest {
metric ->
assertThat(metric)
.hasName("testTimerSeconds")
.hasInstrumentationScope(
InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null))
.hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME))
.hasDescription("This is a test timer")
.hasUnit("s")
.hasHistogramSatisfying(

View File

@ -39,8 +39,7 @@ class TimerTest {
metric ->
assertThat(metric)
.hasName("testTimer")
.hasInstrumentationScope(
InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null))
.hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME))
.hasDescription("This is a test timer")
.hasUnit("ms")
.hasHistogramSatisfying(
@ -137,8 +136,7 @@ class TimerTest {
metric ->
assertThat(metric)
.hasName("testTimer")
.hasInstrumentationScope(
InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null))
.hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME))
.hasDescription("This is a test timer")
.hasUnit("ms")
.hasHistogramSatisfying(
@ -210,8 +208,7 @@ class TimerTest {
metric ->
assertThat(metric)
.hasName("testTimer")
.hasInstrumentationScope(
InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null))
.hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME))
.hasDescription("This is a test timer")
.hasUnit("ms")
.hasHistogramSatisfying(

View File

@ -30,7 +30,12 @@ public abstract class InstrumentationScopeInfo {
return InstrumentationScopeInfo.create(name, null, null, Attributes.empty());
}
/** Creates a new instance of {@link InstrumentationScopeInfo}. */
/**
* Creates a new instance of {@link InstrumentationScopeInfo}.
*
* @deprecated Use {@link #builder(String)} or {@link #create(String)}.
*/
@Deprecated
public static InstrumentationScopeInfo create(
String name, @Nullable String version, @Nullable String schemaUrl) {
return InstrumentationScopeInfo.create(name, version, schemaUrl, Attributes.empty());

View File

@ -6,6 +6,7 @@
package io.opentelemetry.sdk.internal;
import io.opentelemetry.sdk.common.InstrumentationScopeInfo;
import io.opentelemetry.sdk.common.InstrumentationScopeInfoBuilder;
/**
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
@ -27,10 +28,15 @@ public final class InstrumentationScopeUtil {
@SuppressWarnings("deprecation") // Utility method for compatibility
public static InstrumentationScopeInfo toInstrumentationScopeInfo(
io.opentelemetry.sdk.common.InstrumentationLibraryInfo instrumentationLibraryInfo) {
return InstrumentationScopeInfo.create(
instrumentationLibraryInfo.getName(),
instrumentationLibraryInfo.getVersion(),
instrumentationLibraryInfo.getSchemaUrl());
InstrumentationScopeInfoBuilder builder =
InstrumentationScopeInfo.builder(instrumentationLibraryInfo.getName());
if (instrumentationLibraryInfo.getVersion() != null) {
builder.setVersion(instrumentationLibraryInfo.getVersion());
}
if (instrumentationLibraryInfo.getSchemaUrl() != null) {
builder.setSchemaUrl(instrumentationLibraryInfo.getSchemaUrl());
}
return builder.build();
}
private InstrumentationScopeUtil() {}

View File

@ -6,7 +6,6 @@
package io.opentelemetry.sdk.common;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import io.opentelemetry.api.common.Attributes;
@ -23,18 +22,35 @@ class InstrumentationScopeInfoTest {
@Test
void create_Valid() {
assertThatCode(() -> InstrumentationScopeInfo.builder("name").build())
.doesNotThrowAnyException();
assertThatCode(() -> InstrumentationScopeInfo.builder("name").setVersion(null).build())
.doesNotThrowAnyException();
assertThatCode(() -> InstrumentationScopeInfo.builder("name").setSchemaUrl(null).build())
.doesNotThrowAnyException();
assertThatCode(
() ->
InstrumentationScopeInfo scope = InstrumentationScopeInfo.builder("name").build();
assertThat(scope.getName()).isEqualTo("name");
assertThat(scope.getVersion()).isNull();
assertThat(scope.getSchemaUrl()).isNull();
assertThat(scope.getAttributes()).isEqualTo(Attributes.empty());
scope =
InstrumentationScopeInfo.builder("name")
.setVersion("version")
.setSchemaUrl("schemaUrl")
.setAttributes(Attributes.builder().put("key", "value").build())
.build())
.doesNotThrowAnyException();
.build();
assertThat(scope.getName()).isEqualTo("name");
assertThat(scope.getVersion()).isEqualTo("version");
assertThat(scope.getSchemaUrl()).isEqualTo("schemaUrl");
assertThat(scope.getAttributes()).isEqualTo(Attributes.builder().put("key", "value").build());
}
@Test
@SuppressWarnings("deprecation") // Testing deprecated code
void create_AllArgs() {
assertThat(InstrumentationScopeInfo.create("name", "version", "schemaUrl"))
.isEqualTo(
InstrumentationScopeInfo.builder("name")
.setVersion("version")
.setSchemaUrl("schemaUrl")
.build());
assertThat(InstrumentationScopeInfo.create("name", null, null))
.isEqualTo(InstrumentationScopeInfo.builder("name").build());
}
@Test

View File

@ -0,0 +1,52 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.sdk.internal;
import static org.assertj.core.api.Assertions.assertThat;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.sdk.common.InstrumentationScopeInfo;
import org.junit.jupiter.api.Test;
@SuppressWarnings("deprecation") // Testing deprecated code
class InstrumentationScopeUtilTest {
@Test
void toInstrumentationLibraryInfo() {
assertThat(
InstrumentationScopeUtil.toInstrumentationLibraryInfo(
InstrumentationScopeInfo.builder("name").build()))
.isEqualTo(
io.opentelemetry.sdk.common.InstrumentationLibraryInfo.create("name", null, null));
assertThat(
InstrumentationScopeUtil.toInstrumentationLibraryInfo(
InstrumentationScopeInfo.builder("name")
.setVersion("version")
.setSchemaUrl("schemaUrl")
.setAttributes(Attributes.builder().put("key", "value").build())
.build()))
.isEqualTo(
io.opentelemetry.sdk.common.InstrumentationLibraryInfo.create(
"name", "version", "schemaUrl"));
}
@Test
void toInstrumentationScopeInfo() {
assertThat(
InstrumentationScopeUtil.toInstrumentationScopeInfo(
io.opentelemetry.sdk.common.InstrumentationLibraryInfo.create("name", null, null)))
.isEqualTo(InstrumentationScopeInfo.builder("name").build());
assertThat(
InstrumentationScopeUtil.toInstrumentationScopeInfo(
io.opentelemetry.sdk.common.InstrumentationLibraryInfo.create(
"name", "version", "schemaUrl")))
.isEqualTo(
InstrumentationScopeInfo.builder("name")
.setVersion("version")
.setSchemaUrl("schemaUrl")
.build());
}
}

View File

@ -185,7 +185,10 @@ class SdkLogEmitterProviderTest {
@Test
void logEmitterBuilder_PropagatesToEmitter() {
InstrumentationScopeInfo expected =
InstrumentationScopeInfo.create("test", "version", "http://url");
InstrumentationScopeInfo.builder("test")
.setVersion("version")
.setSchemaUrl("http://url")
.build();
assertThat(
((SdkLogEmitter)
sdkLogEmitterProvider

View File

@ -173,7 +173,7 @@ class IdentityTest {
metricData ->
assertThat(metricData)
.hasInstrumentationScope(
InstrumentationScopeInfo.create("meter1", "version1", null))
InstrumentationScopeInfo.builder("meter1").setVersion("version1").build())
.hasName("counter1")
.hasLongSumSatisfying(
sum -> sum.hasPointsSatisfying(point -> point.hasValue(10))));
@ -199,14 +199,17 @@ class IdentityTest {
metricData ->
assertThat(metricData)
.hasInstrumentationScope(
InstrumentationScopeInfo.create("meter1", "version1", null))
InstrumentationScopeInfo.builder("meter1").setVersion("version1").build())
.hasName("counter1")
.hasLongSumSatisfying(
sum -> sum.hasPointsSatisfying(point -> point.hasValue(10))),
metricData ->
assertThat(metricData)
.hasInstrumentationScope(
InstrumentationScopeInfo.create("meter1", "version1", "schema1"))
InstrumentationScopeInfo.builder("meter1")
.setVersion("version1")
.setSchemaUrl("schema1")
.build())
.hasName("counter1")
.hasLongSumSatisfying(
sum -> sum.hasPointsSatisfying(point -> point.hasValue(10))));
@ -566,7 +569,7 @@ class IdentityTest {
metricData ->
assertThat(metricData)
.hasInstrumentationScope(
InstrumentationScopeInfo.create("meter1", "version1", null))
InstrumentationScopeInfo.builder("meter1").setVersion("version1").build())
.hasName("counter1")
.hasDescription("description1")
.hasLongSumSatisfying(
@ -574,7 +577,7 @@ class IdentityTest {
metricData -> {
assertThat(metricData)
.hasInstrumentationScope(
InstrumentationScopeInfo.create("meter1", "version2", null))
InstrumentationScopeInfo.builder("meter1").setVersion("version2").build())
.hasName("counter1")
.hasLongSumSatisfying(
sum -> sum.hasPointsSatisfying(point -> point.hasValue(10)));
@ -613,7 +616,7 @@ class IdentityTest {
metricData ->
assertThat(metricData)
.hasInstrumentationScope(
InstrumentationScopeInfo.create("meter1", null, "schema1"))
InstrumentationScopeInfo.builder("meter1").setSchemaUrl("schema1").build())
.hasName("counter1")
.hasDescription("description1")
.hasLongSumSatisfying(
@ -621,7 +624,7 @@ class IdentityTest {
metricData -> {
assertThat(metricData)
.hasInstrumentationScope(
InstrumentationScopeInfo.create("meter1", null, "schema2"))
InstrumentationScopeInfo.builder("meter1").setSchemaUrl("schema2").build())
.hasName("counter1")
.hasLongSumSatisfying(
sum -> sum.hasPointsSatisfying(point -> point.hasValue(10)));

View File

@ -91,7 +91,10 @@ class SdkMeterRegistryTest {
@Test
void propagatesInstrumentationScopeInfoToMeter() {
InstrumentationScopeInfo expected =
InstrumentationScopeInfo.create("theName", "theVersion", "http://theschema");
InstrumentationScopeInfo.builder("theName")
.setVersion("theVersion")
.setSchemaUrl("http://theschema")
.build();
SdkMeter meter =
(SdkMeter)
meterProvider

View File

@ -39,7 +39,7 @@ import org.mockito.junit.jupiter.MockitoExtension;
public class SynchronousMetricStorageTest {
private static final Resource RESOURCE = Resource.empty();
private static final InstrumentationScopeInfo INSTRUMENTATION_SCOPE_INFO =
InstrumentationScopeInfo.create("test", "1.0", null);
InstrumentationScopeInfo.builder("test").setVersion("1.0").build();
private static final InstrumentDescriptor DESCRIPTOR =
InstrumentDescriptor.create(
"name", "description", "unit", InstrumentType.COUNTER, InstrumentValueType.DOUBLE);

View File

@ -30,7 +30,10 @@ class ViewRegistryTest {
@RegisterExtension LogCapturer logs = LogCapturer.create().captureForType(ViewRegistry.class);
private static final InstrumentationScopeInfo INSTRUMENTATION_SCOPE_INFO =
InstrumentationScopeInfo.create("name", "version", "schema_url");
InstrumentationScopeInfo.builder("name")
.setVersion("version")
.setSchemaUrl("schema_url")
.build();
private static RegisteredView registeredView(InstrumentSelector instrumentSelector, View view) {
return RegisteredView.create(

View File

@ -53,7 +53,7 @@ class MetricAssertionsTest {
private static final Resource RESOURCE =
Resource.create(Attributes.builder().put("dog", "bark").build());
private static final InstrumentationScopeInfo INSTRUMENTATION_SCOPE_INFO =
InstrumentationScopeInfo.create("opentelemetry", "1.0", null);
InstrumentationScopeInfo.builder("opentelemetry").setVersion("1.0").build();
private static final AttributeKey<String> BEAR = AttributeKey.stringKey("bear");
private static final AttributeKey<String> CAT = AttributeKey.stringKey("cat");

View File

@ -46,7 +46,7 @@ class TraceAssertionsTest {
private static final Resource RESOURCE =
Resource.create(Attributes.builder().put("dog", "bark").build());
private static final InstrumentationScopeInfo INSTRUMENTATION_SCOPE_INFO =
InstrumentationScopeInfo.create("opentelemetry", "1.0", null);
InstrumentationScopeInfo.builder("opentelemetry").setVersion("1.0").build();
private static final AttributeKey<String> BEAR = AttributeKey.stringKey("bear");
private static final AttributeKey<String> CAT = AttributeKey.stringKey("cat");

View File

@ -171,7 +171,10 @@ class SdkTracerProviderTest {
@Test
void propagatesInstrumentationScopeInfoToTracer() {
InstrumentationScopeInfo expected =
InstrumentationScopeInfo.create("theName", "theVersion", "http://url");
InstrumentationScopeInfo.builder("theName")
.setVersion("theVersion")
.setSchemaUrl("http://url")
.build();
Tracer tracer =
tracerFactory
.tracerBuilder(expected.getName())

View File

@ -27,8 +27,10 @@ class SdkTracerTest {
"io.opentelemetry.sdk.trace.TracerSdkTest";
private static final String INSTRUMENTATION_SCOPE_VERSION = "0.2.0";
private static final InstrumentationScopeInfo instrumentationScopeInfo =
InstrumentationScopeInfo.create(
INSTRUMENTATION_SCOPE_NAME, INSTRUMENTATION_SCOPE_VERSION, "http://schemaurl");
InstrumentationScopeInfo.builder(INSTRUMENTATION_SCOPE_NAME)
.setVersion(INSTRUMENTATION_SCOPE_VERSION)
.setSchemaUrl("http://schemaurl")
.build();
private final SdkTracer tracer =
(SdkTracer)
SdkTracerProvider.builder()
@ -51,12 +53,7 @@ class SdkTracerTest {
@Test
void propagatesInstrumentationScopeInfoToSpan() {
ReadableSpan readableSpan = (ReadableSpan) tracer.spanBuilder("spanName").startSpan();
assertThat(readableSpan.getInstrumentationScopeInfo())
.isEqualTo(
InstrumentationScopeInfo.create(
instrumentationScopeInfo.getName(),
instrumentationScopeInfo.getVersion(),
instrumentationScopeInfo.getSchemaUrl()));
assertThat(readableSpan.getInstrumentationScopeInfo()).isEqualTo(instrumentationScopeInfo);
}
@Test