Search in sources :

Example 61 with SpanData

use of io.opencensus.trace.export.SpanData in project instrumentation-java by census-instrumentation.

the class StackdriverV2ExporterHandlerProtoTest method generateSpan_WithResourceLabels.

@Test
public void generateSpan_WithResourceLabels() {
    SpanData spanData = SpanData.create(spanContext, parentSpanId, /* hasRemoteParent= */
    true, SPAN_NAME, null, startTimestamp, attributes, annotations, messageEvents, links, CHILD_SPAN_COUNT, status, endTimestamp);
    Span span = handler.generateSpan(spanData, EXPECTED_RESOURCE_ATTRIBUTES, Collections.<String, AttributeValue>emptyMap());
    Map<String, AttributeValue> attributeMap = span.getAttributes().getAttributeMapMap();
    assertThat(attributeMap.entrySet()).containsAtLeastElementsIn(EXPECTED_RESOURCE_ATTRIBUTES.entrySet());
}
Also used : AttributeValue(com.google.devtools.cloudtrace.v2.AttributeValue) SpanData(io.opencensus.trace.export.SpanData) TruncatableString(com.google.devtools.cloudtrace.v2.TruncatableString) Span(com.google.devtools.cloudtrace.v2.Span) Test(org.junit.Test)

Example 62 with SpanData

use of io.opencensus.trace.export.SpanData in project instrumentation-java by census-instrumentation.

the class StackdriverV2ExporterHandlerProtoTest method generateSpanName_ForServerWithRecv.

@Test
public void generateSpanName_ForServerWithRecv() {
    SpanData spanData = SpanData.create(spanContext, parentSpanId, /* hasRemoteParent= */
    true, "Recv." + SPAN_NAME, Kind.SERVER, startTimestamp, attributes, annotations, messageEvents, links, CHILD_SPAN_COUNT, status, endTimestamp);
    assertThat(handler.generateSpan(spanData, EMPTY_RESOURCE_LABELS, Collections.<String, AttributeValue>emptyMap()).getDisplayName().getValue()).isEqualTo("Recv." + SPAN_NAME);
}
Also used : SpanData(io.opencensus.trace.export.SpanData) Test(org.junit.Test)

Example 63 with SpanData

use of io.opencensus.trace.export.SpanData in project instrumentation-java by census-instrumentation.

the class StackdriverV2ExporterHandlerProtoTest method addFixedAttributes.

@Test
public void addFixedAttributes() {
    final ImmutableMap<String, AttributeValue> fixedAttributes = ImmutableMap.of("string_attr_key", toStringAttributeValueProto("my-project"), "long_attr_key", AttributeValue.newBuilder().setIntValue(1234).build(), "bool_attr_key", AttributeValue.newBuilder().setBoolValue(true).build());
    SpanData spanData = SpanData.create(spanContext, parentSpanId, /* hasRemoteParent= */
    true, "Sent." + SPAN_NAME, Kind.CLIENT, startTimestamp, attributes, annotations, messageEvents, links, CHILD_SPAN_COUNT, status, endTimestamp);
    Span span = handler.generateSpan(spanData, EMPTY_RESOURCE_LABELS, fixedAttributes);
    Map<String, AttributeValue> attributeMap = span.getAttributes().getAttributeMapMap();
    assertThat(attributeMap.entrySet()).containsAtLeastElementsIn(fixedAttributes.entrySet());
}
Also used : AttributeValue(com.google.devtools.cloudtrace.v2.AttributeValue) SpanData(io.opencensus.trace.export.SpanData) TruncatableString(com.google.devtools.cloudtrace.v2.TruncatableString) Span(com.google.devtools.cloudtrace.v2.Span) Test(org.junit.Test)

Example 64 with SpanData

use of io.opencensus.trace.export.SpanData in project instrumentation-java by census-instrumentation.

the class ZipkinExporterHandler method timeLimitedExport.

@Override
public void timeLimitedExport(final Collection<SpanData> spanDataList) throws IOException {
    List<byte[]> encodedSpans = new ArrayList<byte[]>(spanDataList.size());
    for (SpanData spanData : spanDataList) {
        encodedSpans.add(encoder.encode(generateSpan(spanData, localEndpoint)));
    }
    sender.sendSpans(encodedSpans).execute();
}
Also used : SpanData(io.opencensus.trace.export.SpanData) ArrayList(java.util.ArrayList)

Example 65 with SpanData

use of io.opencensus.trace.export.SpanData in project instrumentation-java by census-instrumentation.

the class TracezZPageHandler method emitSpans.

/**
 * Emits the list of SampledRequets with a header.
 */
private static void emitSpans(PrintWriter out, Formatter formatter, Collection<SpanData> spans) {
    out.write("<pre>\n");
    formatter.format("%-23s %18s%n", "When", "Elapsed(s)");
    out.write("-------------------------------------------\n");
    for (SpanData span : spans) {
        tracer.getCurrentSpan().addAnnotation("Render span.", ImmutableMap.<String, AttributeValue>builder().put("SpanId", AttributeValue.stringAttributeValue(BaseEncoding.base16().lowerCase().encode(span.getContext().getSpanId().getBytes()))).build());
        emitSingleSpan(formatter, span);
    }
    out.write("</pre>\n");
}
Also used : SpanData(io.opencensus.trace.export.SpanData)

Aggregations

SpanData (io.opencensus.trace.export.SpanData)86 Test (org.junit.Test)74 RecordEventsSpanImpl (io.opencensus.implcore.trace.RecordEventsSpanImpl)18 Link (io.opencensus.trace.Link)17 AttributeValue (io.opencensus.trace.AttributeValue)13 Collectors (java.util.stream.Collectors)13 Scope (org.apache.ignite.spi.tracing.Scope)13 TracingConfigurationCoordinates (org.apache.ignite.spi.tracing.TracingConfigurationCoordinates)13 TracingConfigurationParameters (org.apache.ignite.spi.tracing.TracingConfigurationParameters)13 TracingSpi (org.apache.ignite.spi.tracing.TracingSpi)13 IgniteEx (org.apache.ignite.internal.IgniteEx)12 SAMPLING_RATE_ALWAYS (org.apache.ignite.spi.tracing.TracingConfigurationParameters.SAMPLING_RATE_ALWAYS)12 OpenCensusTracingSpi (org.apache.ignite.spi.tracing.opencensus.OpenCensusTracingSpi)12 SpanId (io.opencensus.trace.SpanId)11 Collections (java.util.Collections)9 SpanType (org.apache.ignite.internal.processors.tracing.SpanType)9 TX (org.apache.ignite.spi.tracing.Scope.TX)9 ArrayList (java.util.ArrayList)8 Arrays (java.util.Arrays)8 Set (java.util.Set)8