1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-02-23 10:53:02 +01:00
Luca Palmieri 7da6ea91ac
Adopt OpenTelemetry's semantic convention (#15)
* Add http.route.

* Align all fields with OpenTelemetry's semantic conventions.

* Add span kind.

* Emit event for errors.
Add OTEL status code.

* Create otel.status_code field as empty.

* Fix errors.

* Add (feature-gated) support for OpenTelemetry span propagation.

* Capture the trace id as an attribute on the span.

* Change message.

* Log the newly-generated trace id if there is no parent context.

* Define a root_span macro as a stepping stone to allow crate users to add their own fields to the root span.

* Add comments.

* mut is no longer necessary.

* Allow users to customise generation of the root span. Split recording fields on span end from emission of log record. Make log record on error optional via feature flag.

* Provide constructor + default implementation.

* Explode into multiple modules.
Fix various paths/private imports in root_span.

* Rename module to root_span_macro.

* Add a new extractor to retrieve the root span.

* Document crate.

* Docs!

* Add section on OTEL.

* Mention actix-web-opentelemetry.

* Add OpenTelemetry example.

* Improve readme.

* Add custom root span example.

Co-authored-by: LukeMathWalker <contact@palmieri.com>
2021-04-25 12:19:27 +01:00

701 B

OpenTelemetry integration

Prerequisites

To execute this example you need a running Jaeger instance.
You can launch one using Docker:

docker run -d -p6831:6831/udp -p6832:6832/udp -p16686:16686 jaegertracing/all-in-one:latest

Running

You can launch this example with

cargo run

An actix-web application will be listening on port 8080.
You can fire requests to it with:

curl -v http://localhost:8080/hello
Hello world!

Traces

You can look at the exported traces in your browser by visiting http://localhost:16686.
Spans will be also printed to the console in JSON format, as structured log records.