example

command
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

cmd/example/main.go

Complete example application using the observability package with both metrics and tracing

This example demonstrates:

  • Automatic HTTP metrics and distributed tracing via unified middleware
  • Manual DB operation instrumentation (metrics + tracing)
  • Cache operation instrumentation (metrics + tracing)
  • Custom span creation for business logic
  • Error handling and span status management
  • Graceful shutdown with proper cleanup

Environment Variables Required:

  • APP_NAME: Service name (e.g., "example-api")
  • APP_VERSION: Service version (e.g., "1.0.0")
  • APP_ENV: Environment (development, staging, production)
  • LOG_LEVEL: Logging level (debug, info, warn, error)
  • OBSERVABILITY_METRICS_ENABLED: Enable metrics collection (true/false)
  • OBSERVABILITY_TRACING_ENABLED: Enable distributed tracing (true/false)
  • OBSERVABILITY_OTLP_ENDPOINT: OTLP collector endpoint (e.g., "localhost:4317")

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL