use of io.opentelemetry.exporter.internal.otlp.KeyValueMarshaler in project opentelemetry-java by open-telemetry.
the class NumberDataPointMarshaler method create.
static NumberDataPointMarshaler create(PointData point) {
ExemplarMarshaler[] exemplarMarshalers = ExemplarMarshaler.createRepeated(point.getExemplars());
KeyValueMarshaler[] attributeMarshalers = KeyValueMarshaler.createRepeated(point.getAttributes());
ProtoFieldInfo valueField;
if (point instanceof LongPointData) {
valueField = NumberDataPoint.AS_INT;
} else {
assert point instanceof DoublePointData;
valueField = NumberDataPoint.AS_DOUBLE;
}
return new NumberDataPointMarshaler(point.getStartEpochNanos(), point.getEpochNanos(), point, valueField, exemplarMarshalers, attributeMarshalers);
}
use of io.opentelemetry.exporter.internal.otlp.KeyValueMarshaler in project opentelemetry-java by open-telemetry.
the class LogMarshaler method create.
// name field to be removed
@SuppressWarnings("deprecation")
static LogMarshaler create(io.opentelemetry.sdk.logs.data.LogData logData) {
KeyValueMarshaler[] attributeMarshalers = KeyValueMarshaler.createRepeated(logData.getAttributes());
// For now, map all the bodies to String AnyValue.
StringAnyValueMarshaler anyValueMarshaler = new StringAnyValueMarshaler(MarshalerUtil.toBytes(logData.getBody().asString()));
SpanContext spanContext = logData.getSpanContext();
return new LogMarshaler(logData.getEpochNanos(), toProtoSeverityNumber(logData.getSeverity()), MarshalerUtil.toBytes(logData.getSeverityText()), MarshalerUtil.toBytes(logData.getName()), anyValueMarshaler, attributeMarshalers, // TODO (trask) implement droppedAttributesCount in LogRecord
0, spanContext.getTraceFlags(), spanContext.getTraceId().equals(INVALID_TRACE_ID) ? null : spanContext.getTraceId(), spanContext.getSpanId().equals(INVALID_SPAN_ID) ? null : spanContext.getSpanId());
}
use of io.opentelemetry.exporter.internal.otlp.KeyValueMarshaler in project opentelemetry-java by open-telemetry.
the class SpanMarshaler method create.
// Because SpanMarshaler is always part of a repeated field, it cannot return "null".
static SpanMarshaler create(SpanData spanData) {
KeyValueMarshaler[] attributeMarshalers = KeyValueMarshaler.createRepeated(spanData.getAttributes());
SpanEventMarshaler[] spanEventMarshalers = SpanEventMarshaler.createRepeated(spanData.getEvents());
SpanLinkMarshaler[] spanLinkMarshalers = SpanLinkMarshaler.createRepeated(spanData.getLinks());
String parentSpanId = spanData.getParentSpanContext().isValid() ? spanData.getParentSpanContext().getSpanId() : null;
TraceState traceState = spanData.getSpanContext().getTraceState();
byte[] traceStateUtf8 = traceState.isEmpty() ? EMPTY_BYTES : encodeTraceState(traceState).getBytes(StandardCharsets.UTF_8);
return new SpanMarshaler(spanData.getSpanContext().getTraceId(), spanData.getSpanContext().getSpanId(), traceStateUtf8, parentSpanId, MarshalerUtil.toBytes(spanData.getName()), toProtoSpanKind(spanData.getKind()), spanData.getStartEpochNanos(), spanData.getEndEpochNanos(), attributeMarshalers, spanData.getTotalAttributeCount() - spanData.getAttributes().size(), spanEventMarshalers, spanData.getTotalRecordedEvents() - spanData.getEvents().size(), spanLinkMarshalers, spanData.getTotalRecordedLinks() - spanData.getLinks().size(), SpanStatusMarshaler.create(spanData.getStatus()));
}
use of io.opentelemetry.exporter.internal.otlp.KeyValueMarshaler in project opentelemetry-java by open-telemetry.
the class ExemplarMarshaler method create.
private static ExemplarMarshaler create(ExemplarData exemplar) {
KeyValueMarshaler[] attributeMarshalers = KeyValueMarshaler.createRepeated(exemplar.getFilteredAttributes());
ProtoFieldInfo valueField;
if (exemplar instanceof LongExemplarData) {
valueField = io.opentelemetry.proto.metrics.v1.internal.Exemplar.AS_INT;
} else {
assert exemplar instanceof DoubleExemplarData;
valueField = io.opentelemetry.proto.metrics.v1.internal.Exemplar.AS_DOUBLE;
}
return new ExemplarMarshaler(exemplar.getEpochNanos(), exemplar, valueField, exemplar.getSpanContext(), attributeMarshalers);
}
Aggregations