use of io.opentelemetry.api.common.Attributes in project opentelemetry-java by open-telemetry.
the class AdapterTest method getSpanData.
private static SpanData getSpanData(long startMs, long endMs, SpanKind kind, int totalRecordedEvents, int totalAttributeCount) {
Attributes attributes = Attributes.of(booleanKey("valueB"), true);
LinkData link = LinkData.create(createSpanContext(LINK_TRACE_ID, LINK_SPAN_ID), attributes);
return TestSpanData.builder().setHasEnded(true).setSpanContext(createSpanContext(TRACE_ID, SPAN_ID)).setParentSpanContext(SpanContext.create(TRACE_ID, PARENT_SPAN_ID, TraceFlags.getDefault(), TraceState.getDefault())).setName("GET /api/endpoint").setStartEpochNanos(MILLISECONDS.toNanos(startMs)).setEndEpochNanos(MILLISECONDS.toNanos(endMs)).setAttributes(Attributes.of(booleanKey("valueB"), true)).setTotalAttributeCount(totalAttributeCount).setEvents(Collections.singletonList(getTimedEvent())).setTotalRecordedEvents(totalRecordedEvents).setLinks(Collections.singletonList(link)).setTotalRecordedLinks(1).setKind(kind).setResource(Resource.create(Attributes.empty())).setStatus(StatusData.create(StatusCode.OK, "ok!")).build();
}
use of io.opentelemetry.api.common.Attributes in project opentelemetry-java by open-telemetry.
the class ResourceConfigurationTest method resource.
@Test
void resource() {
Attributes attributes = ResourceConfiguration.configureResource(DefaultConfigProperties.get(Collections.emptyMap()), ResourceConfigurationTest.class.getClassLoader(), (r, c) -> r).getAttributes();
assertThat(attributes.get(ResourceAttributes.OS_TYPE)).isNotNull();
assertThat(attributes.get(ResourceAttributes.OS_DESCRIPTION)).isNotNull();
assertThat(attributes.get(ResourceAttributes.PROCESS_PID)).isNotNull();
assertThat(attributes.get(ResourceAttributes.PROCESS_EXECUTABLE_PATH)).isNotNull();
assertThat(attributes.get(ResourceAttributes.PROCESS_COMMAND_LINE)).isNotNull();
assertThat(attributes.get(ResourceAttributes.PROCESS_RUNTIME_NAME)).isNotNull();
assertThat(attributes.get(ResourceAttributes.PROCESS_RUNTIME_VERSION)).isNotNull();
assertThat(attributes.get(ResourceAttributes.PROCESS_RUNTIME_DESCRIPTION)).isNotNull();
}
use of io.opentelemetry.api.common.Attributes in project opentelemetry-java by open-telemetry.
the class ResourceConfigurationTest method emptyClassLoader.
@Test
void emptyClassLoader() {
Attributes attributes = ResourceConfiguration.configureResource(DefaultConfigProperties.get(Collections.emptyMap()), new URLClassLoader(new URL[0], null), (r, c) -> r).getAttributes();
assertProcessAttributeIsNull(attributes);
}
use of io.opentelemetry.api.common.Attributes in project opentelemetry-java by open-telemetry.
the class ResourceConfigurationTest method onlySettingEnabledConfiguration.
@Test
void onlySettingEnabledConfiguration() {
Map<String, String> customConfigs = new HashMap<>(1);
customConfigs.put("otel.java.enabled.resource.providers", "io.opentelemetry.sdk.autoconfigure.ResourceProviderCustomizer");
Attributes attributes = ResourceConfiguration.configureResource(DefaultConfigProperties.get(customConfigs), ResourceConfigurationTest.class.getClassLoader(), (r, c) -> r).getAttributes();
assertProcessAttributeIsNull(attributes);
assertThat(attributes.get(AttributeKey.stringKey("animal"))).isEqualTo("cat");
}
use of io.opentelemetry.api.common.Attributes in project opentelemetry-java by open-telemetry.
the class EcsResourceTest method testContainerIdMissing.
@Test
void testContainerIdMissing() throws UnknownHostException {
when(mockDockerHelper.getContainerId()).thenReturn("");
Map<String, String> mockSysEnv = new HashMap<>();
mockSysEnv.put(ECS_METADATA_KEY_V4, "ecs_metadata_v4_uri");
Attributes attributes = EcsResource.buildResource(mockSysEnv, mockDockerHelper).getAttributes();
assertThat(attributes).containsOnly(entry(ResourceAttributes.CLOUD_PROVIDER, "aws"), entry(ResourceAttributes.CLOUD_PLATFORM, "aws_ecs"), entry(ResourceAttributes.CONTAINER_NAME, InetAddress.getLocalHost().getHostName()));
}
Aggregations