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
27 changes: 27 additions & 0 deletions .chloggen/feat_delete-ff-resourcedetection-propagateerrors.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: "breaking"

# The name of the component, or a single word describing the area of concern, (e.g. receiver/filelog)
component: "processor/resourcedetection"

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "Remove feature gate processor.resourcedetection.propagateerrors"

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [45853]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [user]
12 changes: 0 additions & 12 deletions processor/resourcedetectionprocessor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,6 @@ override the resource value in telemetry data with this information.
> **Note**
>
> If a configured resource detector fails, the error will propagate and stop the collector from starting.
> The `processor.resourcedetection.propagateerrors` [feature gate](https://github.com/open-telemetry/opentelemetry-collector/tree/main/featuregate) is now stable and always enabled
> (as of v0.146.0).

## Feature gates

See [documentation.md](./documentation.md) for the complete list of feature gates supported by this processor.

Feature gates can be enabled using the `--feature-gates` flag:

```shell
"--feature-gates=<feature-gate>"
```

## Supported detectors

Expand Down
13 changes: 0 additions & 13 deletions processor/resourcedetectionprocessor/documentation.md

This file was deleted.

2 changes: 1 addition & 1 deletion processor/resourcedetectionprocessor/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ require (
go.opentelemetry.io/collector/consumer v1.55.0
go.opentelemetry.io/collector/consumer/consumertest v0.149.0
go.opentelemetry.io/collector/consumer/xconsumer v0.149.0
go.opentelemetry.io/collector/featuregate v1.55.0
go.opentelemetry.io/collector/pdata v1.55.0
go.opentelemetry.io/collector/pdata/pprofile v0.149.0
go.opentelemetry.io/collector/processor v1.55.0
Expand Down Expand Up @@ -167,6 +166,7 @@ require (
go.opentelemetry.io/collector/consumer/consumererror v0.149.0 // indirect
go.opentelemetry.io/collector/extension/extensionauth v1.55.0 // indirect
go.opentelemetry.io/collector/extension/extensionmiddleware v0.149.0 // indirect
go.opentelemetry.io/collector/featuregate v1.55.0 // indirect
go.opentelemetry.io/collector/internal/componentalias v0.149.0 // indirect
go.opentelemetry.io/collector/internal/sharedcomponent v0.149.0 // indirect
go.opentelemetry.io/collector/internal/telemetry v0.149.0 // indirect
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import (
"go.opentelemetry.io/collector/pdata/pcommon"
"go.opentelemetry.io/collector/processor"
"go.uber.org/zap"

"github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor/internal/metadata"
)

type DetectorType string
Expand Down Expand Up @@ -200,9 +198,7 @@ func (p *ResourceProvider) detectResource(ctx context.Context) (pcommon.Resource
for _, ch := range resultsChan {
result := <-ch
if result.err != nil {
if metadata.ProcessorResourcedetectionPropagateerrorsFeatureGate.IsEnabled() {
joinedErr = errors.Join(joinedErr, result.err)
}
joinedErr = errors.Join(joinedErr, result.err)
continue
}
successes++
Expand All @@ -212,22 +208,15 @@ func (p *ResourceProvider) detectResource(ctx context.Context) (pcommon.Resource

p.logger.Info("detected resource information", zap.Any("resource", res.Attributes().AsRaw()))

// Determine the error to return based on feature gate setting.
var returnErr error
if metadata.ProcessorResourcedetectionPropagateerrorsFeatureGate.IsEnabled() {
// Feature gate enabled: return joined errors (if any)
if successes == 0 && joinedErr == nil {
returnErr = errors.New("resource detection failed: no detectors succeeded")
} else {
returnErr = joinedErr
}
if successes == 0 && joinedErr == nil {
returnErr = errors.New("resource detection failed: no detectors succeeded")
} else {
returnErr = joinedErr
}

// If all detectors failed, return empty resource.
if successes == 0 {
if !metadata.ProcessorResourcedetectionPropagateerrorsFeatureGate.IsEnabled() {
p.logger.Warn("resource detection failed but error propagation is disabled")
}
return pcommon.NewResource(), "", returnErr
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/featuregate"
"go.opentelemetry.io/collector/pdata/pcommon"
"go.opentelemetry.io/collector/processor"
"go.opentelemetry.io/collector/processor/processortest"
Expand Down Expand Up @@ -125,10 +124,7 @@ func TestDetectResource_DetectorFactoryError(t *testing.T) {
require.EqualError(t, err, fmt.Sprintf("failed creating detector type %q: %v", mockDetectorKey, "creation failed"))
}

func TestDetectResource_Error_ContextDeadline_WithErrPropagation(t *testing.T) {
err := featuregate.GlobalRegistry().Set(metadata.ProcessorResourcedetectionPropagateerrorsFeatureGate.ID(), true)
assert.NoError(t, err)

func TestDetectResource_Error_ContextDeadline(t *testing.T) {
md1 := &mockDetector{}
md1.On("Detect").Return(pcommon.NewResource(), "", errors.New("err1"))

Expand All @@ -141,12 +137,19 @@ func TestDetectResource_Error_ContextDeadline_WithErrPropagation(t *testing.T) {
ctx, cancel := context.WithTimeout(t.Context(), 3*time.Second)
defer cancel()

err = p.Refresh(ctx, &http.Client{Timeout: 10 * time.Second})
err := p.Refresh(ctx, &http.Client{Timeout: 10 * time.Second})
require.Error(t, err)
require.Contains(t, err.Error(), "err1")
require.Contains(t, err.Error(), "err2")
}

func TestDetectResource_NoDetectors(t *testing.T) {
p := NewResourceProvider(zap.NewNop(), time.Second)

err := p.Refresh(t.Context(), &http.Client{Timeout: 10 * time.Second})
require.EqualError(t, err, "resource detection failed: no detectors succeeded")
}

func TestMergeResource(t *testing.T) {
for _, tt := range []struct {
name string
Expand Down
10 changes: 0 additions & 10 deletions processor/resourcedetectionprocessor/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,3 @@ tests:
- "golang.org/x/net/http2.(*clientConnReadLoop).run"
- "crypto/tls.(*Conn).readRecordOrCCS"
- "crypto/tls.(*Conn).Read"

feature_gates:
- id: processor.resourcedetection.propagateerrors
stage: stable
description: >-
When enabled, allows errors returned from resource detectors to propagate
in the Start() method and stop the collector.
from_version: v0.121.0
to_version: v0.146.0
reference_url: https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/37961
Loading