Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .chloggen/mx-psi_interval-passing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: datadogexporter

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add alpha feature gate 'exporter.datadogexporter.InferIntervalForDeltaMetrics'.

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [42494]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext: |
This feature gate will set the interval for OTLP delta metrics mapped by the exporter when it can infer them.

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
6 changes: 6 additions & 0 deletions exporter/datadogexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ var metricExportSerializerClientFeatureGate = featuregate.GlobalRegistry().MustR
featuregate.WithRegisterDescription("When enabled, metric export in datadogexporter uses the serializer exporter from the Datadog Agent."),
)

var inferIntervalDeltaFeatureGate = featuregate.GlobalRegistry().MustRegister(
"exporter.datadogexporter.InferIntervalForDeltaMetrics",
featuregate.StageAlpha,
featuregate.WithRegisterDescription("When enabled, the exporter will infer the metrics interval for OTLP delta sums using a heuristic."),
)

func init() {
log.SetupLogger(log.Disabled(), "off")
}
Expand Down
4 changes: 2 additions & 2 deletions exporter/datadogexporter/internal/metrics/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ func (c *Consumer) ConsumeTimeSeries(
dims *metrics.Dimensions,
typ metrics.DataType,
timestamp uint64,
_ int64,
interval int64,
value float64,
) {
dt := c.toDataType(typ)
met := NewMetric(dims.Name(), dt, timestamp, value, dims.Tags())
met := NewMetric(dims.Name(), dt, timestamp, interval, value, dims.Tags())
met.SetResources([]datadogV2.MetricResource{
{
Name: datadog.PtrString(dims.Host()),
Expand Down
15 changes: 8 additions & 7 deletions exporter/datadogexporter/internal/metrics/series.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,29 @@ func newMetricSeries(name string, ts uint64, value float64, tags []string) datad

// NewMetric creates a new DatadogV2 metric given a name, a type, a Unix nanoseconds timestamp
// a value and a slice of tags
func NewMetric(name string, dt datadogV2.MetricIntakeType, ts uint64, value float64, tags []string) datadogV2.MetricSeries {
func NewMetric(name string, dt datadogV2.MetricIntakeType, ts uint64, interval int64, value float64, tags []string) datadogV2.MetricSeries {
metric := newMetricSeries(name, ts, value, tags)
metric.SetType(dt)
metric.SetInterval(interval)
return metric
}

// NewGauge creates a new DatadogV2 Gauge metric given a name, a Unix nanoseconds timestamp
// a value and a slice of tags
func NewGauge(name string, ts uint64, value float64, tags []string) datadogV2.MetricSeries {
return NewMetric(name, datadogV2.METRICINTAKETYPE_GAUGE, ts, value, tags)
func NewGauge(name string, ts uint64, interval int64, value float64, tags []string) datadogV2.MetricSeries {
return NewMetric(name, datadogV2.METRICINTAKETYPE_GAUGE, ts, interval, value, tags)
}

// NewCount creates a new DatadogV2 count metric given a name, a Unix nanoseconds timestamp
// a value and a slice of tags
func NewCount(name string, ts uint64, value float64, tags []string) datadogV2.MetricSeries {
return NewMetric(name, datadogV2.METRICINTAKETYPE_COUNT, ts, value, tags)
func NewCount(name string, ts uint64, interval int64, value float64, tags []string) datadogV2.MetricSeries {
return NewMetric(name, datadogV2.METRICINTAKETYPE_COUNT, ts, interval, value, tags)
}

// DefaultMetrics creates built-in metrics to report that an exporter is running
func DefaultMetrics(exporterType, hostname string, timestamp uint64, tags []string) []datadogV2.MetricSeries {
metrics := []datadogV2.MetricSeries{
NewGauge(fmt.Sprintf("otel.datadog_exporter.%s.running", exporterType), timestamp, 1.0, tags),
NewGauge(fmt.Sprintf("otel.datadog_exporter.%s.running", exporterType), timestamp, 0, 1.0, tags),
}
for i := range metrics {
metrics[i].SetResources([]datadogV2.MetricResource{
Expand All @@ -70,7 +71,7 @@ func DefaultMetrics(exporterType, hostname string, timestamp uint64, tags []stri

// GatewayUsageGauge creates a gauge metric to report if there is a gateway
func GatewayUsageGauge(timestamp uint64, hostname string, tags []string, gatewayUsage *attributes.GatewayUsage) datadogV2.MetricSeries {
series := NewGauge("datadog.otel.gateway", timestamp, gatewayUsage.Gauge(), tags)
series := NewGauge("datadog.otel.gateway", timestamp, 0, gatewayUsage.Gauge(), tags)
series.SetResources([]datadogV2.MetricResource{
{
Name: datadog.PtrString(hostname),
Expand Down
4 changes: 2 additions & 2 deletions exporter/datadogexporter/internal/metrics/series_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ func TestNewType(t *testing.T) {
value := 2.0
tags := []string{"tag:value"}

gauge := NewGauge(name, ts, value, tags)
gauge := NewGauge(name, ts, 10, value, tags)
assert.Equal(t, datadogV2.METRICINTAKETYPE_GAUGE, gauge.GetType())

count := NewCount(name, ts, value, tags)
count := NewCount(name, ts, 10, value, tags)
assert.Equal(t, datadogV2.METRICINTAKETYPE_COUNT, count.GetType())
}

Expand Down
5 changes: 5 additions & 0 deletions exporter/datadogexporter/metrics_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ func newMetricsExporter(
options = append(options, otlpmetrics.WithRemapping())
}

if inferIntervalDeltaFeatureGate.IsEnabled() {
params.Logger.Info("Metrics interval will be inferred for OTLP delta metrics with a set StartTimestamp.")
options = append(options, otlpmetrics.WithInferDeltaInterval())
}

tr, err := otlpmetrics.NewTranslator(params.TelemetrySettings, attrsTranslator, options...)
if err != nil {
return nil, err
Expand Down
26 changes: 26 additions & 0 deletions exporter/datadogexporter/metrics_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,48 +191,55 @@ func Test_metricsExporter_PushMetricsData(t *testing.T) {
"metric": "int.gauge",
"points": []any{map[string]any{"timestamp": float64(0), "value": float64(222)}},
"type": float64(datadogV2.METRICINTAKETYPE_GAUGE),
"interval": float64(0),
"resources": []any{map[string]any{"name": "test-host", "type": "host"}},
"tags": []any{"env:dev"},
},
map[string]any{
"metric": "otel.system.filesystem.utilization",
"points": []any{map[string]any{"timestamp": float64(0), "value": float64(333)}},
"type": float64(datadogV2.METRICINTAKETYPE_GAUGE),
"interval": float64(0),
"resources": []any{map[string]any{"name": "test-host", "type": "host"}},
"tags": []any{"env:dev"},
},
map[string]any{
"metric": "double.histogram.bucket",
"points": []any{map[string]any{"timestamp": float64(0), "value": float64(2)}},
"type": float64(datadogV2.METRICINTAKETYPE_COUNT),
"interval": float64(0),
"resources": []any{map[string]any{"name": "test-host", "type": "host"}},
"tags": []any{"lower_bound:-inf", "upper_bound:0", "env:dev"},
},
map[string]any{
"metric": "double.histogram.bucket",
"points": []any{map[string]any{"timestamp": float64(0), "value": float64(18)}},
"type": float64(datadogV2.METRICINTAKETYPE_COUNT),
"interval": float64(0),
"resources": []any{map[string]any{"name": "test-host", "type": "host"}},
"tags": []any{"lower_bound:0", "upper_bound:inf", "env:dev"},
},
map[string]any{
"metric": "system.disk.in_use",
"points": []any{map[string]any{"timestamp": float64(0), "value": float64(333)}},
"type": float64(datadogV2.METRICINTAKETYPE_GAUGE),
"interval": float64(0),
"resources": []any{map[string]any{"name": "test-host", "type": "host"}},
"tags": []any{"env:dev"},
},
map[string]any{
"metric": "datadog.otel.gateway",
"points": []any{map[string]any{"timestamp": float64(0), "value": float64(0)}},
"type": float64(datadogV2.METRICINTAKETYPE_GAUGE),
"interval": float64(0),
"resources": []any{map[string]any{"name": "test-host", "type": "host"}},
"tags": []any{"version:latest", "command:otelcol"},
},
map[string]any{
"metric": "otel.datadog_exporter.metrics.running",
"points": []any{map[string]any{"timestamp": float64(0), "value": float64(1)}},
"type": float64(datadogV2.METRICINTAKETYPE_GAUGE),
"interval": float64(0),
"resources": []any{map[string]any{"name": "test-host", "type": "host"}},
"tags": []any{"version:latest", "command:otelcol"},
},
Expand All @@ -256,48 +263,55 @@ func Test_metricsExporter_PushMetricsData(t *testing.T) {
"metric": "int.gauge",
"points": []any{map[string]any{"timestamp": float64(0), "value": float64(222)}},
"type": float64(datadogV2.METRICINTAKETYPE_GAUGE),
"interval": float64(0),
"resources": []any{map[string]any{"name": "test-host", "type": "host"}},
"tags": []any{"env:new_env"},
},
map[string]any{
"metric": "otel.system.filesystem.utilization",
"points": []any{map[string]any{"timestamp": float64(0), "value": float64(333)}},
"type": float64(datadogV2.METRICINTAKETYPE_GAUGE),
"interval": float64(0),
"resources": []any{map[string]any{"name": "test-host", "type": "host"}},
"tags": []any{"env:new_env"},
},
map[string]any{
"metric": "double.histogram.bucket",
"points": []any{map[string]any{"timestamp": float64(0), "value": float64(2)}},
"type": float64(datadogV2.METRICINTAKETYPE_COUNT),
"interval": float64(0),
"resources": []any{map[string]any{"name": "test-host", "type": "host"}},
"tags": []any{"lower_bound:-inf", "upper_bound:0", "env:new_env"},
},
map[string]any{
"metric": "double.histogram.bucket",
"points": []any{map[string]any{"timestamp": float64(0), "value": float64(18)}},
"type": float64(datadogV2.METRICINTAKETYPE_COUNT),
"interval": float64(0),
"resources": []any{map[string]any{"name": "test-host", "type": "host"}},
"tags": []any{"lower_bound:0", "upper_bound:inf", "env:new_env"},
},
map[string]any{
"metric": "system.disk.in_use",
"points": []any{map[string]any{"timestamp": float64(0), "value": float64(333)}},
"type": float64(datadogV2.METRICINTAKETYPE_GAUGE),
"interval": float64(0),
"resources": []any{map[string]any{"name": "test-host", "type": "host"}},
"tags": []any{"env:new_env"},
},
map[string]any{
"metric": "datadog.otel.gateway",
"points": []any{map[string]any{"timestamp": float64(0), "value": float64(0)}},
"type": float64(datadogV2.METRICINTAKETYPE_GAUGE),
"interval": float64(0),
"resources": []any{map[string]any{"name": "test-host", "type": "host"}},
"tags": []any{"version:latest", "command:otelcol"},
},
map[string]any{
"metric": "otel.datadog_exporter.metrics.running",
"points": []any{map[string]any{"timestamp": float64(0), "value": float64(1)}},
"type": float64(datadogV2.METRICINTAKETYPE_GAUGE),
"interval": float64(0),
"resources": []any{map[string]any{"name": "test-host", "type": "host"}},
"tags": []any{"version:latest", "command:otelcol"},
},
Expand All @@ -318,34 +332,39 @@ func Test_metricsExporter_PushMetricsData(t *testing.T) {
"metric": "int.gauge",
"points": []any{map[string]any{"timestamp": float64(0), "value": float64(222)}},
"type": float64(datadogV2.METRICINTAKETYPE_GAUGE),
"interval": float64(0),
"resources": []any{map[string]any{"name": "test-host", "type": "host"}},
"tags": []any{"env:dev"},
},
map[string]any{
"metric": "otel.system.filesystem.utilization",
"points": []any{map[string]any{"timestamp": float64(0), "value": float64(333)}},
"type": float64(datadogV2.METRICINTAKETYPE_GAUGE),
"interval": float64(0),
"resources": []any{map[string]any{"name": "test-host", "type": "host"}},
"tags": []any{"env:dev"},
},
map[string]any{
"metric": "system.disk.in_use",
"points": []any{map[string]any{"timestamp": float64(0), "value": float64(333)}},
"type": float64(datadogV2.METRICINTAKETYPE_GAUGE),
"interval": float64(0),
"resources": []any{map[string]any{"name": "test-host", "type": "host"}},
"tags": []any{"env:dev"},
},
map[string]any{
"metric": "datadog.otel.gateway",
"points": []any{map[string]any{"timestamp": float64(0), "value": float64(0)}},
"type": float64(datadogV2.METRICINTAKETYPE_GAUGE),
"interval": float64(0),
"resources": []any{map[string]any{"name": "test-host", "type": "host"}},
"tags": []any{"version:latest", "command:otelcol"},
},
map[string]any{
"metric": "otel.datadog_exporter.metrics.running",
"points": []any{map[string]any{"timestamp": float64(0), "value": float64(1)}},
"type": float64(datadogV2.METRICINTAKETYPE_GAUGE),
"interval": float64(0),
"resources": []any{map[string]any{"name": "test-host", "type": "host"}},
"tags": []any{"version:latest", "command:otelcol"},
},
Expand Down Expand Up @@ -384,48 +403,55 @@ func Test_metricsExporter_PushMetricsData(t *testing.T) {
"metric": "int.gauge",
"points": []any{map[string]any{"timestamp": float64(0), "value": float64(222)}},
"type": float64(datadogV2.METRICINTAKETYPE_GAUGE),
"interval": float64(0),
"resources": []any{map[string]any{"name": "test-host", "type": "host"}},
"tags": []any{"env:dev", "key1:value1", "key2:value2"},
},
map[string]any{
"metric": "otel.system.filesystem.utilization",
"points": []any{map[string]any{"timestamp": float64(0), "value": float64(333)}},
"type": float64(datadogV2.METRICINTAKETYPE_GAUGE),
"interval": float64(0),
"resources": []any{map[string]any{"name": "test-host", "type": "host"}},
"tags": []any{"env:dev", "key1:value1", "key2:value2"},
},
map[string]any{
"metric": "double.histogram.bucket",
"points": []any{map[string]any{"timestamp": float64(0), "value": float64(2)}},
"type": float64(datadogV2.METRICINTAKETYPE_COUNT),
"interval": float64(0),
"resources": []any{map[string]any{"name": "test-host", "type": "host"}},
"tags": []any{"lower_bound:-inf", "upper_bound:0", "env:dev", "key1:value1", "key2:value2"},
},
map[string]any{
"metric": "double.histogram.bucket",
"points": []any{map[string]any{"timestamp": float64(0), "value": float64(18)}},
"type": float64(datadogV2.METRICINTAKETYPE_COUNT),
"interval": float64(0),
"resources": []any{map[string]any{"name": "test-host", "type": "host"}},
"tags": []any{"lower_bound:0", "upper_bound:inf", "env:dev", "key1:value1", "key2:value2"},
},
map[string]any{
"metric": "system.disk.in_use",
"points": []any{map[string]any{"timestamp": float64(0), "value": float64(333)}},
"type": float64(datadogV2.METRICINTAKETYPE_GAUGE),
"interval": float64(0),
"resources": []any{map[string]any{"name": "test-host", "type": "host"}},
"tags": []any{"env:dev", "key1:value1", "key2:value2"},
},
map[string]any{
"metric": "datadog.otel.gateway",
"points": []any{map[string]any{"timestamp": float64(0), "value": float64(0)}},
"type": float64(datadogV2.METRICINTAKETYPE_GAUGE),
"interval": float64(0),
"resources": []any{map[string]any{"name": "test-host", "type": "host"}},
"tags": []any{"version:latest", "command:otelcol", "key1:value1", "key2:value2"},
},
map[string]any{
"metric": "otel.datadog_exporter.metrics.running",
"points": []any{map[string]any{"timestamp": float64(0), "value": float64(1)}},
"type": float64(datadogV2.METRICINTAKETYPE_GAUGE),
"interval": float64(0),
"resources": []any{map[string]any{"name": "test-host", "type": "host"}},
"tags": []any{"version:latest", "command:otelcol", "key1:value1", "key2:value2"},
},
Expand Down
Loading