Skip to content

Commit 0049a4f

Browse files
committed
docs: start doc for distributed tracing and logs guidance
1 parent c7e47de commit 0049a4f

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

docs/logs.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# OpenTelemetry Rust Logs
2+
3+
Status: **Work-In-Progress**
4+
5+
## Introduction
6+
7+
This document provides comprehensive guidance on leveraging OpenTelemetry
8+
logs in Rust applications.
9+
10+
## Instrumentation Guidance
11+
12+
// TODO
13+
// Draft points to cover
14+
1. OTel Log-Bridge API is not meant for end-users
15+
2. End users must use existing logging API and bridge them.
16+
3. Recommend `tracing`
17+
4. Recommendation about Name, Target, Message
18+
5. add more.

docs/traces.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# OpenTelemetry Rust Traces
2+
3+
Status: **Work-In-Progress**
4+
5+
## Introduction
6+
7+
This document provides comprehensive guidance on leveraging OpenTelemetry traces
8+
in Rust applications.
9+
10+
## Instrumentation Guidance
11+
12+
1. **Use OTel API for distributed traces**
13+
14+
Use the `opentelemetry::trace` API to create spans. This supports context
15+
propagation, span kinds (server/client), links, and remote parents.
16+
17+
2. **Use tracing for logs/events**
18+
19+
Use `tracing::info!`, `tracing::event!`, etc. for structured logging. This
20+
will be converted to OTel LogRecords via opentelemetry-appender-tracing and
21+
will be automatically correlated with the current active OTel trace context
22+
as well.
23+
24+
3. **In-proc contextual enrichment for logs/events**
25+
26+
This is not something OTel has a spec-ed out solution for. This is very
27+
specific to the logging library (tracing) and its bridge.
28+
29+
Use `tracing::span!` macros to add contextual metadata (e.g., filename) that
30+
applies to a group of logs. The `otel-appender-tracing` crate will be
31+
enhanced to extract span attributes and attach them to logs automatically.
32+
33+
4. **If using tracing::span! to create spans**
34+
35+
This is not directly supported by OpenTelemetry. Use the
36+
`tracing-opentelemetry` bridge to convert tracing spans into OTel spans.
37+
38+
There are some limitations with this approach arising due to `tracing`s lack of support for
39+
creating Spans following OpenTelemetry specification. Examples include
40+
- Cannot set remote parent
41+
- Cannot specify span kind (e.g., server/client)
42+
- Cannot add span links
43+
44+
The bridge offers extension APIs to support some of these, but they are not
45+
standard and are maintained outside the OpenTelemetry and Tracing project and
46+
within the bridge itself.
47+
48+
TODO: Should we make a recommendation about
49+
avoiding this extension APIs for instrumentation?
50+
51+
5. **Use instrumentation libraries when possible**
52+
53+
If you're manually creating `tracing::span!` and converting to OTel span for
54+
"edge" spans, consider using official instrumentation libraries where
55+
available. These handle proper span creation and context propagation using
56+
the OpenTelemetry API directly.

0 commit comments

Comments
 (0)