@@ -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/ )
0 commit comments