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

Enhance resourceprocessor #3

Closed
wants to merge 3 commits into from

Conversation

omrozowicz-splunk
Copy link
Owner

N/A

Comment on lines 102 to 103
ecsConfig := ecs.CreateDefaultConfig()
return ecsConfig
Copy link

Choose a reason for hiding this comment

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

Just for brevity :)

Suggested change
ecsConfig := ecs.CreateDefaultConfig()
return ecsConfig
return ecs.CreateDefaultConfig()

Copy link
Owner Author

Choose a reason for hiding this comment

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

Done

@@ -97,7 +97,6 @@ func createDefaultConfig() component.Config {
Detectors: []string{env.TypeStr},
HTTPClientSettings: defaultHTTPClientSettings(),
Override: true,
Attributes: nil,
Copy link

Choose a reason for hiding this comment

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

We should not drop this config right away. It should be supported for some time as a deprecated option. See https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/exporter/splunkhecexporter/config.go#LL88C2-L88C16 as an example

Comment on lines 29 to 31
"net/http"
"reflect"
"regexp"
Copy link

Choose a reason for hiding this comment

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

These must be in the first group. Linter will complain :)

Copy link
Owner Author

Choose a reason for hiding this comment

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

Done

if _, err = d.metadataProvider.InstanceID(ctx); err != nil {
d.logger.Debug("EC2 metadata unavailable", zap.Error(err))
return res, "", nil
}
Copy link

Choose a reason for hiding this comment

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

why is this removed?

Copy link
Owner Author

Choose a reason for hiding this comment

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

By mistake I think, brought it back

attr.PutStr(conventions.AttributeHostType, meta.InstanceType)
attr.PutStr(conventions.AttributeHostName, hostname)

setResourceAttributes(dictionary, resourceAttributes, attr)
Copy link

Choose a reason for hiding this comment

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

I assume you added this function for easier future maintenance, but setResourceAttributes is hard to read, and we might generate helpers wrapping the if enabled check in the future as it's done for metrics scraping receivers. So I'd suggest keeping it simple for now and writing a bit of boilerplate instead:

if resourceAttributes.CloudAccountID.Enabled {
	attr.PutStr(conventions.AttributeCloudAccountID, meta.AccountID)
}

Copy link
Owner Author

Choose a reason for hiding this comment

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

Thanks! I put this method everywhere, it is really much simpler, as sometimes setting these attributes required some further checks and everything was getting so complicated...

Copy link

@mx-psi mx-psi left a comment

Choose a reason for hiding this comment

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

The approach makes sense to me. I think if you run golangci-lint run --fix it will fix all the import groups

…nfig structure, add and update unit tests, update CHANGELOG, fix copy-paste issues, add DEPRECATION note to attributes option
@omrozowicz-splunk omrozowicz-splunk force-pushed the enhance-resourceprocessor branch from 8f7453c to 655ac75 Compare June 23, 2023 09:06
@github-actions
Copy link

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Jul 21, 2023
@github-actions
Copy link

github-actions bot commented Aug 5, 2023

Closed as inactive. Feel free to reopen if this PR is still being worked on.

@github-actions github-actions bot closed this Aug 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants