Skip to content

Commit 2b03261

Browse files
committed
use alpha stage feature-gate
1 parent eb7c81a commit 2b03261

File tree

4 files changed

+25
-15
lines changed

4 files changed

+25
-15
lines changed

.chloggen/fix-42462.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ issues: [42462]
1616
# These lines will be padded with 2 spaces and then inserted directly into the document.
1717
# Use pipe (|) for multiline entries.
1818
subtext: |
19-
This change introduces a breaking change, which is now guarded by the feature gate `connector.spanmetrics.legacyDefaultMetricsUnit`.
20-
Currently, the feature gate is enabled by default, so the unit will remain `ms`. After one or two release cycles, the unit will switch to `s` and the feature gate will also be disabled by default.
19+
This change introduces a breaking change, which is now guarded by the feature gate `connector.spanmetrics.useSCDefaultMetricsUnit`.
20+
Currently, the feature gate is disabled by default, so the unit will remain `ms`. After one release cycle, the unit will switch to `s` and the feature gate will also be enabled by default.
2121
To revert this change manually, users can either enable the feature gate or modify the configuration as follows:
2222
```
2323
connectors

connector/spanmetricsconnector/README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@
2323
[Stability Level]: https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/component-stability.md#stability-levels
2424
<!-- end autogenerated section -->
2525

26+
⚠️ Breaking Change Warning:
27+
The default duration metrics unit will change from `ms` to `s` to adhere to the OpenTelemetry semantic conventions and a feature gate `connector.spanmetrics.useSCDefaultMetricsUnit` is also added.
28+
29+
Currently, the feature gate is disabled by default, so the unit will remain `ms`. After one release cycle, the unit will switch to `s` and the feature gate will also be enabled by default.
30+
To revert this change manually, users can either disabled the feature gate or modify the configuration as follows:
31+
```
32+
connectors
33+
spanmetrics:
34+
histogram:
35+
unit: "ms"
36+
```
37+
2638
## Overview
2739

2840
Aggregates Request, Error and Duration (R.E.D) OpenTelemetry metrics from span data.
@@ -96,7 +108,7 @@ The following settings can be optionally configured:
96108
- `histogram` (default: `explicit`): Use to configure the type of histogram to record
97109
calculated from spans duration measurements. Must be either `explicit` or `exponential`.
98110
- `disable` (default: `false`): Disable all histogram metrics.
99-
- `unit` (default: `ms`, it will change to `s` in the next release, you can enable feature-gate `connector.spanmetrics.legacyDefaultMetricsUnit` to keep use `ms` unit): The time unit for recording duration measurements.
111+
- `unit` (default: `ms`): The time unit for recording duration measurements.
100112
calculated from spans duration measurements. One of either: `ms` or `s`.
101113
- `dimensions`: additional attributes to add as dimensions to the `traces.span.metrics.duration` metric,
102114
which will be included _on top of_ the common and configured `dimensions` for span attributes and resource attributes.

connector/spanmetricsconnector/config_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ import (
2626
func TestLoadConfig(t *testing.T) {
2727
t.Parallel()
2828

29-
// disable legacyDefaultMetricsUnit featuregate
30-
require.NoError(t, featuregate.GlobalRegistry().Set(legacyDefaultMetricsUnit.ID(), false))
31-
29+
require.NoError(t, featuregate.GlobalRegistry().Set(useSCDefaultMetricsUnit.ID(), true))
3230
cm, err := confmaptest.LoadConf(filepath.Join("testdata", "config.yaml"))
3331
require.NoError(t, err)
3432

connector/spanmetricsconnector/factory.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ const (
2525
DefaultNamespace = "traces.span.metrics"
2626
legacyMetricNamesFeatureGateID = "connector.spanmetrics.legacyMetricNames"
2727
includeCollectorInstanceIDFeatureGateID = "connector.spanmetrics.includeCollectorInstanceID"
28-
legacyDefaultMetricsUnitFeatureGateID = "connector.spanmetrics.legacyDefaultMetricsUnit"
28+
useSCDefaultMetricsUnitFeatureGateID = "connector.spanmetrics.useSCDefaultMetricsUnit"
2929
)
3030

3131
var (
3232
legacyMetricNamesFeatureGate *featuregate.Gate
3333
includeCollectorInstanceID *featuregate.Gate
34-
legacyDefaultMetricsUnit *featuregate.Gate
34+
useSCDefaultMetricsUnit *featuregate.Gate
3535
)
3636

3737
func init() {
@@ -48,10 +48,10 @@ func init() {
4848
featuregate.WithRegisterDescription("When enabled, connector add collector.instance.id to default dimensions."),
4949
featuregate.WithRegisterReferenceURL("https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/40400"),
5050
)
51-
legacyDefaultMetricsUnit = featuregate.GlobalRegistry().MustRegister(
52-
legacyDefaultMetricsUnitFeatureGateID,
53-
featuregate.StageBeta, // current enabled by default and disable it in the next release
54-
featuregate.WithRegisterDescription("enabled by default, connector use ms unit for duration metrics."),
51+
useSCDefaultMetricsUnit = featuregate.GlobalRegistry().MustRegister(
52+
useSCDefaultMetricsUnitFeatureGateID,
53+
featuregate.StageAlpha,
54+
featuregate.WithRegisterDescription("When enabled, connector use second as default unit for duration metrics."),
5555
featuregate.WithRegisterReferenceURL("https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/42103"),
5656
)
5757
}
@@ -71,11 +71,11 @@ func createDefaultConfig() component.Config {
7171
ResourceMetricsCacheSize: defaultResourceMetricsCacheSize,
7272
MetricsFlushInterval: 60 * time.Second,
7373
Histogram: HistogramConfig{Disable: false, Unit: func() metrics.Unit {
74-
if legacyDefaultMetricsUnit.IsEnabled() {
75-
return metrics.Milliseconds
74+
if useSCDefaultMetricsUnit.IsEnabled() {
75+
return metrics.Seconds
7676
}
7777

78-
return metrics.Seconds
78+
return metrics.Milliseconds
7979
}()},
8080
Namespace: DefaultNamespace,
8181
AggregationCardinalityLimit: 0,

0 commit comments

Comments
 (0)