Skip to content

Commit 34837c8

Browse files
authored
docs: Try improve getting started doc (#3299)
1 parent 8b7ae64 commit 34837c8

2 files changed

Lines changed: 48 additions & 13 deletions

File tree

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,12 @@ Project versioning information and stability guarantees can be found
7272

7373
## Getting Started
7474

75-
If you are new to OpenTelemetry, start with the [Stdout
76-
Example](./opentelemetry-stdout/examples/basic.rs). This example demonstrates
77-
how to use OpenTelemetry for logs, metrics, and traces, and display
78-
telemetry data on your console.
75+
If you are new to OpenTelemetry, start with the getting started examples for
76+
[logs](./examples/logs-basic/README.md),
77+
[metrics](./examples/metrics-basic/README.md) or
78+
[traces](./examples/tracing-grpc/README.md). This example demonstrates how to
79+
use OpenTelemetry for logs, metrics, and traces, and display telemetry data on
80+
your console.
7981

8082
For those using OTLP, the recommended OpenTelemetry Exporter for production
8183
scenarios, refer to the [OTLP Example -

examples/logs-basic/README.md

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,50 @@
1-
# OpenTelemetry Log Appender for tracing - Example
1+
# Getting started with OpenTelemetry Rust Logging
22

3-
This example shows how to use the opentelemetry-appender-tracing crate, which is a
4-
[logging
5-
appender](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/glossary.md#log-appender--bridge)
6-
that bridges logs from the [tracing crate](https://tracing.rs/tracing/#events) to
7-
OpenTelemetry. The example setups a LoggerProvider with stdout exporter, so logs
8-
are emitted to stdout.
3+
This example demonstrates the basics of logging with OpenTelemetry in Rust. If
4+
you're new to OpenTelemetry logging, this is a great place to start!
5+
6+
## Understanding OpenTelemetry Logging
7+
8+
**Important**: OpenTelemetry does not provide its own end-user facing logging
9+
API. Instead, it integrates with existing, popular logging libraries in the Rust
10+
ecosystem. This example uses the [tracing
11+
crate](https://docs.rs/tracing/latest/tracing/), one of the most widely-used
12+
logging frameworks in Rust.
13+
14+
The way this works is through a [log appender (or
15+
bridge)](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/glossary.md#log-appender--bridge) - in this case, the `opentelemetry-appender-tracing` crate. The appender
16+
captures logs emitted through the `tracing` crate and forwards them to
17+
OpenTelemetry's logging pipeline.
18+
19+
## What This Example Does
20+
21+
This example:
22+
23+
1. Sets up an OpenTelemetry `LoggerProvider` with resource attributes (like
24+
service name)
25+
2. Configures a **stdout exporter** to output logs to the console (for
26+
simplicity)
27+
3. Bridges the `tracing` crate to OpenTelemetry using
28+
`opentelemetry-appender-tracing`
29+
4. Emits a sample log event using the `tracing` library's `error!` macro
30+
5. Properly shuts down the logging pipeline
31+
32+
**Note on Exporters**: This example uses the stdout exporter for demonstration
33+
purposes. In production scenarios, you would typically use other exporters such
34+
as:
35+
36+
- **OTLP exporter** (`opentelemetry-otlp`) to send logs to an OpenTelemetry
37+
Collector or compatible backend
38+
- Other vendor-specific exporters for your observability platform
939

1040
## Usage
1141

12-
Run the following, and Logs emitted using [tracing](https://docs.rs/tracing/latest/tracing/)
13-
will be written out to stdout.
42+
Run the example to see logs emitted through the `tracing` crate being captured
43+
and output via OpenTelemetry:
1444

1545
```shell
1646
cargo run
1747
```
48+
49+
You'll see the log output in your console, demonstrating how OpenTelemetry
50+
captures and processes logs from the `tracing` library.

0 commit comments

Comments
 (0)