-
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
[exporter-helper] [resource_to_label_conversion] add helper function and expose exporter settings #2060
[exporter-helper] [resource_to_label_conversion] add helper function and expose exporter settings #2060
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2060 +/- ##
==========================================
+ Coverage 92.10% 92.11% +0.01%
==========================================
Files 278 279 +1
Lines 16978 17038 +60
==========================================
+ Hits 15637 15695 +58
- Misses 922 923 +1
- Partials 419 420 +1
Continue to review full report at Codecov.
|
Hi @bogdandrutu can you share your views here regarding the next steps. As discussed yesterdays Collector SIG meeting, the core function is working fine. I need guidance regarding making it a common utility for all exporters. |
Update TODO Help Needed Thanks. |
One option (needs some refactoring) you can do it in metricshelper.ConsumeMetrics: type metricsExporter struct {
*baseExporter
consumer.MetricsConsumer
}
// Delete the current ConsumeMetrics from metricsExporter
// NewMetricsExporter creates an MetricsExporter that records observability metrics and wraps every request with a Span.
func NewMetricsExporter(
cfg configmodels.Exporter,
logger *zap.Logger,
pushMetricsData PushMetricsData,
options ...ExporterOption,
) (component.MetricsExporter, error) {
.......
rc := &requestConsumer{
sender: be.sender,
pusher: pushMetricsData,
}
// Can plugin the resource consumer here if enabled.
cc := &contextConsumer{
name: be.cfg.Name(),
next: rc,
}
return &metricsExporter{
baseExporter: be,
MetricsConsumer: cc,
}, nil
}
type contextConsumer struct {
name string
next consumer.MetricsConsumer
}
func (cc *contextConsumer) ConsumeMetrics(ctx context.Context, md pdata.Metrics) error {
return cc.next.ConsumeMetrics(obsreport.ExporterContext(ctx, cc.name), md)
}
type requestConsumer struct {
sender requestSender
pusher PushMetricsData
}
func (rc *requestConsumer) ConsumeMetrics(ctx context.Context, md pdata.Metrics) error {
req := newMetricsRequest(ctx, md, rc.pusher)
_, err := rc.sender.send(req)
return err
} |
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.
Your option also works, I think requires less work, so even better. We can cleanup later the consumer chain as I proposed.
Thanks. I will send another PR with updated README and your few minor suggestions. |
Not sure I understand, are you going to close this PR and send a new one? |
Sorry, my bad. I will send an update (commit). |
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.
Please rebase
Signed-off-by: Rayhan Hossain <hossain.rayhan@outlook.com>
Signed-off-by: Rayhan Hossain <hossain.rayhan@outlook.com>
Signed-off-by: Rayhan Hossain <hossain.rayhan@outlook.com>
Signed-off-by: Rayhan Hossain <hossain.rayhan@outlook.com>
Signed-off-by: Rayhan Hossain <hossain.rayhan@outlook.com>
Signed-off-by: Rayhan Hossain <hossain.rayhan@outlook.com>
14c92d9
to
96df6b7
Compare
Hi @bogdandrutu, will appreciate a final look from you. |
Signed-off-by: Rayhan Hossain <hossain.rayhan@outlook.com>
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.
Almost LGTM
if dataPoint.IsNil() { | ||
continue | ||
} | ||
newLabelMap.ForEach(func(k, v string) { |
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.
These 3 lines are code duplicate, can have a simple func.
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.
Yea, they look similar but are of different types. From my understanding, for creating a different function we need to introduce some kind of interface/wrapping over these types. I think maybe it's OK to have this simple and straight forward solution rather than making it more complex.
I also found some similar patterns in our existing codebase. your call- would appreciate a second thought.
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 they? You have two StringMap.
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.
Never mind. I got it wrong earlier- I thought about about line 97-100. Thanks, it makes the code nicer. Pushed an update.
) | ||
|
||
// ResourceToLabelSettings defines configuration for converting resource attributes to labels | ||
type ResourceToLabelSettings struct { |
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.
ResourceToTelemetey? We want to extend in the future to do resource to span attributes and log 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.
Same changes applies to With func.
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.
Updated.
Signed-off-by: Rayhan Hossain <hossain.rayhan@outlook.com>
Signed-off-by: Rayhan Hossain <hossain.rayhan@outlook.com>
…RTER_OTLP_TRACES_INSECURE (open-telemetry#2060)
Description:
We need a common helper function which can convert resource attributes to metric labels and be utilized by every exporter. In the linked issue, @bogdandrutu suggested two possible ways- a consumer or a helper function. In this PR, we have both of the consumer and helper function ready. However, I was only able to utilize the helper function for end to end test modifying the
logging
exporter. Every exporter can call this helper function before exporting the metrics to destination.For the consumer setup, I cannot find a place to plug in this in between a processor and an exporter. I think I need more guidance on how we can make it a common utility for all exporters. Thanks in advance.
Link to tracking Issue:
Issue 1359
Testing:
End_To_End Test: Tested manually with
awsecscontainermetrics
receiver andlogging
exporter.Unit test added.