|
1 |
| -# Example for go-redis OpenTelemetry instrumentation |
| 1 | +# go-redis OpenTelemetry Monitoring with Uptrace |
2 | 2 |
|
3 |
| -This example demonstrates how to monitor Redis using OpenTelemetry and |
4 |
| -[Uptrace](https://github.com/uptrace/uptrace). It requires Docker to start Redis Server and Uptrace. |
| 3 | +This example demonstrates how to instrument and monitor Redis operations in Go applications using |
| 4 | +OpenTelemetry and [Uptrace](https://github.com/uptrace/uptrace), providing comprehensive |
| 5 | +observability into your Redis performance and operations. |
5 | 6 |
|
6 |
| -See |
7 |
| -[Monitoring Go Redis Performance and Errors](https://redis.uptrace.dev/guide/go-redis-monitoring.html) |
8 |
| -for details. |
| 7 | +## Overview |
9 | 8 |
|
10 |
| -**Step 1**. Download the example using Git: |
| 9 | +This integration provides: |
11 | 10 |
|
12 |
| -```shell |
| 11 | +- **Distributed tracing** for Redis operations |
| 12 | +- **Performance monitoring** with latency and throughput metrics |
| 13 | +- **Error tracking** and debugging capabilities |
| 14 | +- **Visual dashboards** for Redis health monitoring |
| 15 | +- **Production-ready** observability stack with Docker |
| 16 | + |
| 17 | +## Prerequisites |
| 18 | + |
| 19 | +- Go 1.19+ |
| 20 | +- Docker and Docker Compose |
| 21 | +- Basic understanding of Redis and OpenTelemetry |
| 22 | + |
| 23 | +## Quick Start |
| 24 | + |
| 25 | +### 1. Clone and Navigate |
| 26 | + |
| 27 | +```bash |
13 | 28 | git clone https://github.com/redis/go-redis.git
|
14 | 29 | cd example/otel
|
15 | 30 | ```
|
16 | 31 |
|
17 |
| -**Step 2**. Start the services using Docker: |
| 32 | +### 2. Start the Monitoring Stack |
| 33 | + |
| 34 | +Launch Redis and Uptrace services: |
18 | 35 |
|
19 |
| -```shell |
20 |
| -docker-compose up -d |
| 36 | +```bash |
| 37 | +docker compose up -d |
21 | 38 | ```
|
22 | 39 |
|
23 |
| -**Step 3**. Make sure Uptrace is running: |
| 40 | +This starts: |
| 41 | + |
| 42 | +- Redis server on `localhost:6379` |
| 43 | +- Uptrace APM on `http://localhost:14318` |
24 | 44 |
|
25 |
| -```shell |
26 |
| -docker-compose logs uptrace |
| 45 | +### 3. Verify Services |
| 46 | + |
| 47 | +Check that Uptrace is running properly: |
| 48 | + |
| 49 | +```bash |
| 50 | +docker compose logs uptrace |
27 | 51 | ```
|
28 | 52 |
|
29 |
| -**Step 4**. Run the Redis client example and Follow the link to view the trace: |
| 53 | +Look for successful startup messages without errors. |
| 54 | + |
| 55 | +### 4. Run the Example |
| 56 | + |
| 57 | +Execute the instrumented Redis client: |
30 | 58 |
|
31 |
| -```shell |
| 59 | +```bash |
32 | 60 | go run client.go
|
| 61 | +``` |
| 62 | + |
| 63 | +You should see output similar to: |
| 64 | + |
| 65 | +``` |
33 | 66 | trace: http://localhost:14318/traces/ee029d8782242c8ed38b16d961093b35
|
34 | 67 | ```
|
35 | 68 |
|
36 |
| - |
| 69 | +Click the trace URL to view detailed operation traces in Uptrace. |
| 70 | + |
| 71 | + |
| 72 | + |
| 73 | +### 5. Explore the Dashboard |
| 74 | + |
| 75 | +Open the Uptrace UI at [http://localhost:14318](http://localhost:14318/metrics/1) to explore: |
| 76 | + |
| 77 | +- **Traces**: Individual Redis operation details |
| 78 | +- **Metrics**: Performance statistics and trends |
| 79 | +- **Logs**: Application and system logs |
| 80 | +- **Service Map**: Visual representation of dependencies |
| 81 | + |
| 82 | +## Advanced Monitoring Setup |
| 83 | + |
| 84 | +### Redis Performance Metrics |
37 | 85 |
|
38 |
| -You can also open Uptrace UI at [http://localhost:14318](http://localhost:14318) to view available |
39 |
| -spans, logs, and metrics. |
| 86 | +For production environments, enable comprehensive Redis monitoring by installing the OpenTelemetry |
| 87 | +Collector: |
40 | 88 |
|
41 |
| -## Redis monitoring |
| 89 | +The [OpenTelemetry Collector](https://uptrace.dev/opentelemetry/collector) acts as a telemetry agent |
| 90 | +that: |
42 | 91 |
|
43 |
| -You can also [monitor Redis performance](https://uptrace.dev/opentelemetry/redis-monitoring.html) |
44 |
| -metrics By installing OpenTelemetry Collector. |
| 92 | +- Pulls performance metrics directly from Redis |
| 93 | +- Collects system-level statistics |
| 94 | +- Forwards data to Uptrace via OTLP protocol |
45 | 95 |
|
46 |
| -[OpenTelemetry Collector](https://uptrace.dev/opentelemetry/collector.html) is an agent that pulls |
47 |
| -telemetry data from systems you want to monitor and sends it to APM tools using the OpenTelemetry |
48 |
| -protocol (OTLP). |
| 96 | +When configured, Uptrace automatically generates a Redis dashboard: |
49 | 97 |
|
50 |
| -When telemetry data reaches Uptrace, it automatically generates a Redis dashboard from a pre-defined |
51 |
| -template. |
| 98 | + |
52 | 99 |
|
53 |
| - |
| 100 | +### Key Metrics Monitored |
| 101 | + |
| 102 | +- **Connection Statistics**: Active connections, connection pool utilization |
| 103 | +- **Command Performance**: Operation latency, throughput, error rates |
| 104 | +- **Memory Usage**: Memory consumption, key distribution |
| 105 | +- **Replication Health**: Master-slave sync status and lag |
| 106 | + |
| 107 | +### Logs and Debugging |
| 108 | + |
| 109 | +View service logs: |
| 110 | + |
| 111 | +```bash |
| 112 | +# All services |
| 113 | +docker compose logs |
| 114 | + |
| 115 | +# Specific service |
| 116 | +docker compose logs redis |
| 117 | +docker compose logs uptrace |
| 118 | +``` |
54 | 119 |
|
55 |
| -## Links |
| 120 | +## Additional Resources |
56 | 121 |
|
57 |
| -- [Uptrace open-source APM](https://uptrace.dev/get/open-source-apm.html) |
58 |
| -- [OpenTelemetry Go instrumentations](https://uptrace.dev/opentelemetry/instrumentations/?lang=go) |
59 |
| -- [OpenTelemetry Go Tracing API](https://uptrace.dev/opentelemetry/go-tracing.html) |
| 122 | +- [Complete go-redis Monitoring Guide](https://redis.uptrace.dev/guide/go-redis-monitoring.html) |
| 123 | +- [OpenTelemetry Go Instrumentation](https://uptrace.dev/get/opentelemetry-go/tracing) |
| 124 | +- [Uptrace Open Source APM](https://uptrace.dev/get/hosted/open-source-apm) |
0 commit comments