{"id":45412703,"url":"https://github.com/genkit-ai/opentelemetry-go-plugin","last_synced_at":"2026-02-22T00:01:19.535Z","repository":{"id":308442974,"uuid":"1032839003","full_name":"genkit-ai/opentelemetry-go-plugin","owner":"genkit-ai","description":"Community plugin to use Opentelemetry with Genkit","archived":false,"fork":false,"pushed_at":"2026-02-16T09:25:44.000Z","size":378,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-02-16T17:28:36.831Z","etag":null,"topics":["genkit","genkit-plugin","go","golang"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/xavidop/genkit-opentelemetry-go","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/genkit-ai.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"xavidop","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":null,"thanks_dev":null,"custom":null}},"created_at":"2025-08-05T23:04:33.000Z","updated_at":"2026-02-16T09:25:46.000Z","dependencies_parsed_at":"2025-08-29T02:17:36.371Z","dependency_job_id":"99991044-b7e4-4fa5-8fb0-bc07a9f05c3f","html_url":"https://github.com/genkit-ai/opentelemetry-go-plugin","commit_stats":null,"previous_names":["xavidop/genkit-opentelemetry-go","genkit-ai/opentelemetry-go-plugin"],"tags_count":29,"template":false,"template_full_name":null,"purl":"pkg:github/genkit-ai/opentelemetry-go-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/genkit-ai%2Fopentelemetry-go-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/genkit-ai%2Fopentelemetry-go-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/genkit-ai%2Fopentelemetry-go-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/genkit-ai%2Fopentelemetry-go-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/genkit-ai","download_url":"https://codeload.github.com/genkit-ai/opentelemetry-go-plugin/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/genkit-ai%2Fopentelemetry-go-plugin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29699335,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-21T23:35:04.139Z","status":"ssl_error","status_checked_at":"2026-02-21T23:35:03.832Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["genkit","genkit-plugin","go","golang"],"created_at":"2026-02-22T00:01:18.795Z","updated_at":"2026-02-22T00:01:19.526Z","avatar_url":"https://github.com/genkit-ai.png","language":"Go","funding_links":["https://github.com/sponsors/xavidop"],"categories":[],"sub_categories":[],"readme":"# Genkit OpenTelemetry Plugin for Go\n\nA comprehensive OpenTelemetry plugin for [Genkit Go](https://genkit.dev/go/docs/) that provides out-of-the-box trace spans, metrics collectors, and logs with the flexibility to bring your own exporters.\n\n## Features\n\n- 🚀 **Out-of-the-box setup** with sensible defaults\n- 📊 **Multiple exporters** - OTLP, Prometheus, Jaeger, Console, and more\n- ⚙️ **Flexible configuration** - use presets or bring your own exporters\n- 🔄 **Environment-aware** - different behavior for dev vs production\n- 📈 **Comprehensive telemetry** - traces, metrics, and structured logs\n\n## Installation\n\n```bash\ngo get github.com/xavidop/genkit-opentelemetry-go\n```\n\n## Quick Start\n\n### Basic Usage\n\nThe simplest way to get started is with the default OTLP configuration:\n\n```go\npackage main\n\nimport (\n    \"context\"\n    \"log\"\n\n    \"github.com/firebase/genkit/go/genkit\"\n    opentelemetry \"github.com/xavidop/genkit-opentelemetry-go\"\n)\n\nfunc main() {\n    ctx := context.Background()\n\n    // Initialize OpenTelemetry plugin with default settings\n    plugin := opentelemetry.New(opentelemetry.Config{\n        ServiceName: \"my-genkit-app\",\n        ForceExport: true, // Export even in development\n    })\n\n    // Initialize Genkit\n    genkit.Init(ctx,\n        genkit.WithPlugins(plugin),\n    )\n\n\n    // Your Genkit flows will now automatically emit telemetry!\n}\n```\n\n### Development Setup\n\nFor development, use the console preset to see telemetry data in your terminal:\n\n```go\notelPlugin := opentelemetry.NewWithPreset(opentelemetry.PresetConsole, opentelemetry.Config{\n    ServiceName: \"my-app-dev\",\n    LogLevel:    slog.LevelDebug,\n    ForceExport: true, // Export even in dev environment\n})\n```\n\n## Examples\n\n### Using Jaeger\n\n```go\njaegerPlugin := opentelemetry.NewWithPreset(opentelemetry.PresetJaeger, opentelemetry.Config{\n    ServiceName: \"my-genkit-app\",\n    ForceExport: true,\n})\n```\n\n### Using Prometheus\n\n```go\nplugin := opentelemetry.NewWithPreset(opentelemetry.PresetPrometheus, opentelemetry.Config{\n    ServiceName:    \"my-genkit-app\",\n    ForceExport:    true,\n    MetricInterval: 15 * time.Second,\n    PrometheusPort: 8081, // Custom port for the /metrics endpoint\n})\n```\n\n### Using OTLP\n\n```go\nplugin := opentelemetry.NewWithPreset(opentelemetry.PresetOTLP, opentelemetry.Config{\n    ServiceName:    \"my-genkit-app\",\n    ForceExport:    true,\n    MetricInterval: 15 * time.Second,\n})\n```\n\n## Production Setup Options\n\n### Generic OTLP Backend\n\n```go\notelPlugin := opentelemetry.New(opentelemetry.Config{\n    ServiceName:  \"my-app\",\n    OTLPEndpoint: \"https://api.your-provider.com\",\n    OTLPUseHTTP:  true,\n    OTLPHeaders: map[string]string{\n        \"authorization\": \"Bearer your-token\",\n    },\n})\n```\n\n### Popular Observability Providers\n\n#### Honeycomb\n\n```go\notelPlugin := opentelemetry.New(opentelemetry.Config{\n    ServiceName:  \"my-app\",\n    OTLPEndpoint: \"https://api.honeycomb.io\",\n    OTLPUseHTTP:  true,\n    OTLPHeaders: map[string]string{\n        \"x-honeycomb-team\": os.Getenv(\"HONEYCOMB_API_KEY\"),\n    },\n})\n```\n\n#### Datadog\n\n```go\notelPlugin := opentelemetry.New(opentelemetry.Config{\n    ServiceName:  \"my-app\",\n    OTLPEndpoint: \"https://trace.agent.datadoghq.com\",\n    OTLPUseHTTP:  true,\n    OTLPHeaders: map[string]string{\n        \"dd-api-key\": os.Getenv(\"DD_API_KEY\"),\n    },\n})\n```\n\n#### New Relic\n\n```go\notelPlugin := opentelemetry.New(opentelemetry.Config{\n    ServiceName:  \"my-app\",\n    OTLPEndpoint: \"https://otlp.nr-data.net\",\n    OTLPUseHTTP:  true,\n    OTLPHeaders: map[string]string{\n        \"api-key\": os.Getenv(\"NEW_RELIC_LICENSE_KEY\"),\n    },\n})\n```\n\n#### Langfuse\n\n```go\n// Build basic auth header value: base64(\"public_key:secret_key\")\nauth := base64.StdEncoding.EncodeToString(\n\t[]byte(os.Getenv(\"LANGFUSE_PUBLIC_KEY\") + \":\" + os.Getenv(\"LANGFUSE_SECRET_KEY\")),\n)\n\notelPlugin := opentelemetry.New(opentelemetry.Config{\n    ServiceName:  \"my-app\",\n    OTLPEndpoint: \"https://cloud.langfuse.com/api/public/otel/v1/traces\", // EU region\n    // OTLPEndpoint: \"https://us.cloud.langfuse.com/api/public/otel/v1/traces\", // US region\n    OTLPUseHTTP:  true,\n    OTLPHeaders: map[string]string{\n        \"Authorization\": \"Basic \" + auth,\n    },\n})\n```\n\n## Local Testing with Docker\n\n### 1. Start the Observability Stack\n\n```bash\n# Clone the repository\ngit clone https://github.com/xavidop/genkit-opentelemetry-go\ncd genkit-opentelemetry-go\n\n# Start Jaeger, Prometheus, and Grafana\ndocker-compose up -d\n```\n\n### 2. Run Your Application\n\n```bash\n# Use the OTLP collector with gRPC (default)\nOTEL_EXPORTER_OTLP_ENDPOINT=localhost:4317 go run your-app.go\n\n# Use the OTLP collector with HTTP\nOTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 go run your-app.go\n\n# Or run the provided examples\ngo run examples/basic/main.go\ngo run examples/jaeger/main.go  \ngo run examples/prometheus/main.go\ngo run examples/otel/main.go\n```\n\n### 3. View Your Data\n\n- **Jaeger UI**: http://localhost:16686 (traces)\n- **Prometheus**: http://localhost:9090 (metrics)\n- **Grafana**: http://localhost:3000 (dashboards, admin/admin)\n\n## Environment Variables\n\nThe plugin respects standard OpenTelemetry environment variables:\n\n```bash\n# OTLP Endpoint - for gRPC (default), use host:port format\nexport OTEL_EXPORTER_OTLP_ENDPOINT=localhost:4317\n\n# OTLP Endpoint - for HTTP, use full URL format  \nexport OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318\n\n# Service name\nexport OTEL_SERVICE_NAME=my-genkit-app\n\n# Headers\nexport OTEL_EXPORTER_OTLP_HEADERS=authorization=Bearer-token\n\n# Protocol (grpc or http/protobuf)\nexport OTEL_EXPORTER_OTLP_PROTOCOL=grpc\n\n# Special endpoints for stdout\nexport OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=stdout\nexport OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=stdout\n```\n\n\n## Configuration Options\n\n### Config Structure\n\n```go\ntype Config struct {\n    // Export even in the dev environment\n    ForceExport bool\n\n    // The interval for exporting metric data (default: 60s)\n    MetricInterval time.Duration\n\n    // The minimum level at which logs will be written (default: Info)\n    LogLevel slog.Leveler\n\n    // Custom trace span exporter (optional)\n    TraceExporter trace.SpanExporter\n\n    // Custom metric exporter (optional)\n    MetricExporter metric.Exporter\n\n    // Custom log handler (optional)\n    LogHandler slog.Handler\n\n    // OTLP endpoint (default: \"localhost:4317\")\n    OTLPEndpoint string\n\n    // Whether to use HTTP instead of gRPC for OTLP (default: false)\n    OTLPUseHTTP bool\n\n    // Headers to include in OTLP requests\n    OTLPHeaders map[string]string\n\n    // Service name for telemetry data (default: \"genkit-service\")\n    ServiceName string\n\n    // Service version for telemetry data\n    ServiceVersion string\n\n    // Additional resource attributes\n    ResourceAttributes map[string]string\n}\n```\n\n## Presets\n\nThe plugin comes with several presets for common scenarios:\n### OTLP (Default)\n```go\notelPlugin := opentelemetry.NewWithPreset(opentelemetry.PresetOTLP)\n```\n\n### Jaeger\n```go\notelPlugin := opentelemetry.NewWithPreset(opentelemetry.PresetJaeger, opentelemetry.Config{\n    OTLPEndpoint: \"http://localhost:14268/api/traces\",\n})\n```\n\n### Prometheus\n```go\notelPlugin := opentelemetry.NewWithPreset(opentelemetry.PresetPrometheus)\n```\n\n### Console (Development)\n```go\notelPlugin := opentelemetry.NewWithPreset(opentelemetry.PresetConsole, opentelemetry.Config{\n    LogLevel: slog.LevelDebug,\n})\n```\n\n## What's Automatically Instrumented\n\nWhen you use this plugin with Genkit, you automatically get:\n\n- **Traces** for all Genkit flows and actions\n- **Metrics** for flow execution times, success/failure rates\n- **Logs** with proper correlation to traces\n- **Custom attributes** for Genkit-specific metadata\n\n## Adding Custom Instrumentation\n\nYou can add your own traces and metrics:\n\n```go\nimport \"go.opentelemetry.io/otel\"\n\n// Get a tracer\ntracer := otel.Tracer(\"my-component\")\n\n// Create a span\nctx, span := tracer.Start(ctx, \"my-operation\")\ndefer span.End()\n\n// Add attributes\nspan.SetAttributes(\n    attribute.String(\"user.id\", userID),\n    attribute.Int(\"batch.size\", batchSize),\n)\n\n// Get a meter for custom metrics\nmeter := otel.Meter(\"my-component\")\ncounter, _ := meter.Int64Counter(\"requests_total\")\ncounter.Add(ctx, 1, metric.WithAttributes(\n    attribute.String(\"method\", \"POST\"),\n))\n```\n\n## Troubleshooting\n\n### Problem: No traces appearing\n\n1. Check if `ForceExport: true` is set in development\n2. Verify the OTLP endpoint is correct\n3. Check network connectivity to your telemetry backend\n4. Look for error logs in your application\n\n### Problem: High memory usage\n\n1. Reduce the `MetricInterval` for more frequent exports\n2. Consider using sampling for traces in high-traffic applications\n3. Check if your telemetry backend is accepting data\n\n### Problem: Missing data\n\n1. Check if your telemetry backend has ingestion limits\n2. Verify the service name matches your expectations\n\n### Getting Help\n\n1. Check the [examples](./examples/) directory\n2. Review the [main documentation](./README.md)\n3. Look at the test files for usage patterns\n4. Open an issue if you find bugs or need features\n\n## Advanced Usage\n\n### Custom Exporters\n\nYou can bring your own exporters:\n\n```go\nimport (\n    \"go.opentelemetry.io/otel/exporters/stdout/stdouttrace\"\n    \"go.opentelemetry.io/otel/exporters/stdout/stdoutmetric\"\n)\n\n// Create custom exporters\ntraceExporter, _ := stdouttrace.New(stdouttrace.WithPrettyPrint())\nmetricExporter, _ := stdoutmetric.New(stdoutmetric.WithPrettyPrint())\n\notelPlugin := opentelemetry.New(opentelemetry.Config{\n    ServiceName:     \"my-app\",\n    TraceExporter:   traceExporter,\n    MetricExporter:  metricExporter,\n    ForceExport:     true,\n})\n```\n\n## Contributing\n\nCheck out the [CONTRIBUTING.md](CONTRIBUTING.md) file for details on how to contribute to this project.\n\n## License\n\nThis project is licensed under the Apache 2.0 License - see the [LICENSE](LICENSE) file for details.\n\n## Related Projects\n\n- [Genkit](https://genkit.dev/) - AI application framework\n- [OpenTelemetry Go](https://opentelemetry.io/docs/languages/go/) - Observability framework\n- [Genkit Google Cloud Plugin](https://genkit.dev/go/docs/plugins/google-cloud/) - Official Google Cloud telemetry plugin\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgenkit-ai%2Fopentelemetry-go-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgenkit-ai%2Fopentelemetry-go-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgenkit-ai%2Fopentelemetry-go-plugin/lists"}