-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Allow specifying Collector's own Resource in the config #5402
Allow specifying Collector's own Resource in the config #5402
Conversation
Codecov Report
@@ Coverage Diff @@
## main #5402 +/- ##
==========================================
+ Coverage 90.98% 91.01% +0.02%
==========================================
Files 191 190 -1
Lines 11429 11442 +13
==========================================
+ Hits 10399 10414 +15
+ Misses 811 809 -2
Partials 219 219
Continue to review full report at Codecov.
|
1e74451
to
39c367d
Compare
service/telemetry.go
Outdated
var instanceID string | ||
instanceID = resource[semconv.AttributeServiceInstanceID] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allow users to decide to not have this... or have it empty if they want?
instanceID, ok := resource[semconv.AttributeServiceInstanceID]
if !ok {
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty label values don't work with OpenCensus Prometheus exporter (I didn't dig deep into why, but I tried and the label is just ignored).
Perhaps we can make "empty" string a marker for deleting the label? I.e. you can do this to stop emitting the auto-generated service.instance.id
:
service:
telemetry:
resource:
service.instance.id:
Is this valuable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. You can now provide empty string to suppress built-in attributes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@open-telemetry/collector-approvers I would like opinions on this. Is this a) valuable and b) not-surprising behaviour?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty strings are valid on resource attributes so it does feel a bit like surprising behavior to me.
I don't have a good replacement for this though, only thing I can think of is maybe just service.instance.id: null
? since null attributes are not valid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, null
is probably a better choice. Let me try that.
ab6d9d5
to
9e1bb3b
Compare
@open-telemetry/collector-approvers please review. |
service/telemetry.go
Outdated
// Empty Resource attributes are an indication by the user to suppress and stop | ||
// emitting the particular attribute. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we making an assumption of how users set attributes or adding a feature that allows users to suppress attributes when they want? If it is the latter, a config option specifically for "stop emitting these attributes" might be clearer. If this approach is kept we should document it clearly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adding a feature that allows users to suppress attributes when they want
To suppress attributes that are otherwise automatically included.
If this approach is kept we should document it clearly.
It is documented in the code in the ServiceTelemetry struct.
This is a great addition, can the new feature be documented specifically on opentelemetry.io? There is a section of telemetry in the collector config doc. It doesn't list every config option, but I think adding this feature to the explicitly mentioned options would be good. |
I think we need to look into using https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/cmd/configschema to generate the documentation and see if we can push it to opentelemetry.io (or pull from there). I don't think it is sustainable to document things here in the code and also on the website and keep the docs in sync manually. We can look into it in a separate PR, that's out of the scope for this PR. |
b915b7e
to
4638360
Compare
Resolves open-telemetry#5398 This adds a sub-section in the `service.telemetry` config section where any Resource attributes can be specified. For example we can have the following in the config: service: telemetry: resource: service.instance.id: 01G3EN4NW306AFVGQT5ZYC0GEK service.namespace: onlineshop deployment.environment: production
dc41385
to
a5bd0fd
Compare
@bogdandrutu @mx-psi ok to merge? |
@@ -38,6 +38,13 @@ type Service struct { | |||
type ServiceTelemetry struct { | |||
Logs ServiceTelemetryLogs `mapstructure:"logs"` | |||
Metrics ServiceTelemetryMetrics `mapstructure:"metrics"` | |||
|
|||
// Resource specifies user-defined attributes to include with all emitted telemetry. | |||
// For metrics the attributes become Prometheus labels. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not 100% true, only if the exporter is prometheus.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I can just delete this line to void misleading?
if _, ok := resource[semconv.AttributeServiceVersion]; !ok { | ||
// AttributeServiceVersion is not specified in the config. Use the actual | ||
// build version. | ||
telAttrs[semconv.AttributeServiceVersion] = version.Version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On non-core distros, this will show latest
, right? We probably want to explicitly pass a version on the Collector settings to avoid this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't verified, but I think you are right. This PR didn't change the behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, I missed that this was not introduced by this PR. I will make a note to reproduce and open an issue then. We probably want to get rid of version.Version
entirely and leave passing the version to the builder instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is another semi-related issue: for Agent Management the Supervisor needs a way to fetch the Collector's version.
If we are going to change how versions are embedded in the Collector I want to use the opportunity to see if we can make it fetchable by the Supervisor. A few options:
- Have a manifest file with version number recorded in it and include the manifest in Collector's installation packages.
- Try to fetch version number from executable directly (as a symbol?). Not very desirable since it requires platform specific code.
- Read from CLI by using
--version
flag (not very reliable since the output format is not precisely defined). - Something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I submitted a separate issue for this #5438
Resolves #5398
This adds a sub-section in the
service.telemetry
config section where any Resource attributes can be specified. All specified attributes will included as own metrics labels.If
service.instance.id
is not specified it will be auto-generated. Previouslyservice.instance.id
was always auto-generated, so the default of the new behavior matches the old behavior.For example we can have the following in the config: