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
3 changes: 0 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,6 @@ linters:
- linters:
- forbidigo
path: processor/filterprocessor/
- linters:
- forbidigo
path: processor/metricsgenerationprocessor/
- linters:
- forbidigo
path: processor/tailsamplingprocessor/
Expand Down
13 changes: 13 additions & 0 deletions processor/metricsgenerationprocessor/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[comment]: <> (Code generated by mdatagen. DO NOT EDIT.)

# metricsgeneration

## Feature Gates

This component has the following feature gates:

| Feature Gate | Stage | Description | From Version | To Version | Reference |
| ------------ | ----- | ----------- | ------------ | ---------- | --------- |
| `metricsgeneration.MatchAttributes` | alpha | When enabled, the metric calculations will only be done between data points whose attributes match. | v0.112.0 | N/A | [Link](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/35425) |

For more information about feature gates, see the [Feature Gates](https://github.com/open-telemetry/opentelemetry-collector/blob/main/featuregate/README.md) documentation.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions processor/metricsgenerationprocessor/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,12 @@ status:
distributions: [contrib]
codeowners:
active: [Aneurysm9, crobert-1]
feature_gates:
- id: metricsgeneration.MatchAttributes
description: >-
When enabled, the metric calculations will only be done between data points whose attributes match.
stage: alpha
from_version: "v0.112.0"
reference_url: https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/35425
tests:
config:
11 changes: 2 additions & 9 deletions processor/metricsgenerationprocessor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,10 @@ import (
"fmt"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/featuregate"
"go.opentelemetry.io/collector/pdata/pmetric"
"go.uber.org/zap"
)

var matchAttributes = featuregate.GlobalRegistry().MustRegister(
"metricsgeneration.MatchAttributes",
featuregate.StageAlpha,
featuregate.WithRegisterDescription("When enabled, the metric calculations will only be done between data points whose attributes match."),
featuregate.WithRegisterReferenceURL("https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/35425"),
featuregate.WithRegisterFromVersion("v0.112.0"),
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/metricsgenerationprocessor/internal/metadata"
)

type metricsGenerationProcessor struct {
Expand Down Expand Up @@ -78,7 +71,7 @@ func (mgp *metricsGenerationProcessor) processMetrics(_ context.Context, md pmet
continue
}

if matchAttributes.IsEnabled() {
if metadata.MetricsgenerationMatchAttributesFeatureGate.IsEnabled() {
generateCalculatedMetrics(rm, metric2, rule, mgp.logger)
} else {
// When matching metric attributes isn't required the value of the first data point of metric2 is
Expand Down
6 changes: 4 additions & 2 deletions processor/metricsgenerationprocessor/processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,9 @@ func TestMetricsGenerationProcessor(t *testing.T) {
ctx := t.Context()
require.NoError(t, mgp.Start(ctx, nil))

cErr := mgp.ConsumeMetrics(t.Context(), test.inMetrics)
inputCopy := pmetric.NewMetrics()
test.inMetrics.CopyTo(inputCopy)
cErr := mgp.ConsumeMetrics(t.Context(), inputCopy)
assert.NoError(t, cErr)
got := next.AllMetrics()

Expand Down Expand Up @@ -514,7 +516,7 @@ func TestGoldenFileMetrics(t *testing.T) {

for _, testCase := range testCaseNames {
t.Run(testCase.name, func(t *testing.T) {
require.NoError(t, featuregate.GlobalRegistry().Set(matchAttributes.ID(), testCase.matchAttributesFlagEnabled))
require.NoError(t, featuregate.GlobalRegistry().Set(metadata.MetricsgenerationMatchAttributesFeatureGate.ID(), testCase.matchAttributesFlagEnabled))

cm, err := confmaptest.LoadConf(filepath.Join("testdata", testCase.testDir, "config.yaml"))
assert.NoError(t, err)
Expand Down
Loading