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());
}
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);
}
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());
}
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();
}
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");
}
Aggregations