1
0
mirror of https://github.com/redis/go-redis.git synced 2026-10-24 07:59:20 +03:00
Files
dependabot[bot] 552379bdb4 chore(deps): bump golang.org/x/sys from 0.48.0 to 0.49.0 (#4090)
* chore(deps): bump golang.org/x/sys from 0.48.0 to 0.49.0

Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.48.0 to 0.49.0.
- [Commits](https://github.com/golang/sys/compare/v0.48.0...v0.49.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-version: 0.49.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore(deps): go mod tidy submodules for x/sys 0.49.0

Example and extra modules still pinned x/sys v0.48.0, so govulncheck
failed with "go mod tidy" in each of them.

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Nedyalko Dyakov <nedyalko.dyakov@gmail.com>
2026-10-12 14:45:31 +03:00
..

OpenTelemetry Metrics Example

This example demonstrates how to enable OpenTelemetry metrics for Redis operations using the extra/redisotel-native package.

Features

  • ✅ OTLP exporter configuration
  • ✅ Periodic metric export (every 10 seconds)
  • ✅ Concurrent Redis operations
  • ✅ Automatic metric collection for:
    • Operation duration
    • Connection metrics
    • Error tracking

Prerequisites

  • Go 1.24.0 or later
  • Redis server running on localhost:6379
  • OTLP collector running on localhost:4317 (optional)

Running the Example

# Start Redis (if not already running)
redis-server

# Optional: Start OTLP collector
# See: https://opentelemetry.io/docs/collector/

# Run the example
go run main.go

What It Does

  1. Creates an OTLP exporter that sends metrics to a collector
  2. Sets up a meter provider with periodic export (every 10 seconds)
  3. Initializes Redis client with OTel instrumentation
  4. Executes concurrent Redis operations (SET commands)
  5. Waits for metrics to be exported

Metrics Collected

The example automatically collects:

  • db.client.operation.duration - Operation latency histogram
  • db.client.connection.create_time - Connection creation time
  • db.client.connection.count - Active connection count
  • db.client.errors - Error counter with error type classification

Configuration

To use with a production OTLP collector:

exporter, err := otlpmetricgrpc.New(ctx,
    otlpmetricgrpc.WithEndpoint("your-collector:4317"),
    otlpmetricgrpc.WithTLSCredentials(credentials.NewClientTLSFromCert(certPool, "")),
)

See Also