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 @@ -146,9 +146,6 @@ linters:
- linters:
- forbidigo
path: internal/filter/
- linters:
- forbidigo
path: pkg/ottl/
- linters:
- forbidigo
path: receiver/awscontainerinsightreceiver/
Expand Down
14 changes: 3 additions & 11 deletions pkg/ottl/contexts/internal/ctxotelcol/otelcol.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,18 @@ import (
"context"
"errors"

"go.opentelemetry.io/collector/featuregate"
"go.opentelemetry.io/collector/pdata/pcommon"

"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl"
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/internal/ctxerror"
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/internal/ctxutil"
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/internal/metadata"
)

var (
enableOTelColContext = featuregate.GlobalRegistry().MustRegister(
"ottl.contexts.enableOTelColContext",
featuregate.StageBeta,
featuregate.WithRegisterDescription("Enable the `otelcol` context for OTTL. This allows users using `otelcol.*` paths in their OTTL statements and conditions."),
featuregate.WithRegisterReferenceURL("https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/46437"),
featuregate.WithRegisterFromVersion("v0.147.0"))
errOTelColContextDisabled = errors.New("OTTL `otelcol` context requires the `ottl.contexts.enableOTelColContext` feature gate to be enabled")
)
var errOTelColContextDisabled = errors.New("OTTL `otelcol` context requires the `ottl.contexts.enableOTelColContext` feature gate to be enabled")

func PathGetSetter[K any](path ottl.Path[K]) (ottl.GetSetter[K], error) {
if !enableOTelColContext.IsEnabled() {
if !metadata.OttlContextsEnableOTelColContextFeatureGate.IsEnabled() {
return nil, errOTelColContextDisabled
}
switch path.Name() {
Expand Down
7 changes: 4 additions & 3 deletions pkg/ottl/contexts/internal/ctxotelcol/otelcol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (

"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl"
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/internal/pathtest"
featureMetadata "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/internal/metadata"
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/ottltest"
)

Expand Down Expand Up @@ -477,12 +478,12 @@ func TestContextGrpcMetadata(t *testing.T) {
}

func Test_enableOTelColContextFeatureGate(t *testing.T) {
original := enableOTelColContext.IsEnabled()
original := featureMetadata.OttlContextsEnableOTelColContextFeatureGate.IsEnabled()
defer func() {
require.NoError(t, featuregate.GlobalRegistry().Set(enableOTelColContext.ID(), original))
require.NoError(t, featuregate.GlobalRegistry().Set(featureMetadata.OttlContextsEnableOTelColContextFeatureGate.ID(), original))
}()

require.NoError(t, featuregate.GlobalRegistry().Set(enableOTelColContext.ID(), false))
require.NoError(t, featuregate.GlobalRegistry().Set(featureMetadata.OttlContextsEnableOTelColContextFeatureGate.ID(), false))
_, err := PathGetSetter(&pathtest.Path[testContext]{})
assert.Equal(t, errOTelColContextDisabled, err)
}
Expand Down
14 changes: 14 additions & 0 deletions pkg/ottl/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[comment]: <> (Code generated by mdatagen. DO NOT EDIT.)

# ottl

## Feature Gates

This component has the following feature gates:

| Feature Gate | Stage | Description | From Version | To Version | Reference |
| ------------ | ----- | ----------- | ------------ | ---------- | --------- |
| `ottl.PanicDuplicateName` | beta | When enabled, the CreateFactoryMap panics if the name is duplicated. | v0.141.0 | N/A | [Link](https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/44630) |
| `ottl.contexts.enableOTelColContext` | beta | Enable the `otelcol` context for OTTL. This allows users using `otelcol.*` paths in their OTTL statements and conditions. | v0.147.0 | N/A | [Link](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/46437) |

For more information about feature gates, see the [Feature Gates](https://github.com/open-telemetry/opentelemetry-collector/blob/main/featuregate/README.md) documentation.
9 changes: 2 additions & 7 deletions pkg/ottl/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,8 @@ package ottl // import "github.com/open-telemetry/opentelemetry-collector-contri

import (
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/featuregate"
)

var panicDuplicateName = featuregate.GlobalRegistry().MustRegister(
"ottl.PanicDuplicateName",
featuregate.StageBeta,
featuregate.WithRegisterDescription("When enabled, the CreateFactoryMap panics if the name is duplicated."),
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/internal/metadata"
)

// Arguments holds the arguments for an OTTL function, with arguments
Expand Down Expand Up @@ -90,7 +85,7 @@ func CreateFactoryMap[K any](factories ...Factory[K]) map[string]Factory[K] {
factoryMap := map[string]Factory[K]{}

for _, fn := range factories {
if panicDuplicateName.IsEnabled() {
if metadata.OttlPanicDuplicateNameFeatureGate.IsEnabled() {
if _, ok := factoryMap[fn.Name()]; ok {
panic("duplicate factory name: " + fn.Name())
}
Expand Down
23 changes: 23 additions & 0 deletions pkg/ottl/internal/metadata/generated_feature_gates.go

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

13 changes: 13 additions & 0 deletions pkg/ottl/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,16 @@ status:
active: [TylerHelmuth, evan-bradley, edmocosta, bogdandrutu]
emeritus: [anuraaga, kentquirk]
seeking_new: true

feature_gates:
- id: "ottl.PanicDuplicateName"
description: When enabled, the CreateFactoryMap panics if the name is duplicated.
stage: beta
from_version: v0.141.0
reference_url: https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/44630

- id: "ottl.contexts.enableOTelColContext"
description: Enable the `otelcol` context for OTTL. This allows users using `otelcol.*` paths in their OTTL statements and conditions.
stage: beta
from_version: v0.147.0
reference_url: https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/46437
Loading