redis/example/otel/README.md

67 lines
1.9 KiB
Markdown
Raw Normal View History

2021-09-08 15:54:10 +03:00
# Example for go-redis OpenTelemetry instrumentation
2022-10-16 11:11:54 +03:00
This example demonstrates how to monitor Redis using OpenTelemetry and
[Uptrace](https://github.com/uptrace/uptrace). It requires Docker to start Redis Server and Uptrace.
2022-04-13 15:53:17 +03:00
See
[Monitoring Go Redis Performance and Errors](https://redis.uptrace.dev/guide/go-redis-monitoring.html)
2022-04-13 15:53:17 +03:00
for details.
2021-11-05 17:17:17 +03:00
2022-10-16 11:11:54 +03:00
**Step 1**. Download the example using Git:
2021-09-08 15:54:10 +03:00
```shell
2022-10-16 11:11:54 +03:00
git clone https://github.com/go-redis/redis.git
cd example/otel
2021-09-08 15:54:10 +03:00
```
2022-10-16 11:11:54 +03:00
**Step 2**. Start the services using Docker:
2021-09-08 15:54:10 +03:00
```shell
2022-10-16 11:11:54 +03:00
docker-compose pull
docker-compose up -d
2021-09-08 15:54:10 +03:00
```
2022-10-16 11:11:54 +03:00
**Step 3**. Make sure Uptrace is running:
2021-11-05 17:17:17 +03:00
```shell
2022-10-16 11:11:54 +03:00
docker-compose logs uptrace
2021-11-05 17:17:17 +03:00
```
2022-10-16 11:11:54 +03:00
**Step 4**. Run the Redis client example:
2021-11-05 17:17:17 +03:00
```shell
2022-10-16 11:11:54 +03:00
UPTRACE_DSN=http://project2_secret_token@localhost:14317/2 go run client.go
2021-11-05 17:17:17 +03:00
```
2022-10-16 11:11:54 +03:00
**Step 5**. Follow the link from the CLI to view the trace:
```shell
UPTRACE_DSN=http://project2_secret_token@localhost:14317/2 go run client.go
trace: http://localhost:14318/traces/ee029d8782242c8ed38b16d961093b35
```
2022-11-09 16:16:13 +03:00
![Redis trace](./image/redis-trace.png)
2022-10-16 11:28:12 +03:00
You can also open Uptrace UI at [http://localhost:14318](http://localhost:14318) to view available
spans, logs, and metrics.
2022-11-09 16:16:13 +03:00
## Redis monitoring
You can also [monitor Redis performance](https://uptrace.dev/opentelemetry/redis-monitoring.html)
metrics By installing OpenTelemetry Collector.
[OpenTelemetry Collector](https://uptrace.dev/opentelemetry/collector.html) is an agent that pulls
telemetry data from systems you want to monitor and sends it to APM tools using the OpenTelemetry
protocol (OTLP).
When telemetry data reaches Uptrace, it automatically generates a Redis dashboard from a pre-defined
template.
![Redis dashboard](./image/metrics.png)
2021-11-05 17:17:17 +03:00
## Links
2022-10-16 11:11:54 +03:00
- [Uptrace open-source APM](https://uptrace.dev/get/open-source-apm.html)
- [OpenTelemetry Go instrumentations](https://uptrace.dev/opentelemetry/instrumentations/?lang=go)
- [OpenTelemetry Go Tracing API](https://uptrace.dev/opentelemetry/go-tracing.html)