Commit 0f3b0c9
authored
Refactor componentattribute and move into service (#13948)
#### Description
This PR splits the code handling component attribute injection,
currently in `internal/telemetry` and
`internal/telemetry/componentattribute`, into three parts:
- the part meant to be called by components to drop unwanted injected
attributes, which remains in `internal/telemetry`;
- the part which handles copying Zap logs to an OTel LoggerProvider
(where injected attributes are surfaced as instrumentation scope
attributes), which is moved into `service/telemetry/otelconftelemetry`,
since this "copying" behavior is specific to the otelconf-based
telemetry provider;
- the rest is moved into `service/internal/componentattribute`.
The main goals of this split are:
- to address #13842, by moving most dependencies of `componentattribute`
into the service
- to prepare for the availability of alternate telemetry providers.
I also rewrote a lot of the attribute injection code along the way:
- Instead of adding an unexported field in `TelemetrySettings` to 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 the `TelemetrySettings` definition back into `component`,
removing the dependency it had on `componentattribute`.
- I completely changed the approach for injection in logs. Instead of a
chain of custom core wrappers with a `withAttributeSet` method, injected
attributes are now set through the standard `zapcore.Core.With` method.
By introducing a custom `ObjectMarshaler`, 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{}` in
`TelemetrySettings`, 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/otelconftelemetry` and
`service/internal/componentattribute`, which hopefully should fill that
gap appropriately.1 parent 8038c69 commit 0f3b0c9
File tree
136 files changed
+837
-1602
lines changed- cmd/mdatagen
- component
- componentstatus
- componenttest
- config
- configauth
- configgrpc
- confighttp
- xconfighttp
- configmiddleware
- connector
- connectortest
- forwardconnector
- xconnector
- exporter
- debugexporter
- exporterhelper
- xexporterhelper
- exportertest
- nopexporter
- otlpexporter
- otlphttpexporter
- xexporter
- extension
- extensionauth/extensionauthtest
- extensioncapabilities
- extensionmiddleware/extensionmiddlewaretest
- extensiontest
- memorylimiterextension
- xextension
- zpagesextension
- internal
- memorylimiter
- telemetry
- componentattribute
- telemetrytest
- processor
- batchprocessor
- memorylimiterprocessor
- processorhelper
- xprocessorhelper
- processortest
- xprocessor
- receiver
- nopreceiver
- otlpreceiver
- receiverhelper
- receivertest
- xreceiver
- scraper
- scraperhelper
- scrapertest
- service
- extensions
- hostcapabilities
- internal
- attribute
- componentattribute
- graph
- obsconsumer
- telemetry
- otelconftelemetry
- telemetrytest
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
136 files changed
+837
-1602
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
65 | 64 | | |
66 | 65 | | |
67 | 66 | | |
68 | 67 | | |
69 | 68 | | |
70 | 69 | | |
71 | | - | |
72 | | - | |
73 | 70 | | |
74 | 71 | | |
75 | 72 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
16 | 14 | | |
17 | 15 | | |
18 | 16 | | |
19 | 17 | | |
20 | 18 | | |
21 | 19 | | |
22 | | - | |
23 | 20 | | |
24 | | - | |
25 | | - | |
26 | 21 | | |
27 | | - | |
28 | 22 | | |
| 23 | + | |
29 | 24 | | |
30 | 25 | | |
31 | 26 | | |
| |||
44 | 39 | | |
45 | 40 | | |
46 | 41 | | |
47 | | - | |
48 | | - | |
49 | 42 | | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
33 | 31 | | |
34 | | - | |
35 | 32 | | |
36 | 33 | | |
37 | 34 | | |
| |||
45 | 42 | | |
46 | 43 | | |
47 | 44 | | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | 45 | | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
8 | 10 | | |
| 11 | + | |
9 | 12 | | |
10 | 13 | | |
11 | 14 | | |
12 | 15 | | |
13 | | - | |
14 | | - | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | | - | |
| 22 | + | |
22 | 23 | | |
23 | | - | |
24 | | - | |
25 | 24 | | |
26 | | - | |
27 | | - | |
28 | | - | |
| 25 | + | |
29 | 26 | | |
30 | | - | |
31 | 27 | | |
32 | 28 | | |
33 | 29 | | |
| |||
44 | 40 | | |
45 | 41 | | |
46 | 42 | | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | 43 | | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
8 | 12 | | |
9 | 13 | | |
10 | 14 | | |
11 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | | - | |
18 | 16 | | |
19 | 17 | | |
20 | 18 | | |
21 | 19 | | |
22 | 20 | | |
23 | 21 | | |
24 | | - | |
25 | 22 | | |
26 | | - | |
27 | 23 | | |
28 | | - | |
29 | 24 | | |
30 | | - | |
31 | 25 | | |
32 | 26 | | |
33 | 27 | | |
| |||
51 | 45 | | |
52 | 46 | | |
53 | 47 | | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | 48 | | |
0 commit comments