use of io.opentelemetry.internal.testing.slf4j.SuppressLogger in project opentelemetry-java by open-telemetry.
the class BeanstalkResourceTest method testBadConfigFile.
@Test
@SuppressLogger(BeanstalkResource.class)
void testBadConfigFile(@TempDir File tempFolder) throws IOException {
File file = new File(tempFolder, "beanstalk.config");
String content = "\"deployment_id\":4,\"version_label\":\"2\",\"" + "environment_name\":\"HttpSubscriber-env\"}";
Files.write(content.getBytes(Charsets.UTF_8), file);
Attributes attributes = BeanstalkResource.buildResource(file.getPath()).getAttributes();
assertThat(attributes).isEmpty();
}
use of io.opentelemetry.internal.testing.slf4j.SuppressLogger in project opentelemetry-java by open-telemetry.
the class Ec2ResourceTest method badJson.
@Test
@SuppressLogger(Ec2Resource.class)
void badJson() {
server.enqueue(HttpResponse.of(HttpStatus.NOT_FOUND));
server.enqueue(HttpResponse.of(MediaType.JSON_UTF_8, "I'm not JSON"));
Attributes attributes = Ec2Resource.buildResource("localhost:" + server.httpPort()).getAttributes();
assertThat(attributes).isEmpty();
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.internal.testing.slf4j.SuppressLogger in project opentelemetry-java by open-telemetry.
the class EksResourceTest method testEks.
@Test
@SuppressLogger(EksResource.class)
void testEks(@TempDir File tempFolder) throws IOException {
File mockK8sTokenFile = new File(tempFolder, "k8sToken");
String token = "token123";
Files.write(token.getBytes(Charsets.UTF_8), mockK8sTokenFile);
File mockK8sKeystoreFile = new File(tempFolder, "k8sCert");
String truststore = "truststore123";
Files.write(truststore.getBytes(Charsets.UTF_8), mockK8sKeystoreFile);
when(httpClient.fetchString(any(), Mockito.eq(K8S_SVC_URL + AUTH_CONFIGMAP_PATH), any(), any())).thenReturn("not empty");
when(httpClient.fetchString(any(), Mockito.eq(K8S_SVC_URL + CW_CONFIGMAP_PATH), any(), any())).thenReturn("{\"data\":{\"cluster.name\":\"my-cluster\"}}");
when(mockDockerHelper.getContainerId()).thenReturn("0123456789A");
Resource eksResource = EksResource.buildResource(httpClient, mockDockerHelper, mockK8sTokenFile.getPath(), mockK8sKeystoreFile.getPath());
Attributes attributes = eksResource.getAttributes();
assertThat(eksResource.getSchemaUrl()).isEqualTo(ResourceAttributes.SCHEMA_URL);
assertThat(attributes).containsOnly(entry(ResourceAttributes.CLOUD_PROVIDER, "aws"), entry(ResourceAttributes.CLOUD_PLATFORM, "aws_eks"), entry(ResourceAttributes.K8S_CLUSTER_NAME, "my-cluster"), entry(ResourceAttributes.CONTAINER_ID, "0123456789A"));
}
use of io.opentelemetry.internal.testing.slf4j.SuppressLogger in project opentelemetry-java by open-telemetry.
the class JaegerRemoteSamplerTest method unimplemented_error_server_response.
@Test
@SuppressLogger(OkHttpGrpcService.class)
void unimplemented_error_server_response() {
addGrpcError(12, null);
try (JaegerRemoteSampler sampler = JaegerRemoteSampler.builder().setEndpoint(server.httpUri().toString()).setServiceName(SERVICE_NAME).setPollingInterval(50, TimeUnit.MILLISECONDS).build()) {
assertThat(sampler.getDescription()).startsWith("JaegerRemoteSampler{ParentBased{root:TraceIdRatioBased{0.001000}");
await().untilAsserted(() -> {
LoggingEvent log = logs.assertContains("Server responded with UNIMPLEMENTED.");
assertThat(log.getLevel()).isEqualTo(Level.ERROR);
});
}
}
use of io.opentelemetry.internal.testing.slf4j.SuppressLogger in project opentelemetry-java by open-telemetry.
the class JaegerRemoteSamplerTest method unavailable_error_server_response.
@Test
@SuppressLogger(OkHttpGrpcService.class)
void unavailable_error_server_response() {
addGrpcError(14, "クマ🐻 resource exhausted");
try (JaegerRemoteSampler sampler = JaegerRemoteSampler.builder().setEndpoint(server.httpUri().toString()).setServiceName(SERVICE_NAME).setPollingInterval(50, TimeUnit.MILLISECONDS).build()) {
assertThat(sampler.getDescription()).startsWith("JaegerRemoteSampler{ParentBased{root:TraceIdRatioBased{0.001000}");
await().untilAsserted(() -> {
LoggingEvent log = logs.assertContains("Server is UNAVAILABLE");
assertThat(log.getLevel()).isEqualTo(Level.ERROR);
});
}
}
Aggregations