Opentelemetry-java: AggregationTemporality is set incorrectly in the export pipeline

Created on 24 Nov 2020  路  1Comment  路  Source: open-telemetry/opentelemetry-java

Describe the bug
AggregationTemporality is set incorrectly in export pipeline

Steps to reproduce
Instantiate the OtlpGrpcMetricExporter using a custom AggregationConfiguration with non-default Temporality

    MeterSdkProvider meterProvider = OpenTelemetrySdk.getGlobalMeterProvider();

    InstrumentSelector instrumentSelector = InstrumentSelector.newBuilder()
        .instrumentType(InstrumentType.COUNTER)
        .build();
    AggregationConfiguration viewSpecification = AggregationConfiguration.create(
        Aggregations.sum(),
        Temporality.DELTA
    );
    meterProvider.registerView(instrumentSelector, viewSpecification);

    IntervalMetricReader intervalMetricReader = IntervalMetricReader.builder()
        .setMetricExporter(OtlpGrpcMetricExporter.getDefault())
        .setMetricProducers(Collections.singleton(meterProvider.getMetricProducer()))
        .setExportIntervalMillis(30000)
        .build();

What did you expect to see?
I expected to see the generated Metric proto with AGGREGATION_TEMPORALITY_DELTA

What did you see instead?
I saw the generated Metric proto with AGGREGATION_TEMPORALITY_CUMULATIVE

InstrumentationLibraryMetrics #0
Metric #0
Descriptor:
     -> Name: http_requests
     -> Description: 
     -> Unit: 1
     -> DataType: IntSum
     -> IsMonotonic: true
     -> AggregationTemporality: AGGREGATION_TEMPORALITY_CUMULATIVE

What version and what artifacts are you using?
Artifacts: opentelemetry-sdk opentelemetry-exporter-otlp
Version: v0.11.0
How did you reference these artifacts?

      <dependency>
        <groupId>io.opentelemetry</groupId>
        <artifactId>opentelemetry-bom</artifactId>
        <version>0.11.0</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    <dependency>
      <groupId>io.opentelemetry</groupId>
      <artifactId>opentelemetry-sdk</artifactId>
    </dependency>
    <dependency>
      <groupId>io.opentelemetry</groupId>
      <artifactId>opentelemetry-exporter-otlp</artifactId>
    </dependency>

Environment
Compiler: n/a
OS: Manjaro Linux

Additional context
This code in MetricAdapter hardcodes the AggregationTemporality based on the metric type

  private static AggregationTemporality mapToTemporality(MetricData.Type type) {
    switch (type) {
      case NON_MONOTONIC_LONG:
      case NON_MONOTONIC_DOUBLE:
      case MONOTONIC_LONG:
      case MONOTONIC_DOUBLE:
        return AGGREGATION_TEMPORALITY_CUMULATIVE;
      case SUMMARY:
        return AGGREGATION_TEMPORALITY_DELTA;
      default:
        return AGGREGATION_TEMPORALITY_UNSPECIFIED;
    }
  }

This should instead use the overridden temporality from the AggregationConfiguration. It would appear that a temporality field needs to be added in MetricData and set in Batchers.

Bug p2 required-for-ga

Most helpful comment

FYI, this issue is actually higher up than the exporter. The Aggregation implementations currently have the metadata mostly hard-coded, and they need to be updated to handle the new customizable aggregation configurations.

>All comments

FYI, this issue is actually higher up than the exporter. The Aggregation implementations currently have the metadata mostly hard-coded, and they need to be updated to handle the new customizable aggregation configurations.

Was this page helpful?
0 / 5 - 0 ratings