use of zipkin2.Component in project zipkin by openzipkin.
the class ComponentHealth method ofComponent.
static ComponentHealth ofComponent(Component component) {
Throwable t = null;
try {
CheckResult check = component.check();
if (!check.ok())
t = check.error();
} catch (Throwable unexpected) {
Call.propagateIfFatal(unexpected);
t = unexpected;
}
if (t == null)
return new ComponentHealth(component.toString(), STATUS_UP, null);
String message = t.getMessage();
String error = t.getClass().getName() + (message != null ? ": " + message : "");
return new ComponentHealth(component.toString(), STATUS_DOWN, error);
}
use of zipkin2.Component in project zipkin by openzipkin.
the class ITEnsureSchema method worksWithOldSchema.
/**
* This tests we don't accidentally rely on new indexes such as autocomplete tags
*/
@Test
void worksWithOldSchema(TestInfo testInfo) throws Exception {
String testSuffix = testSuffix(testInfo);
Schema.applyCqlFile(storage.keyspace, session(), "/zipkin2-schema.cql");
Schema.applyCqlFile(storage.keyspace, session(), "/zipkin2-schema-indexes-original.cql");
// Ensure the storage component is functional before proceeding
CheckResult check = storage.check();
if (!check.ok()) {
throw new AssertionError("Could not connect to storage: " + check.error().getMessage(), check.error());
}
List<Span> trace = newTrace(testSuffix);
accept(trace);
assertGetTraceReturns(trace.get(0).traceId(), trace);
assertThat(storage.autocompleteTags().getValues("environment").execute()).isEmpty();
String serviceName = trace.get(0).localServiceName();
assertThat(storage.serviceAndSpanNames().getRemoteServiceNames(serviceName).execute()).isEmpty();
QueryRequest request = requestBuilder().serviceName(serviceName).remoteServiceName(appendSuffix(BACKEND.serviceName(), testSuffix)).build();
// Make sure there's an error if a query will return incorrectly vs returning invalid results
assertThatThrownBy(() -> storage.spanStore().getTraces(request)).isInstanceOf(IllegalArgumentException.class).hasMessage("remoteService=" + trace.get(1).remoteServiceName() + " unsupported due to missing table remote_service_by_service");
}
use of zipkin2.Component in project zipkin by openzipkin.
the class ComponentHealthTest method addsMessageToDetails.
@Test
public void addsMessageToDetails() {
ComponentHealth health = ComponentHealth.ofComponent(new Component() {
@Override
public CheckResult check() {
return CheckResult.failed(new IOException("socket disconnect"));
}
});
assertThat(health.error).isEqualTo("java.io.IOException: socket disconnect");
}
use of zipkin2.Component in project zipkin by openzipkin.
the class ComponentHealthTest method doesntAddNullMessageToDetails.
@Test
public void doesntAddNullMessageToDetails() {
ComponentHealth health = ComponentHealth.ofComponent(new Component() {
@Override
public CheckResult check() {
return CheckResult.failed(ClosedSessionException.get());
}
});
assertThat(health.error).isEqualTo("com.linecorp.armeria.common.ClosedSessionException");
}
use of zipkin2.Component in project java by wavefrontHQ.
the class ZipkinPortUnificationHandlerTest method testZipkinHandler.
@Test
public void testZipkinHandler() throws Exception {
ZipkinPortUnificationHandler handler = new ZipkinPortUnificationHandler("9411", new NoopHealthCheckManager(), mockTraceHandler, mockTraceSpanLogsHandler, null, () -> false, () -> false, null, new SpanSampler(new RateSampler(1.0D), () -> null), "ProxyLevelAppTag", null);
Endpoint localEndpoint1 = Endpoint.newBuilder().serviceName("frontend").ip("10.0.0.1").build();
zipkin2.Span spanServer1 = zipkin2.Span.newBuilder().traceId("2822889fe47043bd").id("2822889fe47043bd").kind(zipkin2.Span.Kind.SERVER).name("getservice").timestamp(startTime * 1000).duration(1234 * 1000).localEndpoint(localEndpoint1).putTag("http.method", "GET").putTag("http.url", "none+h1c://localhost:8881/").putTag("http.status_code", "200").build();
Endpoint localEndpoint2 = Endpoint.newBuilder().serviceName("backend").ip("10.0.0.1").build();
zipkin2.Span spanServer2 = zipkin2.Span.newBuilder().traceId("2822889fe47043bd").id("d6ab73f8a3930ae8").parentId("2822889fe47043bd").kind(zipkin2.Span.Kind.SERVER).name("getbackendservice").timestamp(startTime * 1000).duration(2234 * 1000).localEndpoint(localEndpoint2).putTag("http.method", "GET").putTag("http.url", "none+h2c://localhost:9000/api").putTag("http.status_code", "200").putTag("component", "jersey-server").putTag("application", "SpanLevelAppTag").addAnnotation(startTime * 1000, "start processing").build();
zipkin2.Span spanServer3 = zipkin2.Span.newBuilder().traceId("2822889fe47043bd").id("d6ab73f8a3930ae8").kind(zipkin2.Span.Kind.CLIENT).name("getbackendservice2").timestamp(startTime * 1000).duration(2234 * 1000).localEndpoint(localEndpoint2).putTag("http.method", "GET").putTag("http.url", "none+h2c://localhost:9000/api").putTag("http.status_code", "200").putTag("component", "jersey-server").putTag("application", "SpanLevelAppTag").putTag("emptry.tag", "").addAnnotation(startTime * 1000, "start processing").build();
List<zipkin2.Span> zipkinSpanList = ImmutableList.of(spanServer1, spanServer2, spanServer3);
// Validate all codecs i.e. JSON_V1, JSON_V2, THRIFT and PROTO3.
for (SpanBytesEncoder encoder : SpanBytesEncoder.values()) {
ByteBuf content = Unpooled.copiedBuffer(encoder.encodeList(zipkinSpanList));
// take care of mocks.
doMockLifecycle(mockTraceHandler, mockTraceSpanLogsHandler);
ChannelHandlerContext mockCtx = createNiceMock(ChannelHandlerContext.class);
doMockLifecycle(mockCtx);
FullHttpRequest httpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "http://localhost:9411/api/v1/spans", content, true);
handler.handleHttpMessage(mockCtx, httpRequest);
verify(mockTraceHandler, mockTraceSpanLogsHandler);
}
}
Aggregations