Skip to content

Commit 80db9e8

Browse files
committed
more wordings.
1 parent 0049a4f commit 80db9e8

File tree

2 files changed

+55
-12
lines changed

2 files changed

+55
-12
lines changed

docs/logs.md

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,52 @@ Status: **Work-In-Progress**
44

55
## Introduction
66

7-
This document provides comprehensive guidance on leveraging OpenTelemetry
8-
logs in Rust applications.
7+
This document provides guidance on leveraging OpenTelemetry logs
8+
in Rust applications.
9+
10+
## OTel Log Bridge API
11+
12+
The OpenTelemetry Log Bridge API (part of the `opentelemetry` crate) is **not intended
13+
for direct use by application developers**. It is provided for authoring log
14+
appenders that bridge existing logging systems with OpenTelemetry. Bridges for
15+
`tracing` and `log` crates are already available.
916

1017
## Instrumentation Guidance
1118

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.
19+
1. **Use the `tracing` crate**: We strongly recommend using the
20+
[`tracing`](https://crates.io/crates/tracing) crate for structured logging in
21+
Rust applications.
22+
23+
2. **Explicitly provide `name` and `target` fields**: These map to OpenTelemetry's
24+
EventName and Instrumentation Scope respectively, instead of relying on defaults.
25+
26+
3. **For setup details**: See
27+
[`opentelemetry-appender-tracing`](https://docs.rs/opentelemetry-appender-tracing/)
28+
for mapping details and code examples.
29+
30+
```rust
31+
use tracing::error;
32+
error!(
33+
name: "database_connection_failed",
34+
target: "database",
35+
error_code = "CONNECTION_TIMEOUT",
36+
retry_count = 3,
37+
message = "Failed to connect to database after retries"
38+
);
39+
```
40+
41+
## Terminology
42+
43+
OpenTelemetry defines Events as Logs with an EventName. Since every log from the `tracing`
44+
crate has a `name` field that maps to EventName, every log becomes an OpenTelemetry Event.
45+
46+
**Note**: These are **not** mapped to Span Events. If you want to emit Span Events,
47+
use [`tracing-opentelemetry`](https://docs.rs/tracing-opentelemetry/).
48+
49+
## See Also
50+
51+
- [OpenTelemetry Logs
52+
Specification](https://opentelemetry.io/docs/specs/otel/logs/)
53+
- [`tracing` Documentation](https://docs.rs/tracing/)
54+
- [`opentelemetry-appender-tracing`
55+
Documentation](https://docs.rs/opentelemetry-appender-tracing/)

docs/traces.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@ in Rust applications.
2323

2424
3. **In-proc contextual enrichment for logs/events**
2525

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-
2926
Use `tracing::span!` macros to add contextual metadata (e.g., filename) that
3027
applies to a group of logs. The `otel-appender-tracing` crate will be
3128
enhanced to extract span attributes and attach them to logs automatically.
3229

30+
OpenTelemetry does not have a spec-ed out solution for in-process contextual
31+
enrichment. This is very specific to the logging library (tracing) and its
32+
bridge.
33+
3334
4. **If using tracing::span! to create spans**
3435

3536
This is not directly supported by OpenTelemetry. Use the
@@ -48,6 +49,11 @@ in Rust applications.
4849
TODO: Should we make a recommendation about
4950
avoiding this extension APIs for instrumentation?
5051

52+
If you are creating spans to track in-proc work (what OTel calls "internal" spans),
53+
`tracing:span` API is sufficient with `tracing-opentelemetry` bridge converting the
54+
`tracing` Span to OTel Span, and properly activating/de-activating OTel's context,
55+
to ensure correlation.
56+
5157
5. **Use instrumentation libraries when possible**
5258

5359
If you're manually creating `tracing::span!` and converting to OTel span for

0 commit comments

Comments
 (0)