-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[feature request] [exporter] resource_attributes_to_metric_labels - common utility for all Non-OTLP exporters #1359
Comments
@bogdandrutu would you add your recommendation (we discussed in the SIG meeting) here? |
@bogdandrutu We would like to get this completed by middle November. Appreciate your help in advance. |
So we have 2 problems if I understand correctly:
We can start with a consumer that transforms all the type ResourceToLabels struct {
next consumer.MetricsConsumer
}
func (rl *ResourceToLabels) ConsumeMetrics(_ context.Context, md pdata.Metrics) error {
newMd := pdata.NewMetrics()
// initialize newMd with 1 resource (empty), 1 library metrics (empty), and md.MetricsCount() metrics
num := 0
rms := td.ResourceMetrics()
for i := 0; i < rms.Len(); i++ {
resource := rms.At(i).Resource()
if resource.IsNil() {
continue
}
ilms := rss.At(i).InstrumentationLibraryMetrics()
for j := 0; j < ilms.Len(); j++ {
ilm := ilms.At(j)
if ilm.IsNil() {
continue
}
metrics := ils.Metrics()
library := ils.InstrumentationLibrary()
for k := 0; k < metrics.Len(); k++ {
metric := metrics.At(k)
if metric.IsNil() {
continue
}
resourceToLables(resource.Attributes(), metric, dest.At(num))
num++
}
}
}
return rl.next(md)
} This approach as you can see does require a copy of the metrics, because exporters are not allowed to change the incoming metrics data. An alternative is to provide just a helper func in the resourceAndLibraryToLables(resource pdata.Resource, instrumentationInfo pdata.InstrumentationLibrary, metric pdata.Metric) pdata.Metric {
// Returns a copy of the pdata.Metric with all new added labels
// Again important to notice that needs to be a copy because the exporter cannot change metric data.
} Happy to explore more ideas. |
Hi @bogdandrutu , thanks for the quick suggestions. If I understand correctly, you described two different approaches. I am exploring them. Do you have any preference between these two? Also, I saw a comment from @tigrannajaryan in gitter, regarding converting all the resource attributes to labels (to many labels). Are we still on plan to convert all the resource attributes to labels by default. |
@bogdandrutu To add to this. I think all exporters that do not use a format that natively supports a Resource-equivalent concept have to do this. I wonder if my assertion is correct or there need to be exceptions or this behavior needs to be configurable per exporter. |
OTLP and Jaeger don't need this (Jaeger has process tags). But in general yes all of them except these two. |
Working on this. Maybe you can assign this to me. |
I think we should make it configurable. In CloudWatch Metrics Exporter, we only need to add resource labels for ECS Metrics (@hossain-rayhan is working on in this thread) but for the other use cases like customer application metrics, we don't want to enable it by default. CloudWatch only allows maximum 10 dimensions/labels for each metric. We like it to be able to be configured for combining. :) |
Given that the limitations are specific to destinations we likely need this to be a user-definable configuration option for exporters, possibly also maximum limits enforced by each exporter where such limits exist. |
As I mentioned in the PR description, we had a discussion in our first conversation: From yesterdays (10/29) SIG meeting, this feature can be an opt-in option for exporters or maybe we can make if default (not finalized yet). However, I feel like exporter specific logics (limitation to labels/dimensions) should go under exporter configuration. Maybe @bogdandrutu can add more. |
I believe this has reached the level of a specification-level problem. We agree that generally resource attributes should ideally be preserved somehow when exporting metrics, and we acknowledge that: (1) some protocols have a place for resources, which is nice, and (2) some services have a limit on the number of metric attributes (labels) making it infeasible to recommend that, by default, all resources automatically become metric attributes (labels). In metrics systems, it is common to apply resource labels downstream. For example, Prometheus applies target labels associated with metadata from scrape events, and Statsd packets are often aggregated inside an agent with defined resources. In these cases, we do not want to apply resources that will be applied later. However, if using bare statsd to a remote endpoint, resources should be included. Thus, "all resources" is not a good default, but "no resources" is also not a good default. Note that Prometheus just encourages configurability here: Prometheus |
@jmacd thanks for some good points. Reading all these comments, wondering would it be a good idea to have another look to our previous proposed solution (#1337) which extends the It does not modify existing resource attributes rather adds some new metric labels (values are taken from resources). Also, user will have the control to choose which resource attributes they want to convert to metric labels. I don't know if it goes totally against our specification. Or, should we consider writing a whole new processor ( |
Also, to be more specific I am listing all the available options to us- [1] Extend [2] Write a whole new processor ( [3] Write a common utility for all exporters which converts all the resource attributes to metric labels by default. (currently following this one) [4] Write a common utility for all exporters which converts all the resource attributes to metric labels and has the option to select specific resource attributes. [5] Put it in the exporter. Every exporter should decide how they want to make it configureable. one single setting also may help for default option ( I guess these are good options to us and we need to pick one. |
Addressed by this PR 2060 |
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
And update .gitignore, so the built binary does not show up in git status.
Is your feature request related to a problem? Please describe.
Customer needs to convert resource attributes to metric labels and its a pretty common use case. In Wednesdays (10/22) OpenTelemetry Metrics SIG meeting, we took a decision to implement a common utility for all Non-OTLP exporters which will convert all resource attributes to metric labels by default. If customers need to exclude any resource attributes, they can use the
resource
processor.Describe the solution you'd like
@bogdandrutu will help to provide detailed guidelines.
Describe alternatives you've considered
Do it in the
metricstransform
processor- PR [#1337 ].Do it in the receiver- PR [#1284 ].
The text was updated successfully, but these errors were encountered: