feat: [#726][Metric] Add OpenTelemetry Tracing Support for Distributed Tracing [2]#1293
feat: [#726][Metric] Add OpenTelemetry Tracing Support for Distributed Tracing [2]#1293krishankumar01 merged 25 commits intomasterfrom
Conversation
There was a problem hiding this comment.
⚠️ Performance Alert ⚠️
Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.50.
| Benchmark suite | Current: c653f2b | Previous: 18d63ba | Ratio |
|---|---|---|---|
Benchmark_Fatal |
0.0000023 ns/op 0 B/op 0 allocs/op |
3e-7 ns/op 0 B/op 0 allocs/op |
7.67 |
Benchmark_Fatal - ns/op |
0.0000023 ns/op |
3e-7 ns/op |
7.67 |
This comment was automatically generated by workflow using github-action-benchmark.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1293 +/- ##
==========================================
+ Coverage 66.93% 69.01% +2.07%
==========================================
Files 275 278 +3
Lines 19761 16071 -3690
==========================================
- Hits 13227 11091 -2136
+ Misses 6062 4506 -1556
- Partials 472 474 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR adds OpenTelemetry metrics support to the existing distributed tracing implementation, refactors code organization by consolidating exporter logic, and updates configuration structures to support both traces and metrics.
- Introduces metric collection capabilities alongside existing trace functionality
- Refactors timeout configuration from int (milliseconds) to time.Duration for better type safety
- Consolidates trace exporter logic from separate files into trace.go
Reviewed changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| telemetry/metric.go | Adds new metric provider implementation with OTLP and console exporters (OTLP implementation incomplete) |
| telemetry/trace.go | Consolidates trace exporter creation logic previously in exporter.go, implements factory pattern for custom exporters |
| telemetry/shutdown.go | Introduces shutdown utilities for graceful cleanup of telemetry providers |
| telemetry/config.go | Adds metrics configuration structures, changes Timeout from int to time.Duration, adds custom exporter Via field |
| telemetry/resource.go | Updates to accept full Config instead of ServiceConfig, adds support for custom resource attributes, makes service name required |
| telemetry/application.go | Integrates both trace and meter providers, implements unified shutdown for multiple providers |
| telemetry/resource_test.go | Enhances tests for new resource requirements including service name validation and custom attributes |
| telemetry/trace_test.go | Moves TracerProvider tests from application_test.go, updates to reflect configuration changes |
| telemetry/application_test.go | Updates tests to include required service name in configurations |
| telemetry/setup/stubs.go | Updates configuration template with metrics support, separate trace/metric exporters, and new resource attributes |
| contracts/telemetry/telemetry.go | Extends interface with Meter and MeterProvider methods for metrics support |
| mocks/telemetry/Telemetry.go | Regenerates mocks to include new meter-related interface methods |
| errors/list.go | Adds new error types for validation (service name, zipkin endpoint, via field requirements) |
| go.mod, go.sum | Updates OpenTelemetry dependencies to support metrics SDK |
Comments suppressed due to low confidence (2)
telemetry/trace_test.go:42
- The Timeout field is being set to an integer value (5000) but the ExporterEntry.Timeout field is now defined as time.Duration in config.go. This will be interpreted as 5000 nanoseconds instead of the intended 5000 milliseconds. Use time.Duration with proper units, such as 5000 * time.Millisecond or 5 * time.Second.
telemetry/trace_test.go:161 - The Timeout field is being set to an integer value (5000) but the ExporterEntry.Timeout field is now defined as time.Duration in config.go. This will be interpreted as 5000 nanoseconds instead of the intended 5000 milliseconds. Use time.Duration with proper units, such as 5000 * time.Millisecond or 5 * time.Second.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 17 out of 18 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
hwbrzzl
left a comment
There was a problem hiding this comment.
Great job. Do you need a platform to test the trace and metric?
On my local, I’ve tested using Docker with the following:
And a console driver for all. But we can test it on a deployed application also |
Great, could you add some screenshots in the description? |
@hwbrzzl I’ve resolved the comments and also added the screenshots. Could you please re-review it? |
…d Tracing [2] (#1293) * add metric methods to telemetry interface * optimise trace configuration * optimise tracer setting * add meter provider skelton * fix test cases * make service name mandatory in resources * add resource key to add additional resources * add resource key to add additional resources * add custom driver for metric * add custom driver for trace * optimise resources * fix test cases * optimise config stub * remove parse headers * remove extra space from config stub * implement otlp metric exporter * optimise trace custom exporter logic * optimise metric custom exporter logic * add test cases for metric feature * resolve copilot comments * add comments in stub * remove instance_id * optimise comments for config stub * remove providers * optimise test cases
📑 Description
RelatedTo goravel/goravel#726
Summary
Introduces Metric Telemetry support to the framework, completing the observability triad. This PR provides a flexible way to collect and export application metrics using the OpenTelemetry SDK.
Features:
sdkmetric.Readerinstances or factory functionscumulativevsdeltatemporalityNote
This PR includes full support for Custom Drivers, allowing integration with specialized backends or custom reader implementations via the
viaconfiguration key.Usage
Configuration (
config/telemetry.go)Recording Metrics
Custom Driver Implementation
Shutdown
Configuration Reference
metrics.exporter""(Disabled)otlp,console,custommetrics.reader.interval60exporters.{name}.metric_temporalitycumulativecumulative,deltaexporters.{name}.protocolhttp/protobufgrpc,http/protobufScreenshots
Trace in JaegerUI
Metrics in Grafana (via Prometheus)
✅ Checks