Skip to content

Commit

Permalink
Use custom resource to avoid version number in assertion string.
Browse files Browse the repository at this point in the history
  • Loading branch information
anuraaga committed Jan 7, 2022
1 parent edbe46a commit 28f05d4
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.trace.TracerProvider;
import io.opentelemetry.context.propagation.ContextPropagators;
Expand Down Expand Up @@ -284,10 +285,13 @@ void minimalOpenTelemetrySdkConfigurationDemo() {
void stringRepresentation() {
SpanExporter exporter = mock(SpanExporter.class);
when(exporter.toString()).thenReturn("MockSpanExporter{}");
Resource resource =
Resource.builder().put(AttributeKey.stringKey("service.name"), "otel-test").build();
OpenTelemetrySdk sdk =
OpenTelemetrySdk.builder()
.setTracerProvider(
SdkTracerProvider.builder()
.setResource(resource)
.addSpanProcessor(
SimpleSpanProcessor.create(SpanExporter.composite(exporter, exporter)))
.build())
Expand All @@ -299,7 +303,7 @@ void stringRepresentation() {
+ "tracerProvider=SdkTracerProvider{"
+ "clock=SystemClock{}, "
+ "idGenerator=RandomIdGenerator{}, "
+ "resource=Resource{schemaUrl=null, attributes={service.name=\"unknown_service:java\", telemetry.sdk.language=\"java\", telemetry.sdk.name=\"opentelemetry\", telemetry.sdk.version=\"1.10.0-SNAPSHOT\"}}, "
+ "resource=Resource{schemaUrl=null, attributes={service.name=\"otel-test\"}}, "
+ "spanLimitsSupplier=SpanLimitsValue{maxNumberOfAttributes=128, maxNumberOfEvents=128, maxNumberOfLinks=128, maxNumberOfAttributesPerEvent=128, maxNumberOfAttributesPerLink=128, maxAttributeValueLength=2147483647}, "
+ "sampler=ParentBased{root:AlwaysOnSampler,remoteParentSampled:AlwaysOnSampler,remoteParentNotSampled:AlwaysOffSampler,localParentSampled:AlwaysOnSampler,localParentNotSampled:AlwaysOffSampler}, "
+ "spanProcessor=SimpleSpanProcessor{spanExporter=MultiSpanExporter{spanExporters=[MockSpanExporter{}, MockSpanExporter{}]}}}}");
Expand Down

0 comments on commit 28f05d4

Please sign in to comment.