Skip to content

DataDog Exporter is exporting 0 values for histograms #5378

@emilgelman

Description

@emilgelman

Describe the bug
Using the latest configuration for histograms added in v0.36.0, it seems like the name.bucket metric is always 0 in DataDog.

Steps to reproduce

Full code example:

package main

import (
	"context"
	"time"

	"go.opentelemetry.io/otel"
	"go.opentelemetry.io/otel/exporters/otlp/otlpmetric"
	"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp"
	"go.opentelemetry.io/otel/metric"
	"go.opentelemetry.io/otel/metric/global"
	controller "go.opentelemetry.io/otel/sdk/metric/controller/basic"
	processor "go.opentelemetry.io/otel/sdk/metric/processor/basic"
	"go.opentelemetry.io/otel/sdk/metric/selector/simple"
)

func main() {
	ctx := context.Background()
	client := otlpmetrichttp.NewClient(otlpmetrichttp.WithInsecure(), otlpmetrichttp.WithEndpoint("0.0.0.0:55681"))
	exp, err := otlpmetric.New(ctx, client)
	if err != nil {
		panic("Failed to create the collector exporter")
	}
	defer func() {
		ctx, cancel := context.WithTimeout(ctx, time.Second)
		defer cancel()
		if err := exp.Shutdown(ctx); err != nil {
			otel.Handle(err)
		}
	}()

	pusher := controller.New(
		processor.New(
			simple.NewWithHistogramDistribution(),
			exp,
		),
		controller.WithExporter(exp),
		controller.WithCollectPeriod(time.Millisecond*100),
	)
	global.SetMeterProvider(pusher.MeterProvider())

	if err := pusher.Start(ctx); err != nil {
		panic("could not start metric controoler: %v")
	}
	defer func() {
		ctx, cancel := context.WithTimeout(ctx, time.Second)
		defer cancel()
		// pushes any last exports to the receiver
		if err := pusher.Stop(ctx); err != nil {
			otel.Handle(err)
		}
	}()

	meter := global.Meter("test-meter")

	// Recorder metric example
	recorder := metric.Must(meter).NewInt64Histogram("test.histogram.histogram.distribution.new")
	recorder.Record(ctx, 1000)
	time.Sleep(time.Second * 1)
	recorder.Record(ctx, -20000)
	time.Sleep(time.Second * 1)
	recorder.Record(ctx, 5000)
	time.Sleep(time.Second * 1)

}

What did you expect to see?
I would expect the output in DataDog to match the values I'm seeing in stdout / prometheus exporters.
Output from stdout exporter:

InstrumentationLibraryMetrics #0
InstrumentationLibrary  
Metric #0
Descriptor:
     -> Name: test.histogram.histogram.distribution.new
     -> Description: 
     -> Unit: 
     -> DataType: Histogram
     -> AggregationTemporality: AGGREGATION_TEMPORALITY_CUMULATIVE
HistogramDataPoints #0
Data point attributes:
     -> HOST_NAME: STRING(emil-gelman)
StartTimestamp: 2021-09-22 08:36:17.710314 +0000 UTC
Timestamp: 2021-09-22 08:36:19.812914 +0000 UTC
Count: 3
Sum: -14000.000000
ExplicitBounds #0: 5000.000000
ExplicitBounds #1: 10000.000000
ExplicitBounds #2: 25000.000000
ExplicitBounds #3: 50000.000000
ExplicitBounds #4: 100000.000000
ExplicitBounds #5: 250000.000000
ExplicitBounds #6: 500000.000000
ExplicitBounds #7: 1000000.000000
ExplicitBounds #8: 2500000.000000
ExplicitBounds #9: 5000000.000000
ExplicitBounds #10: 10000000.000000
Buckets #0, Count: 2
Buckets #1, Count: 1
Buckets #2, Count: 0
Buckets #3, Count: 0
Buckets #4, Count: 0
Buckets #5, Count: 0
Buckets #6, Count: 0
Buckets #7, Count: 0
Buckets #8, Count: 0
Buckets #9, Count: 0
Buckets #10, Count: 0
Buckets #11, Count: 0

What did you see instead?
Below is the response of the DataDog query API for the reported metric:

{
    "status": "ok",
    "resp_version": 1,
    "series": [
        {
            "end": 1632299999000,
            "attributes": {},
            "metric": "test.histogram.histogram.distribution.new.bucket",
            "interval": 300,
            "tag_set": [
                "lower_bound:-inf",
                "lower_bound:10000.0",
                "lower_bound:100000.0",
                "lower_bound:1e_07.0"
            ],
            "start": 1632294600000,
            "length": 4,
            "query_index": 0,
            "aggr": "avg",
            "scope": "lower_bound:-inf,lower_bound:10000.0,lower_bound:100000.0,lower_bound:1e_07.0",
            "pointlist": [
                [
                    1632294600000.0,
                    0.0
                ],
                [
                    1632294900000.0,
                    0.0
                ],
                [
                    1632295200000.0,
                    0.0
                ],
                [
                    1632299700000.0,
                    0.0
                ]
            ],
            "expression": "avg:test.histogram.histogram.distribution.new.bucket{lower_bound:-inf,lower_bound:10000.0,lower_bound:100000.0,lower_bound:1e_07.0}",
            "unit": null,
            "display_name": "test.histogram.histogram.distribution.new.bucket"
        }
    ],
    "to_date": 1632300222000,
    "query": "avg:test.histogram.histogram.distribution.new.bucket{*} by {lower_bound}",
    "message": "",
    "res_type": "time_series",
    "times": [],
    "from_date": 1632250222000,
    "group_by": [
        "lower_bound"
    ],
    "values": []
}

What version did you use?
Version: v0.36.0

What config did you use?
otel-collector datadog exporter configuration:

exporters:
  datadog:
    use_resource_metadata: false
    env: "local"
    send_metadata: false
    api:
      key: ${DD_API_KEY}
      site: datadoghq.eu
    metrics:
      send_monotonic_counter: false
      histograms:
        mode: counters

Environment
OS: iOS
Compiler(if manually compiled): go 1.16

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdata:metricsMetric related issuesexporter/datadogDatadog components

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions