Skip to content

Commit ee76205

Browse files
authored
Add few more notes to design docs for Logs (#2694)
1 parent a70affd commit ee76205

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

docs/design/logs.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,22 @@ this crate.
280280
## Performance
281281

282282
// Call out things done specifically for performance
283+
// Rough draft
284+
285+
1. `LogRecord` is stack allocated and not Boxed unless required by the component
286+
needing to store it beyond the logging call. (eg: BatchProcessor)
287+
2. LogRecords's Attribute storage is specially designed struct, that holds up to
288+
five attributes in stack.
289+
3. When passing `LogRecord`s to processor, a mutable ref is passed. This allows
290+
calling multiple processors one after another, without the need for cloning.
291+
4. `Logger` provides a `Enabled` check which can optimize performance when
292+
no-one is interested in the log. The check is passed from `Logger` to the
293+
processor, which may consult its exporter to make the decision. An example use
294+
case - an ETW or user-events exporter can check for the presence of listener and
295+
convey that decision back to logger, allowing appender to avoid even the cost of
296+
creating a `LogRecord` in the first place if there is no listener. This check is
297+
done for each log emission, and can react dynamically to changes in interest, by
298+
enabling/disabling ETW/user-event listener.
283299

284300
### Perf test - benchmarks
285301

@@ -289,6 +305,23 @@ this crate.
289305

290306
// Share ~~ numbers
291307

308+
## Internal logs
309+
310+
OTel itself is instrumented with `tracing` crate to emit internal logs about its
311+
operations. This is feature gated under "internal-logs", and is enabled by
312+
default for all components. The `opentelemetry` provide few helper macros
313+
`otel_warn` etc., which in turn invokes various `tracing` macros like `warn!`
314+
etc. The cargo package name will be set as `target` when using `tracing`. For
315+
example, logs from `opentelemetry-otlp` will have target set to
316+
"opentelemetry-otlp".
317+
318+
The helper macros are part of public API, so can be used by anyone. But it is
319+
only meant for OTel components itself and anyone writing extensions like custom
320+
Exporters etc.
321+
322+
// TODO: Document the principles followed when selecting severity for internal
323+
logs // TODO: Document how this can cause circular loop and plans to address it.
324+
292325
## Summary
293326

294327
- OpenTelemetry Logs does not provide a user-facing logging API.

0 commit comments

Comments
 (0)