-
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
Add singleton flags to factories and standardize attributes #12057
Add singleton flags to factories and standardize attributes #12057
Conversation
If desired, I believe I can split this PR into several smaller PRs. However, I wanted to put this version up in order to show the overall picture. |
0717a5d
to
79e1bcb
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #12057 +/- ##
==========================================
+ Coverage 91.72% 91.88% +0.15%
==========================================
Files 463 465 +2
Lines 24821 25430 +609
==========================================
+ Hits 22767 23366 +599
- Misses 1672 1675 +3
- Partials 382 389 +7 ☔ View full report in Codecov by Sentry. |
I discovered when adding tests that singleton connectors will introduce broader changes into the way we build the graph, since we're wrapping each instance as a specific type of consumer. I've not been able to get it working yet but either way, the additional complexity seems not worth for now. I believe there are some reasons why singleton connectors would be useful but I'm going to propose for now that singleton instances are supported only for receivers and exporters. In the future we can try to add singleton connectors. |
32b1ba7
to
90a4238
Compare
90a4238
to
6a38f9c
Compare
bb19bc7
to
9fc517f
Compare
This PR just cleans up some naming in the `testcomponents` package, so that no component kind has a monopoly on the generic version of a variable or function name. Subset of #12057
9fc517f
to
7772955
Compare
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.
The approach makes sense to me, just one question about naming
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.
Looks good to me.
One thing I don't like about Capabilities
is that a component developer can accidentally 'lie' about their component, which can also happen here. I don't see a great way to do this here without introducing a lot more API, so this seems reasonable enough
256d7c9
to
c498d3e
Compare
Do you have ideas for making the new attributes available to components for use in spans and metrics? (Adding the |
It is the next thing I intend to look into once this is merged. Either as you suggested, or maybe it's possible to save them into the Meter/Tracer providers in some way? |
Subset of #12057 This PR adds a test to validate the expected number of instances of each component. This framework becomes more useful once singleton components are explicitly supported.
98fe10f
to
c72b516
Compare
I will merge this on Monday unless somebody comments, cc @open-telemetry/collector-approvers |
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
@dmitryax will take a look at this before we merge it |
I have a feedback we discuss in the otel collector stability meeting (which may be already address, but want to make sure is documented): We should be able to have internal telemetry (logs/traces/metrics) annotated with the signal type that produces them, so if I fail to parse a message I should know that is the "metrics" pipeline that failed. PS: What I think we discussed is exactly against #11814. I do understand that from a "status" perspective if the main shared gRPC server fails is a fail of all components, but if a message is logged when I process the logs I should know that is about logs. |
I mostly agree with you but I think we need to look at this as two layers:
I think this PR solves (1) and allows for (2) to be a best/recommended practice. (e.g. otlp receiver has a logger w/o signal attribute, but should use We can consider ways to make (2) automatic/natural later, but I think this PR is a big improvement over the current state of things where we incorrectly attribute all logs to the same signal (whichever was created first). |
I do understand the underlying problem you try to solve, but I think this will come with the downside that the signal specific part of the component is not handled correctly (or has to be handled by manually annotating the signal tag to the telemetry). In reality we don't need to share the entire component, but we need to share a "sub-component" which indeed is signal agnostic, for example the "http.Server" part of a receiver. This sub-component is then wrapped in signal specific logic. The current approach is to treat the entire component as shared and not have the Signal annotation available, probably later will manually add that (this is my expectation since I don't see any other way to do this). I would rather go with a different approach which will be to add a concept of a "core/share" component to the factory. |
I'm curious to hear more about your idea but my immediate thoughts:
|
I agree this is a downside, but your proposal leaves the same problem in place. It reduces the scope of the problem slightly at the cost of a lot of refactoring, but fundamentally the same problem remains. Any shared sub-component may have good reason to report telemetry that pertains to one specific signal, so how does the shared sub-component manage this? This still leaves us with manually annotating the signal tag to the telemetry. |
c72b516
to
02f5e8f
Compare
What if we just add another field to It's hard to be convinced that this new public API (Metadata) is required. It feels like just passing a boolean flag back to the factory. It's supposed to be connected to the fact that |
I'm closing this as I no longer believe that adding notions of shared/singleton parts is a realistic solution to all the novel cases. New proposal here: #12217 |
This PR is an extension of #11344 that addresses #11814.
Major changes:
Metadata()
method toreceiver.Factory
,exporter.Factory
andconnector.Factory
(processor.Factory
excluded intentionally as described in Loggers for shared components should not report signal type. #11814). TheseMetadata()
methods returnMetadata
structs, which act similarly toconsumer.Capabilities
in that they are intended as a set of information which describes the components which the factory produces.go.opentelemetry.io/otel/attribute.Set
. This set is used as the ID in the graph, but also as the set of attributes that creates the logger. In the future, the set will be automatically used to describe other aspects of the collector's own telemetry.Minor changes:
Metadata
from the appropriate factory. There is a minor user facing change in that the error message is not wrapped in a "could not build" prefix. I moved the processors to this pattern as well in order to match the other components.