https://github.com/frigus02/opentelemetry-stdout-tree
OpenTelemetry span exporter, which prints traces in a tree-like format
https://github.com/frigus02/opentelemetry-stdout-tree
Last synced: 19 days ago
JSON representation
OpenTelemetry span exporter, which prints traces in a tree-like format
- Host: GitHub
- URL: https://github.com/frigus02/opentelemetry-stdout-tree
- Owner: frigus02
- License: mit
- Created: 2020-11-19T21:28:27.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2022-08-07T20:25:42.000Z (about 4 years ago)
- Last Synced: 2025-10-20T11:09:26.248Z (10 months ago)
- Language: Rust
- Homepage:
- Size: 75.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://crates.io/crates/opentelemetry-stdout-tree)
[](https://docs.rs/opentelemetry-stdout-tree)
[](https://github.com/frigus02/opentelemetry-stdout-tree/actions?query=workflow%3A%22CI%22)
# opentelemetry-stdout-tree
An stdout exporter implementation for [OpenTelemetry Rust], which prints traces in a tree-like
format.
[opentelemetry rust]: https://github.com/open-telemetry/opentelemetry-rust
```
SE my-awesome-books.com GET /authors/:authorId/boo 500 584ms ==================
IN middleware - expressInit 0 0 =
IN middleware - query 0 0 =
IN middleware - session 0 523ms ================
CL pg-pool.connect 0 303ms =========
CL sessions SELECT sess FROM "session" WHERE sid 0 219ms =======
IN middleware - initialize 0 0 =
IN middleware - authenticate 0 0 =
user authenticated ·
IN request handler - /authors/:authorId/books/:boo 0 59ms ==
CL book-service.book-service POST /graphql 200 59ms ==
SE book-service.book.service POST /graphql 200 0 =
IN query 0 0 =
IN field 2 0 =
unknown: something went wrong ·
IN parse 0 0 =
IN validation 0 0 =
```
## Usage
Configure an OpenTelemetry pipeline and start creating spans:
```rust
use opentelemetry::trace::Tracer as _;
let tracer = opentelemetry_stdout_tree::new_pipeline().install_simple();
tracer.in_span("main", |_cx| {});
```
### Features
The function `install` automatically configures an asynchronous batch exporter if you enable
either the **async-std** or **tokio** feature for the `opentelemetry` crate. Otherwise spans
will be exported synchronously.
## Attribute mapping
The exporter makes use of [OpenTelemetry semantic conventions] to provide more useful output
for known types of spans. Currently supported are:
- HTTP: Shows method, host and path and uses status code to determine errors.
- DB: Shows database name and statement or operation.
- Exception events: shows exception type and message.
[opentelemetry semantic conventions]: https://github.com/open-telemetry/opentelemetry-specification/tree/master/specification/trace/semantic_conventions