Debian Codegraph @

docs/rfcs/component-universal-telemetry.md

raw
1 # Pipeline Component Telemetry
2
3 ## Motivation and Scope
4
5 The collector should be observable and this must naturally include observability of its pipeline components. Pipeline components
6 are those components of the collector which directly interact with data, specifically receivers, processors, exporters, and connectors.
7
8 It is understood that each _type_ (`filelog`, `otlp`, etc) of component may emit telemetry describing its internal workings,
9 and that these internally derived signals may vary greatly based on the concerns and maturity of each component. Naturally
10 though, there is much we can do to normalize the telemetry emitted from and about pipeline components.
11
12 Two major challenges in pursuit of broadly normalized telemetry are (1) consistent attributes, and (2) automatic capture.
13
14 This RFC represents an evolving consensus about the desired end state of component telemetry. It does _not_ claim
15 to describe the final state of all component telemetry, but rather seeks to document some specific aspects. It proposes a set of
16 attributes which are both necessary and sufficient to identify components and their instances. It also articulates one specific
17 mechanism by which some telemetry can be automatically captured. Finally, it describes some specific metrics and logs which should
18 be automatically captured for each kind of pipeline component.
19
20 ## Goals
21
22 1. Define attributes that are (A) specific enough to describe individual component [_instances_](https://github.com/open-telemetry/opentelemetry-collector/issues/10534)
23 and (B) consistent enough for correlation across signals.
24 2. Articulate a mechanism which enables us to _automatically_ capture telemetry from _all pipeline components_.
25 3. Define specific metrics for each kind of pipeline component.
26 4. Define specific logs for all kinds of pipeline component.
27
28 ## Attributes
29
30 Traces, logs, and metrics should carry the following instrumentation scope attributes:
31
32 ### Receivers
33
34 - `otelcol.component.kind`: `receiver`
35 - `otelcol.component.id`: The component ID
36 - `otelcol.signal`: `logs`, `metrics`, `traces`, `profiles`
37
38 ### Processors
39
40 - `otelcol.component.kind`: `processor`
41 - `otelcol.component.id`: The component ID
42 - `otelcol.pipeline.id`: The pipeline ID
43 - `otelcol.signal`: `logs`, `metrics`, `traces`, `profiles`
44
45 ### Exporters
46
47 - `otelcol.component.kind`: `exporter`
48 - `otelcol.component.id`: The component ID
49 - `otelcol.signal`: `logs`, `metrics`, `traces`, `profiles`
50
51 ### Connectors
52
53 - `otelcol.component.kind`: `connector`
54 - `otelcol.component.id`: The component ID
55 - `otelcol.signal`: `logs`, `metrics` `traces`
56 - `otelcol.signal.output`: `logs`, `metrics`, `traces`, `profiles`
57
58 Note: The `otelcol.signal`, `otelcol.signal.output`, or `otelcol.pipeline.id` attributes may be omitted if the corresponding component instances
59 are unified by the component implementation. For example, the `otlp` receiver is a singleton, so its telemetry is not specific to a signal.
60 Similarly, the `memory_limiter` processor is a singleton, so its telemetry is not specific to a pipeline.
61
62 These instrumentation scope attributes are automatically injected into the telemetry associated with a component, by wrapping the Logger, TracerProvider, and MeterProvider provided to it.
63
64 ## Auto-Instrumentation Mechanism
65
66 The mechanism of telemetry capture should be _external_ to components. Specifically, we should observe telemetry at each point where a
67 component passes data to another component, and, at each point where a component consumes data from another component. In terms of the
68 component graph, every _edge_ in the graph will have two layers of instrumentation - one for the producing component and one for the
69 consuming component. Importantly, each layer generates telemetry ascribed to a single component instance, so by having two layers per
70 edge we can describe both sides of each handoff independently.
71
72 Telemetry captured by this mechanism should be associated with an instrumentation scope with a name corresponding to the package which implements
73 the mechanism. Currently, that package is `go.opentelemetry.io/collector/service`, but this may change in the future. Notably, this telemetry is not
74 ascribed to individual component packages, both because the instrumentation scope is intended to describe the origin of the telemetry,
75 and because no mechanism is presently identified which would allow us to determine the characteristics of a component-specific scope.
76
77 ### Instrumentation Scope
78
79 All telemetry described in this RFC should include a scope name which corresponds to the package which implements the telemetry. If the
80 package is internal, then the scope name should be that of the module which contains the package. For example,
81 `go.opentelemetry.io/service` should be used instead of `go.opentelemetry.io/service/internal/graph`.
82
83 ### Auto-Instrumented Metrics
84
85 There are two straightforward measurements that can be made on any pdata:
86
87 1. A count of "items" (spans, data points, or log records). These are low cost but broadly useful, so they should be enabled by default.
88 2. A measure of size, based on [ProtoMarshaler.Sizer()](https://github.com/open-telemetry/opentelemetry-collector/blob/9907ba50df0d5853c34d2962cf21da42e15a560d/pdata/ptrace/pb.go#l11).
89 These may be high cost to compute, so by default they should be disabled (and not calculated). This default setting may change in the future if it is demonstrated that the cost is generally acceptable.
90
91 The location of these measurements can be described in terms of whether the data is "consumed" or "produced", from the perspective of the
92 component to which the telemetry is attributed. Metrics which contain the term "produced" describe data which is emitted from the component,
93 while metrics which contain the term "consumed" describe data which is received by the component.
94
95 For both metrics, an `otelcol.component.outcome` attribute with possible values `success`, `failure`, and `refused` should be automatically recorded,
96 based on whether the corresponding function call returned successfully, returned an error originating from the associated component, or propagated an error from a component further downstream.
97
98 Specifically, a call to `ConsumeX` is recorded with:
99 - `otelcol.component.outcome = success` if the call returns `nil`;
100 - `otelcol.component.outcome = failure` if the call returns a regular error;
101 - `otelcol.component.outcome = refused` if the call returns an error tagged as coming from downstream.
102
103 After inspecting the error, the instrumentation layer should tag it as coming from downstream before returning it to the caller. Since there are two instrumentation layers between each pair of successive components (one recording produced data and one recording consumed data), this means that a call recorded with `outcome = failure` by the "consumer" layer will be recorded with `outcome = refused` by the "producer" layer, reflecting the fact that only the "consumer" component failed. In all other cases, the `outcome` recorded by both layers should be identical.
104
105 Errors should be "tagged as coming from downstream" the same way permanent errors are currently handled: they can be wrapped in a `type downstreamError struct { err error }` wrapper error type, then checked with `errors.As`. Note that care may need to be taken when dealing with the `multiError`s returned by the `fanoutconsumer`. If PR #11085 introducing a single generic `Error` type is merged, an additional `downstream bool` field can be added to it to serve the same purpose instead.
106
107 ```yaml
108 otelcol.receiver.produced.items:
109 enabled: true
110 description: Number of items emitted from the receiver.
111 unit: "{item}"
112 sum:
113 value_type: int
114 monotonic: true
115 otelcol.processor.consumed.items:
116 enabled: true
117 description: Number of items passed to the processor.
118 unit: "{item}"
119 sum:
120 value_type: int
121 monotonic: true
122 otelcol.processor.produced.items:
123 enabled: true
124 description: Number of items emitted from the processor.
125 unit: "{item}"
126 sum:
127 value_type: int
128 monotonic: true
129 otelcol.connector.consumed.items:
130 enabled: true
131 description: Number of items passed to the connector.
132 unit: "{item}"
133 sum:
134 value_type: int
135 monotonic: true
136 otelcol.connector.produced.items:
137 enabled: true
138 description: Number of items emitted from the connector.
139 unit: "{item}"
140 sum:
141 value_type: int
142 monotonic: true
143 otelcol.exporter.consumed.items:
144 enabled: true
145 description: Number of items passed to the exporter.
146 unit: "{item}"
147 sum:
148 value_type: int
149 monotonic: true
150
151 otelcol.receiver.produced.size:
152 enabled: false
153 description: Size of items emitted from the receiver.
154 unit: "By"
155 sum:
156 value_type: int
157 monotonic: true
158 otelcol.processor.consumed.size:
159 enabled: false
160 description: Size of items passed to the processor.
161 unit: "By"
162 sum:
163 value_type: int
164 monotonic: true
165 otelcol.processor.produced.size:
166 enabled: false
167 description: Size of items emitted from the processor.
168 unit: "By"
169 sum:
170 value_type: int
171 monotonic: true
172 otelcol.connector.consumed.size:
173 enabled: false
174 description: Size of items passed to the connector.
175 unit: "By"
176 sum:
177 value_type: int
178 monotonic: true
179 otelcol.connector.produced.size:
180 enabled: false
181 description: Size of items emitted from the connector.
182 unit: "By"
183 sum:
184 value_type: int
185 monotonic: true
186 otelcol.exporter.consumed.size:
187 enabled: false
188 description: Size of items passed to the exporter.
189 unit: "By"
190 sum:
191 value_type: int
192 monotonic: true
193 ```
194
195 #### Additional Attribute for Connectors
196
197 Connectors can route telemetry to specific pipelines. Therefore, `otelcol.connector.produced.*` metrics should carry an
198 additional data point attribute, `otelcol.pipeline.id`, to describe the pipeline ID to which the data is sent.
199
200 ### Auto-Instrumented Logs
201
202 Metrics provide most of the observability we need but there are some gaps which logs can fill. Although metrics would describe the overall
203 item counts, it is helpful in some cases to record more granular events. For example, if a produced batch of 10,000 spans results in an error, but
204 100 batches of 100 spans succeed, this may be a matter of batch size that can be detected by analyzing logs, while the corresponding metric
205 reports only that a 50% success rate is observed.
206
207 For security and performance reasons, it would not be appropriate to log the contents of telemetry.
208
209 It's very easy for logs to become too noisy. Even if errors are occurring frequently in the data pipeline, only the errors that are not
210 handled automatically will be of interest to most users.
211
212 With the above considerations, this proposal includes only that we add a DEBUG log for each error, with the attributes from the corresponding
213 metrics as well as the error message and item count. This should be sufficient for detailed troubleshooting but does not impact users otherwise.
214
215 In the future, it may be helpful to define triggers for reporting repeated failures at a higher severity level. e.g. N number of failures in
216 a row, or a moving average success %. For now, the criteria and necessary configurability is unclear so this is mentioned only as an example
217 of future possibilities.
218
219 ### Auto-Instrumented Spans
220
221 It is not clear that any spans can be captured automatically with the proposed mechanism. We have the ability to insert instrumentation both
222 before and after processors and connectors. However, we generally cannot assume a 1:1 relationship between consumed and produced data.
223
224 ## Additional Context
225
226 This proposal pulls from a number of issues and PRs:
227
228 - [Demonstrate graph-based metrics](https://github.com/open-telemetry/opentelemetry-collector/pull/11311)
229 - [Attributes for component instancing](https://github.com/open-telemetry/opentelemetry-collector/issues/11179)
230 - [Simple processor metrics](https://github.com/open-telemetry/opentelemetry-collector/issues/10708)
231 - [Component instancing is complicated](https://github.com/open-telemetry/opentelemetry-collector/issues/10534)