Skip to content

Commit

Permalink
[exporter/datadog] Add metrics::summaries::mode setting; deprecate …
Browse files Browse the repository at this point in the history
…`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 <[email protected]>

* Fix changelog after merge

Co-authored-by: Juraci Paixão Kröhling <[email protected]>
Co-authored-by: Kylian Serrania <[email protected]>
  • Loading branch information
3 people authored and djaglowski committed May 10, 2022
1 parent 1d5d825 commit 6dc6a08
Show file tree
Hide file tree
Showing 11 changed files with 107 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
### 🚩 Deprecations 🚩

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

### 🚀 New components 🚀

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

### 🧰 Bug fixes 🧰

Expand Down
2 changes: 1 addition & 1 deletion exporter/datadogexporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,6 @@ There are a number of optional settings for configuring how to send your metrics
|-|-|-|
| `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` |
| `delta_ttl` | Maximum number of seconds values from cumulative monotonic metrics are kept in memory. | 3600 |
| `report_quantiles` | Whether to report quantile values for summary type metrics. | `true` |
| `summaries::mode` | Mode for summaries. Valid values are `noquantiles` (no quantiles metrics) and `gauges` (one metric per quantile). | `gauges` |
| `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` |
| `histograms::send_count_sum_metrics` | Whether to report sum and count for histograms as separate metrics. | `false` |
40 changes: 40 additions & 0 deletions exporter/datadogexporter/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ type APIConfig struct {
type MetricsConfig struct {
// Quantiles states whether to report quantiles from summary metrics.
// By default, the minimum, maximum and average are reported.
// Deprecated: [v0.50.0] Use `metrics::summaries::mode` (SummaryConfig.Mode) instead.
Quantiles bool `mapstructure:"report_quantiles"`

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

// SumConfig defines the export of OTLP Sums.
SumConfig SumConfig `mapstructure:"sums"`

// SummaryConfig defines the export for OTLP Summaries.
SummaryConfig SummaryConfig `mapstructure:"summaries"`
}

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

// SummaryMode is the export mode for OTLP Summary metrics.
type SummaryMode string

const (
// SummaryModeNoQuantiles sends no `.quantile` metrics. `.sum` and `.count` metrics will still be sent.
SummaryModeNoQuantiles SummaryMode = "noquantiles"
// SummaryModeGauges sends `.quantile` metrics as gauges tagged by the quantile.
SummaryModeGauges SummaryMode = "gauges"
)

var _ encoding.TextUnmarshaler = (*SummaryMode)(nil)

// UnmarshalText implements the encoding.TextUnmarshaler interface.
func (sm *SummaryMode) UnmarshalText(in []byte) error {
switch mode := SummaryMode(in); mode {
case SummaryModeNoQuantiles,
SummaryModeGauges:
*sm = mode
return nil
default:
return fmt.Errorf("invalid summary mode %q", mode)
}
}

// SummaryConfig customizes export of OTLP Summaries.
type SummaryConfig struct {
// Mode is the the mode for exporting OTLP Summaries.
// Valid values are 'noquantiles' or 'gauges'.
// - 'noquantiles' sends no `.quantile` metrics. `.sum` and `.count` metrics will still be sent.
// - 'gauges' sends `.quantile` metrics as gauges tagged by the quantile.
//
// The default is 'gauges'.
// See https://docs.datadoghq.com/metrics/otlp/?tab=summary#mapping for details and examples.
Mode SummaryMode `mapstructure:"mode"`
}

// MetricsExporterConfig provides options for a user to customize the behavior of the
// metrics exporter
type MetricsExporterConfig struct {
Expand Down
11 changes: 11 additions & 0 deletions exporter/datadogexporter/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,17 @@ func TestUnmarshal(t *testing.T) {
}),
err: "1 error(s) decoding:\n\n* error decoding 'host_metadata.hostname_source': invalid host metadata hostname source \"invalid_source\"",
},
{
name: "invalid summary mode",
configMap: config.NewMapFromStringMap(map[string]interface{}{
"metrics": map[string]interface{}{
"summaries": map[string]interface{}{
"mode": "invalid_mode",
},
},
}),
err: "1 error(s) decoding:\n\n* error decoding 'metrics.summaries.mode': invalid summary mode \"invalid_mode\"",
},
}

for _, testInstance := range tests {
Expand Down
3 changes: 3 additions & 0 deletions exporter/datadogexporter/config/warn_envvars.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ func futureDefaultConfig() *Config {
SumConfig: SumConfig{
CumulativeMonotonicMode: CumulativeMonotonicSumModeToDelta,
},
SummaryConfig: SummaryConfig{
Mode: SummaryModeGauges,
},
},
Traces: TracesConfig{
SampleRate: 1,
Expand Down
13 changes: 13 additions & 0 deletions exporter/datadogexporter/config/warning_deprecated.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,19 @@ var renamedSettings = []renameError{
}
},
},
{
oldName: "metrics::report_quantiles",
newName: "metrics::summaries::mode",
oldRemovedIn: "v0.53.0",
issueNumber: 8845,
updateFn: func(c *Config) {
if c.Metrics.Quantiles {
c.Metrics.SummaryConfig.Mode = SummaryModeGauges
} else {
c.Metrics.SummaryConfig.Mode = SummaryModeNoQuantiles
}
},
},
}

// List of settings that have been removed, but for which we keep a custom error.
Expand Down
16 changes: 16 additions & 0 deletions exporter/datadogexporter/example/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ exporters:
#
# send_monotonic_counter: true

## @param report_quantiles - boolean - optional - default: true
## Deprecated: [v0.50.0] Use `metrics::summaries::mode` instead.
## Whether to report quantiles for summary metrics.
#
# report_quantiles: true

## @param - delta_ttl - integer - optional - default: 3600
## The amount of time (in seconds) that values are kept in memory for
## calculating deltas for cumulative monotonic metrics.
Expand Down Expand Up @@ -152,6 +158,16 @@ exporters:
#
# cumulative_monotonic_mode: to_delta

## @param summaries - custom object - optional
## Summaries specific configuration.
## @param mode - string - optional - default: gauges
## How to report summaries. Valid values are:
##
## - `noquantiles` to not report quantile metrics
## - `gauges` to report one gauge metric per quantile.
#
# mode: gauges

## @param traces - custom object - optional
## Trace exporter specific configuration.
#
Expand Down
3 changes: 3 additions & 0 deletions exporter/datadogexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ func (*factory) createDefaultConfig() config.Exporter {
SumConfig: ddconfig.SumConfig{
CumulativeMonotonicMode: ddconfig.CumulativeMonotonicSumModeToDelta,
},
SummaryConfig: ddconfig.SummaryConfig{
Mode: ddconfig.SummaryModeGauges,
},
},

Traces: ddconfig.TracesConfig{
Expand Down
15 changes: 15 additions & 0 deletions exporter/datadogexporter/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ func TestCreateDefaultConfig(t *testing.T) {
SumConfig: ddconfig.SumConfig{
CumulativeMonotonicMode: ddconfig.CumulativeMonotonicSumModeToDelta,
},
SummaryConfig: ddconfig.SummaryConfig{
Mode: ddconfig.SummaryModeGauges,
},
},

Traces: ddconfig.TracesConfig{
Expand Down Expand Up @@ -165,6 +168,9 @@ func TestLoadConfig(t *testing.T) {
SumConfig: ddconfig.SumConfig{
CumulativeMonotonicMode: ddconfig.CumulativeMonotonicSumModeToDelta,
},
SummaryConfig: ddconfig.SummaryConfig{
Mode: ddconfig.SummaryModeGauges,
},
}, apiConfig.Metrics)
assert.Equal(t, ddconfig.TracesConfig{
SampleRate: 1,
Expand Down Expand Up @@ -214,6 +220,9 @@ func TestLoadConfig(t *testing.T) {
SumConfig: ddconfig.SumConfig{
CumulativeMonotonicMode: ddconfig.CumulativeMonotonicSumModeToDelta,
},
SummaryConfig: ddconfig.SummaryConfig{
Mode: ddconfig.SummaryModeGauges,
},
},

Traces: ddconfig.TracesConfig{
Expand Down Expand Up @@ -312,6 +321,9 @@ func TestLoadConfigEnvVariables(t *testing.T) {
SumConfig: ddconfig.SumConfig{
CumulativeMonotonicMode: ddconfig.CumulativeMonotonicSumModeToDelta,
},
SummaryConfig: ddconfig.SummaryConfig{
Mode: ddconfig.SummaryModeNoQuantiles,
},
}, apiConfig.Metrics)
assert.Equal(t,
ddconfig.TracesConfig{
Expand Down Expand Up @@ -362,6 +374,9 @@ func TestLoadConfigEnvVariables(t *testing.T) {
SumConfig: ddconfig.SumConfig{
CumulativeMonotonicMode: ddconfig.CumulativeMonotonicSumModeToDelta,
},
SummaryConfig: ddconfig.SummaryConfig{
Mode: ddconfig.SummaryModeGauges,
},
}, defaultConfig.Metrics)
assert.Equal(t, ddconfig.TracesConfig{
SampleRate: 1,
Expand Down
3 changes: 2 additions & 1 deletion exporter/datadogexporter/metrics_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ func translatorFromConfig(logger *zap.Logger, cfg *config.Config) (*translator.T
options = append(options, translator.WithCountSumMetrics())
}

if cfg.Metrics.Quantiles {
switch cfg.Metrics.SummaryConfig.Mode {
case config.SummaryModeGauges:
options = append(options, translator.WithQuantiles())
}

Expand Down
1 change: 1 addition & 0 deletions exporter/datadogexporter/testdata/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ exporters:

metrics:
endpoint: https://api.datadoghq.test
# Deprecated; kept here to avoid regressions
report_quantiles: false

traces:
Expand Down

0 comments on commit 6dc6a08

Please sign in to comment.