-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Refactor componentattribute and move into service #13948
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
Refactor componentattribute and move into service #13948
Conversation
Codecov Report❌ Patch coverage is ❌ Your patch status has failed because the patch coverage (86.12%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #13948 +/- ##
==========================================
- Coverage 91.61% 91.57% -0.05%
==========================================
Files 655 658 +3
Lines 42793 42824 +31
==========================================
+ Hits 39205 39216 +11
- Misses 2765 2784 +19
- Partials 823 824 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Regarding code coverage:
CodeCov doesn't take these uses into account as they are in different modules. |
|
@axw I can't tag you as reviewer but I would appreciate a review from you, notably on how well this fits into the "bring your own SDK" initiative. |
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.
LGTM!
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.
Thanks @jade-guiton-dd, only minor concerns from me.
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.
Appreciate the PR desciption!
|
/easycla |
0f3b0c9
Description
This PR splits the code handling component attribute injection, currently in
internal/telemetryandinternal/telemetry/componentattribute, into three parts:internal/telemetry;service/telemetry/otelconftelemetry, since this "copying" behavior is specific to the otelconf-based telemetry provider;service/internal/componentattribute.The main goals of this split are:
componentattributeinto the serviceI also rewrote a lot of the attribute injection code along the way:
Instead of adding an unexported field in
TelemetrySettingsto store the current set of injected attributes, this set is now stored inside the provider wrappers (which was already partly the case). This allowed me to move theTelemetrySettingsdefinition back intocomponent, removing the dependency it had oncomponentattribute.I completely changed the approach for injection in logs. Instead of a chain of custom core wrappers with a
withAttributeSetmethod, injected attributes are now set through the standardzapcore.Core.Withmethod. By introducing a customObjectMarshaler, we can make injected attributes act like regular Zap fields, while also allowing special handling in the otelzap wrapper core, which will set them as instrumentation scope attributes instead of log record attributes.If I'm not mistaken, this PR should have no externally-visible changes, so no changelog should be necessary. (Except maybe the
_ struct{}inTelemetrySettings, but there was no changelog when we added those elsewhere)Link to tracking issue
Updates #13842
Testing
The large amounts of splitting and refactoring led me to abandon the existing tests, as they would be too hard to adapt. I wrote new tests for the code in
service/telemetry/otelconftelemetryandservice/internal/componentattribute, which hopefully should fill that gap appropriately.