use of io.opentelemetry.exporter.internal.marshal.ProtoFieldInfo 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.marshal.ProtoFieldInfo in project opentelemetry-java by open-telemetry.
the class MetricMarshaler method create.
static Marshaler create(MetricData metric) {
// TODO(anuraaga): Cache these as they should be effectively singleton.
byte[] name = MarshalerUtil.toBytes(metric.getName());
byte[] description = MarshalerUtil.toBytes(metric.getDescription());
byte[] unit = MarshalerUtil.toBytes(metric.getUnit());
Marshaler dataMarshaler = null;
ProtoFieldInfo dataField = null;
switch(metric.getType()) {
case LONG_GAUGE:
dataMarshaler = GaugeMarshaler.create(metric.getLongGaugeData());
dataField = Metric.GAUGE;
break;
case DOUBLE_GAUGE:
dataMarshaler = GaugeMarshaler.create(metric.getDoubleGaugeData());
dataField = Metric.GAUGE;
break;
case LONG_SUM:
dataMarshaler = SumMarshaler.create(metric.getLongSumData());
dataField = Metric.SUM;
break;
case DOUBLE_SUM:
dataMarshaler = SumMarshaler.create(metric.getDoubleSumData());
dataField = Metric.SUM;
break;
case SUMMARY:
dataMarshaler = SummaryMarshaler.create(metric.getSummaryData());
dataField = Metric.SUMMARY;
break;
case HISTOGRAM:
dataMarshaler = HistogramMarshaler.create(metric.getHistogramData());
dataField = Metric.HISTOGRAM;
break;
case EXPONENTIAL_HISTOGRAM:
dataMarshaler = ExponentialHistogramMarshaler.create(ExponentialHistogramData.fromMetricData(metric));
dataField = Metric.EXPONENTIAL_HISTOGRAM;
}
if (dataMarshaler == null || dataField == null) {
// Someone not using BOM to align versions as we require. Just skip the metric.
return NoopMarshaler.INSTANCE;
}
return new MetricMarshaler(name, description, unit, dataMarshaler, dataField);
}
use of io.opentelemetry.exporter.internal.marshal.ProtoFieldInfo 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