Skip to content

Commit ab4ed72

Browse files
mx-psijpkrohlingKSerrania
authored
[exporter/datadog] Add metrics::summaries::mode setting; deprecate metrics::report_quantiles (open-telemetry#8846)
* [exporter/datadog] Add `metrics::summaries::mode` setting; deprecate `metrics::report_quantiles` * Add changelog entry * Bump version of deprecation and removal This won't make it into v0.48.0, so I am bumping to v0.49.0s * Fix changelog * Apply suggestions from code review Co-authored-by: Kylian Serrania <kylian.serrania@datadoghq.com> * Fix changelog after merge Co-authored-by: Juraci Paixão Kröhling <juraci@kroehling.de> Co-authored-by: Kylian Serrania <kylian.serrania@datadoghq.com>
1 parent 063aae5 commit ab4ed72

File tree

11 files changed

+107
-2
lines changed

11 files changed

+107
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
### 🚩 Deprecations 🚩
1313

1414
- `cumulativetodeltaprocessor`: Deprecated `metrics` configuration option in favor of `include` and `exclude` (#8952)
15+
- `datadogexporter`: Deprecate `metrics::report_quantiles` in favor of `metrics::summaries::mode` (#8846)
1516

1617
### 🚀 New components 🚀
1718

@@ -28,6 +29,7 @@
2829
- `cmd/mdatagen`: Update generated functions to have simple parse function to handle string parsing consistently and limit code duplication across receivers (#7574)
2930
- `attributesprocessor`: Support filter by severity (#9132)
3031
- `processor/transform`: Add transformation of logs (#9368)
32+
- `datadogexporter`: Add `metrics::summaries::mode` to specify export mode for summaries (#8846)
3133

3234
### 🧰 Bug fixes 🧰
3335

exporter/datadogexporter/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,6 @@ There are a number of optional settings for configuring how to send your metrics
105105
|-|-|-|
106106
| `send_monotonic_counter` | Cumulative monotonic metrics are sent as deltas between successive measurements. Disable this flag to send get the raw, monotonically increasing value. | `true` |
107107
| `delta_ttl` | Maximum number of seconds values from cumulative monotonic metrics are kept in memory. | 3600 |
108-
| `report_quantiles` | Whether to report quantile values for summary type metrics. | `true` |
108+
| `summaries::mode` | Mode for summaries. Valid values are `noquantiles` (no quantiles metrics) and `gauges` (one metric per quantile). | `gauges` |
109109
| `histograms::mode` | Mode for histograms. Valid values are `nobuckets` (no bucket metrics), `counters` (one metric per bucket) and `distributions` (send as Datadog distributions, recommended). | `distributions` |
110110
| `histograms::send_count_sum_metrics` | Whether to report sum and count for histograms as separate metrics. | `false` |

exporter/datadogexporter/config/config.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ type APIConfig struct {
6464
type MetricsConfig struct {
6565
// Quantiles states whether to report quantiles from summary metrics.
6666
// By default, the minimum, maximum and average are reported.
67+
// Deprecated: [v0.50.0] Use `metrics::summaries::mode` (SummaryConfig.Mode) instead.
6768
Quantiles bool `mapstructure:"report_quantiles"`
6869

6970
// SendMonotonic states whether to report cumulative monotonic metrics as counters
@@ -87,6 +88,9 @@ type MetricsConfig struct {
8788

8889
// SumConfig defines the export of OTLP Sums.
8990
SumConfig SumConfig `mapstructure:"sums"`
91+
92+
// SummaryConfig defines the export for OTLP Summaries.
93+
SummaryConfig SummaryConfig `mapstructure:"summaries"`
9094
}
9195

9296
// HistogramConfig customizes export of OTLP Histograms.
@@ -152,6 +156,42 @@ type SumConfig struct {
152156
CumulativeMonotonicMode CumulativeMonotonicSumMode `mapstructure:"cumulative_monotonic_mode"`
153157
}
154158

159+
// SummaryMode is the export mode for OTLP Summary metrics.
160+
type SummaryMode string
161+
162+
const (
163+
// SummaryModeNoQuantiles sends no `.quantile` metrics. `.sum` and `.count` metrics will still be sent.
164+
SummaryModeNoQuantiles SummaryMode = "noquantiles"
165+
// SummaryModeGauges sends `.quantile` metrics as gauges tagged by the quantile.
166+
SummaryModeGauges SummaryMode = "gauges"
167+
)
168+
169+
var _ encoding.TextUnmarshaler = (*SummaryMode)(nil)
170+
171+
// UnmarshalText implements the encoding.TextUnmarshaler interface.
172+
func (sm *SummaryMode) UnmarshalText(in []byte) error {
173+
switch mode := SummaryMode(in); mode {
174+
case SummaryModeNoQuantiles,
175+
SummaryModeGauges:
176+
*sm = mode
177+
return nil
178+
default:
179+
return fmt.Errorf("invalid summary mode %q", mode)
180+
}
181+
}
182+
183+
// SummaryConfig customizes export of OTLP Summaries.
184+
type SummaryConfig struct {
185+
// Mode is the the mode for exporting OTLP Summaries.
186+
// Valid values are 'noquantiles' or 'gauges'.
187+
// - 'noquantiles' sends no `.quantile` metrics. `.sum` and `.count` metrics will still be sent.
188+
// - 'gauges' sends `.quantile` metrics as gauges tagged by the quantile.
189+
//
190+
// The default is 'gauges'.
191+
// See https://docs.datadoghq.com/metrics/otlp/?tab=summary#mapping for details and examples.
192+
Mode SummaryMode `mapstructure:"mode"`
193+
}
194+
155195
// MetricsExporterConfig provides options for a user to customize the behavior of the
156196
// metrics exporter
157197
type MetricsExporterConfig struct {

exporter/datadogexporter/config/config_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,17 @@ func TestUnmarshal(t *testing.T) {
207207
}),
208208
err: "1 error(s) decoding:\n\n* error decoding 'host_metadata.hostname_source': invalid host metadata hostname source \"invalid_source\"",
209209
},
210+
{
211+
name: "invalid summary mode",
212+
configMap: config.NewMapFromStringMap(map[string]interface{}{
213+
"metrics": map[string]interface{}{
214+
"summaries": map[string]interface{}{
215+
"mode": "invalid_mode",
216+
},
217+
},
218+
}),
219+
err: "1 error(s) decoding:\n\n* error decoding 'metrics.summaries.mode': invalid summary mode \"invalid_mode\"",
220+
},
210221
}
211222

212223
for _, testInstance := range tests {

exporter/datadogexporter/config/warn_envvars.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ func futureDefaultConfig() *Config {
4646
SumConfig: SumConfig{
4747
CumulativeMonotonicMode: CumulativeMonotonicSumModeToDelta,
4848
},
49+
SummaryConfig: SummaryConfig{
50+
Mode: SummaryModeGauges,
51+
},
4952
},
5053
Traces: TracesConfig{
5154
SampleRate: 1,

exporter/datadogexporter/config/warning_deprecated.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,19 @@ var renamedSettings = []renameError{
8484
}
8585
},
8686
},
87+
{
88+
oldName: "metrics::report_quantiles",
89+
newName: "metrics::summaries::mode",
90+
oldRemovedIn: "v0.53.0",
91+
issueNumber: 8845,
92+
updateFn: func(c *Config) {
93+
if c.Metrics.Quantiles {
94+
c.Metrics.SummaryConfig.Mode = SummaryModeGauges
95+
} else {
96+
c.Metrics.SummaryConfig.Mode = SummaryModeNoQuantiles
97+
}
98+
},
99+
},
87100
}
88101

89102
// List of settings that have been removed, but for which we keep a custom error.

exporter/datadogexporter/example/config.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ exporters:
101101
#
102102
# send_monotonic_counter: true
103103

104+
## @param report_quantiles - boolean - optional - default: true
105+
## Deprecated: [v0.50.0] Use `metrics::summaries::mode` instead.
106+
## Whether to report quantiles for summary metrics.
107+
#
108+
# report_quantiles: true
109+
104110
## @param - delta_ttl - integer - optional - default: 3600
105111
## The amount of time (in seconds) that values are kept in memory for
106112
## calculating deltas for cumulative monotonic metrics.
@@ -152,6 +158,16 @@ exporters:
152158
#
153159
# cumulative_monotonic_mode: to_delta
154160

161+
## @param summaries - custom object - optional
162+
## Summaries specific configuration.
163+
## @param mode - string - optional - default: gauges
164+
## How to report summaries. Valid values are:
165+
##
166+
## - `noquantiles` to not report quantile metrics
167+
## - `gauges` to report one gauge metric per quantile.
168+
#
169+
# mode: gauges
170+
155171
## @param traces - custom object - optional
156172
## Trace exporter specific configuration.
157173
#

exporter/datadogexporter/factory.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ func (*factory) createDefaultConfig() config.Exporter {
100100
SumConfig: ddconfig.SumConfig{
101101
CumulativeMonotonicMode: ddconfig.CumulativeMonotonicSumModeToDelta,
102102
},
103+
SummaryConfig: ddconfig.SummaryConfig{
104+
Mode: ddconfig.SummaryModeGauges,
105+
},
103106
},
104107

105108
Traces: ddconfig.TracesConfig{

exporter/datadogexporter/factory_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ func TestCreateDefaultConfig(t *testing.T) {
8888
SumConfig: ddconfig.SumConfig{
8989
CumulativeMonotonicMode: ddconfig.CumulativeMonotonicSumModeToDelta,
9090
},
91+
SummaryConfig: ddconfig.SummaryConfig{
92+
Mode: ddconfig.SummaryModeGauges,
93+
},
9194
},
9295

9396
Traces: ddconfig.TracesConfig{
@@ -165,6 +168,9 @@ func TestLoadConfig(t *testing.T) {
165168
SumConfig: ddconfig.SumConfig{
166169
CumulativeMonotonicMode: ddconfig.CumulativeMonotonicSumModeToDelta,
167170
},
171+
SummaryConfig: ddconfig.SummaryConfig{
172+
Mode: ddconfig.SummaryModeGauges,
173+
},
168174
}, apiConfig.Metrics)
169175
assert.Equal(t, ddconfig.TracesConfig{
170176
SampleRate: 1,
@@ -214,6 +220,9 @@ func TestLoadConfig(t *testing.T) {
214220
SumConfig: ddconfig.SumConfig{
215221
CumulativeMonotonicMode: ddconfig.CumulativeMonotonicSumModeToDelta,
216222
},
223+
SummaryConfig: ddconfig.SummaryConfig{
224+
Mode: ddconfig.SummaryModeGauges,
225+
},
217226
},
218227

219228
Traces: ddconfig.TracesConfig{
@@ -312,6 +321,9 @@ func TestLoadConfigEnvVariables(t *testing.T) {
312321
SumConfig: ddconfig.SumConfig{
313322
CumulativeMonotonicMode: ddconfig.CumulativeMonotonicSumModeToDelta,
314323
},
324+
SummaryConfig: ddconfig.SummaryConfig{
325+
Mode: ddconfig.SummaryModeNoQuantiles,
326+
},
315327
}, apiConfig.Metrics)
316328
assert.Equal(t,
317329
ddconfig.TracesConfig{
@@ -362,6 +374,9 @@ func TestLoadConfigEnvVariables(t *testing.T) {
362374
SumConfig: ddconfig.SumConfig{
363375
CumulativeMonotonicMode: ddconfig.CumulativeMonotonicSumModeToDelta,
364376
},
377+
SummaryConfig: ddconfig.SummaryConfig{
378+
Mode: ddconfig.SummaryModeGauges,
379+
},
365380
}, defaultConfig.Metrics)
366381
assert.Equal(t, ddconfig.TracesConfig{
367382
SampleRate: 1,

exporter/datadogexporter/metrics_exporter.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ func translatorFromConfig(logger *zap.Logger, cfg *config.Config) (*translator.T
7272
options = append(options, translator.WithCountSumMetrics())
7373
}
7474

75-
if cfg.Metrics.Quantiles {
75+
switch cfg.Metrics.SummaryConfig.Mode {
76+
case config.SummaryModeGauges:
7677
options = append(options, translator.WithQuantiles())
7778
}
7879

0 commit comments

Comments
 (0)