Add (optional) OpenTelemetry + Xray integration (#95) (#96)

This introduces all the necessary code to be able to send traces to
AWS Xray via `tracing-opentelemetry`. It can be optionally enabled
using the `xray` feature defined on this crate.

Also update the README.md with instructions on how to enable and use
this.
This commit is contained in:
Bryan Garza
2022-05-18 09:13:19 -07:00
committed by GitHub
parent 4b4ecf0310
commit 6cd697afe9
4 changed files with 106 additions and 6 deletions

View File

@@ -59,6 +59,31 @@ cargo run --bin mini-redis-cli set foo bar
cargo run --bin mini-redis-cli get foo
```
## OpenTelemetry
If you are running many instances of your application (which is usually the case
when you are developing a cloud service, for example), you need a way to get all
of your trace data out of your host and into a centralized place. There are many
options here, such as Prometheus, Jaeger, DataDog, Honeycomb, AWS X-Ray etc.
We leverage OpenTelemetry, because it's an open standard that allows for a
single data format to be used for all the options mentioned above (and more).
This eliminates the risk of vendor lock-in, since you can switch between
providers if needed.
### AWS X-Ray example
To enable sending traces to X-Ray, use the `otel` feature:
```
RUST_LOG=debug cargo run --bin mini-redis-server --features otel
```
This will switch `tracing` to use `tracing-opentelemetry`. You will need to
have a copy of AWSOtelCollector running on the same host.
For demo purposes, you can follow the setup documented at
https://github.com/aws-observability/aws-otel-collector/blob/main/docs/developers/docker-demo.md#run-a-single-aws-otel-collector-instance-in-docker
## Supported commands
`mini-redis` currently supports the following commands.