com.lightstep.opentelemetry.exporter..Adapter.swp Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lightstep-opentelemetry-auto-exporter Show documentation
Show all versions of lightstep-opentelemetry-auto-exporter Show documentation
Lightstep OpenTelemetry Auto Exporter
The newest version!
b0VIM 8.0 ??^?? T~ carlosalbertocortez Carloss-MacBook-Pro.local /development/opentelemetry-exporter-java/exporter/src/main/java/com/lightstep/opentelemetry/exporter/Adapter.java
3210 #"! U tp ` ????????k a T ? ad ? ` ? ? ? r L ! ? ? ? x ? ?
?
?
T
? ? ? ? v _ I - ? ? ? ? ? ? ? j 7 ?
?
?
?
?
?
?
5
0
? ? ? E ? ? ? ? A ; % ! ? ? ? M - ' ? ? g f - ? ? ? ? ? X W ? ? x ? ? ? B ? ? ? ? m = ? ? ? final long parentSpanId = spanIdToLong(spanData.getParentSpanId()); final Reference.Builder referenceBuilder = Reference.newBuilder(); if (spanData.getParentSpanId().isValid()) { // add the parent span builder.addAllReferences(toReferences(spanData.getLinks())); builder.addAllLogs(toLightstepLogs(spanData.getTimedEvents())); } builder.addAllTags(lsSpanAttributes); if (lsSpanAttributes != null && !lsSpanAttributes.isEmpty()) { builder.addAllTags(toKeyValues(spanData.getResource().getAttributes())); builder.addAllTags(toKeyValues(spanData.getAttributes())); builder.setDurationMicros(Durations.toMicros(Timestamps.between(startTimestamp, endTimestamp))); builder.setStartTimestamp(startTimestamp); final Timestamp endTimestamp = Timestamps.fromNanos(spanData.getEndEpochNanos()); final Timestamp startTimestamp = Timestamps.fromNanos(spanData.getStartEpochNanos()); builder.setSpanContext(spanContext); SpanContext.newBuilder().setTraceId(traceId).setSpanId(spanId).build(); final SpanContext spanContext = long spanId = spanIdToLong(spanData.getSpanId()); long traceId = traceIdToLong(spanData.getTraceId()); builder.setOperationName(spanData.getName()); final Span.Builder builder = Span.newBuilder(); static Span toLightstepSpan(SpanData spanData, Collection lsSpanAttributes) { */ * @return the Lightstep span * @param lsSpanAttributes the list of LS-specific Span attributes to add. * @param spanData the spanData to be converted * * Converts a single {@link SpanData} into a Lightstep's {@link Span}. /** } return converted; } converted.add(toLightstepSpan(span, lsSpanAttributes)); for (SpanData span : spans) { List converted = new ArrayList<>(); Collection lsSpanAttributes) { static List toLightstepSpans(Collection spans, */ * @see #toLightstepSpan(SpanData, Collection) * @return the collection of Lightstep spans * @param lsSpanAttributes the list of LS-specific Span attributes to add. * @param spans the list of spans to be converted * * Converts a list of {@link SpanData} into a collection of Lightstep's {@link Span}. /** } private Adapter() { static final String KEY_SPAN_STATUS_CODE = "span.status.code"; static final String KEY_SPAN_STATUS_MESSAGE = "span.status.message"; static final String KEY_SPAN_KIND = "span.kind"; static final String KEY_LOG_MESSAGE = "message"; final class Adapter { @ThreadSafe */ * Adapts OpenTelemetry objects to Lightstep objects. /** import javax.annotation.concurrent.ThreadSafe; import java.util.Map.Entry; import java.util.Map; import java.util.List; import java.util.Collection; import java.util.ArrayList; import java.nio.ByteBuffer; import io.opentelemetry.trace.TraceId; import io.opentelemetry.trace.SpanId; import io.opentelemetry.sdk.trace.data.SpanData.TimedEvent; import io.opentelemetry.sdk.trace.data.SpanData.Link; import io.opentelemetry.sdk.trace.data.SpanData; import io.opentelemetry.common.AttributeValue; import com.lightstep.tracer.grpc.SpanContext; import com.lightstep.tracer.grpc.Span; import com.lightstep.tracer.grpc.Reference.Relationship; import com.lightstep.tracer.grpc.Reference; import com.lightstep.tracer.grpc.Log; import com.lightstep.tracer.grpc.KeyValue; import com.google.protobuf.util.Timestamps; import com.google.protobuf.util.Durations; import com.google.protobuf.Timestamp; import com.google.protobuf.ByteString; import com.google.common.annotations.VisibleForTesting; package com.lightstep.opentelemetry.exporter; ad c ? T ? ? ? ? ? ? ? ; 6 ? ? ? ? m % $ ?
?
?
?
g
X
D
? ? ? ? ? ? ? } | v J E ( ? ? ? ? ? ? G
?
?
v
L
? i e d * ? ? ? ? ? ? j e J ' ! ? ? ? ? p ; 7 6 ? ? ? ? } } return ByteBuffer.wrap(bytes).getLong(); private static long fromByteArray(byte[] bytes) { } return fromByteArray(protoSpanId.toByteArray()); final ByteString protoSpanId = toByteString(spanId); } return 0L; if (spanId == null) { static long spanIdToLong(final SpanId spanId) { @VisibleForTesting */ * @return long value of span id * @param spanId span id * * Convert {@link SpanId} to long value. /** } return ByteString.copyFrom(spanIdBytes); spanId.copyBytesTo(spanIdBytes, 0); byte[] spanIdBytes = new byte[SpanId.getSize()]; private static ByteString toByteString(SpanId spanId) { } return ByteString.copyFrom(traceIdBytes, traceIdSize / 2, traceIdSize / 2); // 8 bytes. See https://github.com/openzipkin/b3-propagation#traceid-1 // Use the 64 least significant bits, represented by the right-most traceId.copyBytesTo(traceIdBytes, 0); byte[] traceIdBytes = new byte[traceIdSize]; int traceIdSize = TraceId.getSize(); private static ByteString toByteString(TraceId traceId) { } return fromByteArray(protoTraceId.toByteArray()); final ByteString protoTraceId = toByteString(traceId); } return 0L; if (traceId == null) { static long traceIdToLong(final TraceId traceId) { @VisibleForTesting */ * @return long value of trace id * @param traceId trace id * * Convert {@link TraceId} to long value. /** } return builder.build(); } break; builder.setDoubleValue(value.getDoubleValue()); case DOUBLE: break; builder.setBoolValue(value.getBooleanValue()); case BOOLEAN: break; builder.setIntValue(value.getLongValue()); case LONG: break; builder.setStringValue(value.getStringValue()); case STRING: switch (value.getType()) { final KeyValue.Builder builder = KeyValue.newBuilder().setKey(key); static KeyValue toKeyValue(String key, AttributeValue value) { @VisibleForTesting */ * @return a Lightstep key value * @param value the entry value * @param key the entry key as string * * Converts the given key and {@link AttributeValue} into Lightstep's {@link KeyValue}. /** } return keyValues; } keyValues.add(toKeyValue(entry.getKey(), entry.getValue()));