use of io.opentelemetry.sdk.resources.Resource in project inspectit-ocelot by inspectIT.
the class OpenTelemetryProtoConverter method toSpanData.
/**
* @return Converts an {@link InstrumentationLibrarySpans} instance to a stream of individual {@link SpanData} instances.
*/
private Stream<SpanData> toSpanData(InstrumentationLibrarySpans librarySpans, Resource resource, Map<String, String> customSpanAttributes) {
InstrumentationLibrary library = librarySpans.getInstrumentationLibrary();
InstrumentationLibraryInfo libraryInfo = InstrumentationLibraryInfo.create(library.getName(), library.getVersion());
return librarySpans.getSpansList().stream().map(protoSpan -> OcelotSpanUtils.createSpanData(protoSpan, resource, libraryInfo, customSpanAttributes)).filter(Objects::nonNull);
}
use of io.opentelemetry.sdk.resources.Resource in project opentelemetry-java by open-telemetry.
the class EcsResourceTest method testCreateAttributes.
@Test
void testCreateAttributes() throws UnknownHostException {
when(mockDockerHelper.getContainerId()).thenReturn("0123456789A");
Map<String, String> mockSysEnv = new HashMap<>();
mockSysEnv.put(ECS_METADATA_KEY_V3, "ecs_metadata_v3_uri");
Resource resource = EcsResource.buildResource(mockSysEnv, mockDockerHelper);
Attributes attributes = resource.getAttributes();
assertThat(resource.getSchemaUrl()).isEqualTo(ResourceAttributes.SCHEMA_URL);
assertThat(attributes).containsOnly(entry(ResourceAttributes.CLOUD_PROVIDER, "aws"), entry(ResourceAttributes.CLOUD_PLATFORM, "aws_ecs"), entry(ResourceAttributes.CONTAINER_NAME, InetAddress.getLocalHost().getHostName()), entry(ResourceAttributes.CONTAINER_ID, "0123456789A"));
}
use of io.opentelemetry.sdk.resources.Resource in project opentelemetry-java by open-telemetry.
the class LambdaResourceTest method shouldAddNonEmptyAttributes.
@Test
void shouldAddNonEmptyAttributes() {
Resource resource = LambdaResource.buildResource(singletonMap("AWS_LAMBDA_FUNCTION_NAME", "my-function"));
Attributes attributes = resource.getAttributes();
assertThat(resource.getSchemaUrl()).isEqualTo(ResourceAttributes.SCHEMA_URL);
assertThat(attributes).containsOnly(entry(ResourceAttributes.CLOUD_PROVIDER, "aws"), entry(ResourceAttributes.CLOUD_PLATFORM, "aws_lambda"), entry(ResourceAttributes.FAAS_NAME, "my-function"));
}
use of io.opentelemetry.sdk.resources.Resource in project opentelemetry-java by open-telemetry.
the class Ec2ResourceTest method imdsv1.
@Test
void imdsv1() {
server.enqueue(HttpResponse.of(HttpStatus.NOT_FOUND));
server.enqueue(HttpResponse.of(MediaType.JSON_UTF_8, IDENTITY_DOCUMENT));
server.enqueue(HttpResponse.of("ec2-1-2-3-4"));
Resource resource = Ec2Resource.buildResource("localhost:" + server.httpPort());
assertThat(resource.getSchemaUrl()).isEqualTo(ResourceAttributes.SCHEMA_URL);
Attributes attributes = resource.getAttributes();
assertThat(attributes).containsOnly(entry(ResourceAttributes.CLOUD_PROVIDER, "aws"), entry(ResourceAttributes.CLOUD_PLATFORM, "aws_ec2"), entry(ResourceAttributes.HOST_ID, "i-1234567890abcdef0"), entry(ResourceAttributes.CLOUD_AVAILABILITY_ZONE, "us-west-2b"), entry(ResourceAttributes.HOST_TYPE, "t2.micro"), entry(ResourceAttributes.HOST_IMAGE_ID, "ami-5fb8c835"), entry(ResourceAttributes.CLOUD_ACCOUNT_ID, "123456789012"), entry(ResourceAttributes.CLOUD_REGION, "us-west-2"), entry(ResourceAttributes.HOST_NAME, "ec2-1-2-3-4"));
AggregatedHttpRequest request1 = server.takeRequest().request();
assertThat(request1.path()).isEqualTo("/latest/api/token");
assertThat(request1.headers().get("X-aws-ec2-metadata-token-ttl-seconds")).isEqualTo("60");
AggregatedHttpRequest request2 = server.takeRequest().request();
assertThat(request2.path()).isEqualTo("/latest/dynamic/instance-identity/document");
assertThat(request2.headers().get("X-aws-ec2-metadata-token")).isNull();
}
use of io.opentelemetry.sdk.resources.Resource in project opentelemetry-java by open-telemetry.
the class BeanstalkResourceTest method testCreateAttributes.
@Test
void testCreateAttributes(@TempDir File tempFolder) throws IOException {
File file = new File(tempFolder, "beanstalk.config");
String content = "{\"noise\": \"noise\", \"deployment_id\":4,\"" + "version_label\":\"2\",\"environment_name\":\"HttpSubscriber-env\"}";
Files.write(content.getBytes(Charsets.UTF_8), file);
Resource resource = BeanstalkResource.buildResource(file.getPath());
Attributes attributes = resource.getAttributes();
assertThat(attributes).containsOnly(entry(ResourceAttributes.CLOUD_PROVIDER, "aws"), entry(ResourceAttributes.CLOUD_PLATFORM, "aws_elastic_beanstalk"), entry(ResourceAttributes.SERVICE_INSTANCE_ID, "4"), entry(ResourceAttributes.SERVICE_VERSION, "2"), entry(ResourceAttributes.SERVICE_NAMESPACE, "HttpSubscriber-env"));
assertThat(resource.getSchemaUrl()).isEqualTo(ResourceAttributes.SCHEMA_URL);
}
Aggregations