Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[processor/resourcedetection] Disable host.id on system detector by default #24010

Merged
merged 3 commits into from
Jul 17, 2023
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
30 changes: 30 additions & 0 deletions .chloggen/mx-psi_system-detector-host-id.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Use this changelog template to create an entry for release notes.
# If your change doesn't affect end users, such as a test fix or a tooling change,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: breaking
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder whether this is a breaking change or rather a fix to a previous breaking change 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this has been out for a few months now I would rather mark this as breaking in case users have adapted to the new behavior


# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: resourcedetectionprocessor

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "Disable `host.id` by default on the `system` detector. This restores the behavior prior to v0.72.0 when using the `system` detector together with other detectors that set `host.id`"

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

# (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: |
To re-enable `host.id` on the `system` detector set `system::resource_attributes::host.id::enabled` to `true`:

```
resourcedetection:
detectors: [system]
system:
resource_attributes:
host.id:
enabled: true
```
2 changes: 0 additions & 2 deletions processor/resourcedetectionprocessor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,6 @@ resourcedetection:
enabled: false
```

NOTE: Currently all attributes are enabled by default for backwards compatibility purposes, but it will change in the future.

## Ordering

Note that if multiple detectors are inserting the same attribute name, the first detector to insert wins. For example if you had `detectors: [eks, ec2]` then `cloud.platform` will be `aws_eks` instead of `ec2`. The below ordering is recommended.
Expand Down

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

Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ resource_attributes:
host.id:
description: The host.id
type: string
enabled: true
enabled: false
os.type:
description: The os.type
type: string
enabled: true
enabled: true
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ func TestDetectFQDNAvailable(t *testing.T) {
expected := map[string]any{
conventions.AttributeHostName: "fqdn",
conventions.AttributeOSType: "darwin",
conventions.AttributeHostID: "2",
}

assert.Equal(t, expected, res.Attributes().AsRaw())
Expand All @@ -110,10 +109,32 @@ func TestFallbackHostname(t *testing.T) {
mdHostname.On("Hostname").Return("hostname", nil)
mdHostname.On("FQDN").Return("", errors.New("err"))
mdHostname.On("OSType").Return("darwin", nil)
mdHostname.On("HostID").Return("3", nil)

resourceAttributes := CreateDefaultConfig().ResourceAttributes
detector := &Detector{provider: mdHostname, logger: zap.NewNop(), hostnameSources: []string{"dns", "os"}, resourceAttributes: resourceAttributes}
res, schemaURL, err := detector.Detect(context.Background())
require.NoError(t, err)
assert.Equal(t, conventions.SchemaURL, schemaURL)
mdHostname.AssertExpectations(t)

expected := map[string]any{
conventions.AttributeHostName: "hostname",
conventions.AttributeOSType: "darwin",
}

assert.Equal(t, expected, res.Attributes().AsRaw())
}

func TestEnableHostID(t *testing.T) {
mdHostname := &mockMetadata{}
mdHostname.On("Hostname").Return("hostname", nil)
mdHostname.On("FQDN").Return("", errors.New("err"))
mdHostname.On("OSType").Return("darwin", nil)
mdHostname.On("HostID").Return("3", nil)

resourceAttributes := CreateDefaultConfig().ResourceAttributes
resourceAttributes.HostID.Enabled = true
detector := &Detector{provider: mdHostname, logger: zap.NewNop(), hostnameSources: []string{"dns", "os"}, resourceAttributes: resourceAttributes}
res, schemaURL, err := detector.Detect(context.Background())
require.NoError(t, err)
Expand Down Expand Up @@ -145,7 +166,6 @@ func TestUseHostname(t *testing.T) {
expected := map[string]any{
conventions.AttributeHostName: "hostname",
conventions.AttributeOSType: "darwin",
conventions.AttributeHostID: "1",
}

assert.Equal(t, expected, res.Attributes().AsRaw())
Expand Down