Search in sources :

Example 11 with Component

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);
}
Also used : CheckResult(zipkin2.CheckResult)

Example 12 with Component

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");
}
Also used : QueryRequest(zipkin2.storage.QueryRequest) CheckResult(zipkin2.CheckResult) Span(zipkin2.Span) Test(org.junit.jupiter.api.Test)

Example 13 with Component

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");
}
Also used : CheckResult(zipkin2.CheckResult) IOException(java.io.IOException) Component(zipkin2.Component) Test(org.junit.Test)

Example 14 with Component

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");
}
Also used : CheckResult(zipkin2.CheckResult) Component(zipkin2.Component) Test(org.junit.Test)

Example 15 with Component

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);
    }
}
Also used : DefaultFullHttpRequest(io.netty.handler.codec.http.DefaultFullHttpRequest) FullHttpRequest(io.netty.handler.codec.http.FullHttpRequest) DefaultFullHttpRequest(io.netty.handler.codec.http.DefaultFullHttpRequest) RateSampler(com.wavefront.sdk.entities.tracing.sampling.RateSampler) SpanBytesEncoder(zipkin2.codec.SpanBytesEncoder) SpanSampler(com.wavefront.agent.sampler.SpanSampler) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) ByteBuf(io.netty.buffer.ByteBuf) Span(wavefront.report.Span) Endpoint(zipkin2.Endpoint) NoopHealthCheckManager(com.wavefront.agent.channel.NoopHealthCheckManager) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)7 Point (java.awt.Point)5 Component (org.powerbot.script.rt6.Component)5 Span (zipkin2.Span)5 Condition (org.powerbot.script.Condition)4 Component (org.sbolstandard.core2.Component)4 ComponentDefinition (org.sbolstandard.core2.ComponentDefinition)4 CheckResult (zipkin2.CheckResult)4 SequenceAnnotation (org.sbolstandard.core2.SequenceAnnotation)3 Font (java.awt.Font)2 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Component (org.powerbot.script.rt4.Component)2 Item (org.powerbot.script.rt6.Item)2 FunctionalComponent (org.sbolstandard.core2.FunctionalComponent)2 SBOLDocument (org.sbolstandard.core2.SBOLDocument)2 Sequence (org.sbolstandard.core2.Sequence)2 Component (zipkin2.Component)2 TraceSpan (com.google.devtools.cloudtrace.v1.TraceSpan)1