Search in sources :

Example 1 with ProtoFieldInfo

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);
}
Also used : LongPointData(io.opentelemetry.sdk.metrics.data.LongPointData) KeyValueMarshaler(io.opentelemetry.exporter.internal.otlp.KeyValueMarshaler) ProtoFieldInfo(io.opentelemetry.exporter.internal.marshal.ProtoFieldInfo) DoublePointData(io.opentelemetry.sdk.metrics.data.DoublePointData)

Example 2 with ProtoFieldInfo

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);
}
Also used : Marshaler(io.opentelemetry.exporter.internal.marshal.Marshaler) ProtoFieldInfo(io.opentelemetry.exporter.internal.marshal.ProtoFieldInfo)

Example 3 with ProtoFieldInfo

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);
}
Also used : DoubleExemplarData(io.opentelemetry.sdk.metrics.data.DoubleExemplarData) LongExemplarData(io.opentelemetry.sdk.metrics.data.LongExemplarData) KeyValueMarshaler(io.opentelemetry.exporter.internal.otlp.KeyValueMarshaler) ProtoFieldInfo(io.opentelemetry.exporter.internal.marshal.ProtoFieldInfo)

Aggregations

ProtoFieldInfo (io.opentelemetry.exporter.internal.marshal.ProtoFieldInfo)3 KeyValueMarshaler (io.opentelemetry.exporter.internal.otlp.KeyValueMarshaler)2 Marshaler (io.opentelemetry.exporter.internal.marshal.Marshaler)1 DoubleExemplarData (io.opentelemetry.sdk.metrics.data.DoubleExemplarData)1 DoublePointData (io.opentelemetry.sdk.metrics.data.DoublePointData)1 LongExemplarData (io.opentelemetry.sdk.metrics.data.LongExemplarData)1 LongPointData (io.opentelemetry.sdk.metrics.data.LongPointData)1