feat: [#726][Trace] Add OpenTelemetry Tracing Support for Distributed Tracing#1283
feat: [#726][Trace] Add OpenTelemetry Tracing Support for Distributed Tracing#1283krishankumar01 merged 29 commits intomasterfrom
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1283 +/- ##
==========================================
- Coverage 69.14% 68.97% -0.18%
==========================================
Files 265 275 +10
Lines 15671 15947 +276
==========================================
+ Hits 10836 10999 +163
- Misses 4368 4476 +108
- Partials 467 472 +5 ☔ 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 claims to add OpenTelemetry tracing support for distributed tracing (issue #726), but the implementation is incomplete. The PR only creates a placeholder file with no actual functionality, no OpenTelemetry dependencies, and no tests.
Key observations:
- Only a single file is added:
contracts/telemetry/telemetry.gocontaining only a package declaration and a placeholder comment - No OpenTelemetry dependencies are added to
go.mod - No actual tracing interfaces, types, or implementation code exists
- No test coverage is provided
💡 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 26 out of 27 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Exporters Configuration | ||
| // | ||
| // Configure exporters for sending telemetry data. | ||
| // Supported drivers: "otlp", "zipkin", "console" |
There was a problem hiding this comment.
The comment says "Supported drivers" but should say "Supported exporters" for consistency with the rest of the configuration comments and the actual setting name ("exporter").
| // Supported drivers: "otlp", "zipkin", "console" | |
| // Supported exporters: "otlp", "zipkin", "console" |
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: ed119d1 | Previous: 9a4a7b4 | Ratio |
|---|---|---|---|
Benchmark_DecryptString |
6361 ns/op 2032 B/op 16 allocs/op |
2082 ns/op 2032 B/op 16 allocs/op |
3.06 |
Benchmark_DecryptString - ns/op |
6361 ns/op |
2082 ns/op |
3.06 |
This comment was automatically generated by workflow using github-action-benchmark.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 27 out of 28 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| "go.opentelemetry.io/otel/attribute" | ||
| "go.opentelemetry.io/otel/sdk/resource" | ||
| semconv "go.opentelemetry.io/otel/semconv/v1.37.0" |
There was a problem hiding this comment.
The import semconv "go.opentelemetry.io/otel/semconv/v1.37.0" is used but this dependency is not declared in go.mod or go.sum. This will cause compilation failures. The semconv package needs to be added as a direct dependency in go.mod.
There was a problem hiding this comment.
Because this is not direct dependency but a subpart of otel#v1.138.0 package
hwbrzzl
left a comment
There was a problem hiding this comment.
Awesome 👍 Two middleware (http/grpc) should be needed, correct? Normally, users don't need to use facades.Telemetry() directly.
telemetry/application.go
Outdated
| propagator propagation.TextMapPropagator | ||
| } | ||
|
|
||
| func NewApplication(cfg config.Config) (*Application, error) { |
There was a problem hiding this comment.
When writing test cases, we have to mock every configuration. Sometimes it's very complicated. Ideally, every module should have its own config interface to fetch configuration, and have a Config struct to be initiated in NewApplication, then the config can be mocked. We can optimized it later if you agree.
There was a problem hiding this comment.
Yeah, that’s why I experimented a bit with the propagator and exporter, you can check that they both expect a config struct. We can follow the same approach, and our service provider should resolve this config struct. If you agree, I can start moving at least this module to that philosophy. Or we can expose a method UnmarshalKey to map a key to a go struct.
There was a problem hiding this comment.
@hwbrzzl I have added a config.go we can follow a similar way to resolve all config
There was a problem hiding this comment.
Yes, use the module's own config instead of facades.Config directly. It's easier to mock.
Yeah, I’ll implement auto-instrumentation in later PRs. |
telemetry/setup/setup.go
Outdated
| telemetryServiceProvider := "&telemetry.ServiceProvider{}" | ||
| modulePath := packages.GetModulePath() | ||
|
|
||
| packages.Setup(os.Args). |
There was a problem hiding this comment.
I think we need to rethink the paths feature. In the code you pass a configPackage, for example:
WithPaths(func(paths configuration.Paths) {
paths.Config("hello")
paths.Facades("new")
})If a user customises paths like this, when they install the cache package it should create the config in the hello directory and the facades in the new directory. But your current stubs only customise moduleName in the path. I’m not sure that’s the right approach, it looks like we need to optimise this before adopting it.
There was a problem hiding this comment.
Let’s optimise this in a later PR.
| "timeout": config.Env("OTEL_EXPORTER_OTLP_TIMEOUT", 10000), | ||
| "traces_timeout": config.Env("OTEL_EXPORTER_OTLP_TRACES_TIMEOUT", ""), |
There was a problem hiding this comment.
Got it. Do we have a plan to add metrics and logs later?
… Tracing (#1283) * init telemetry contracts package * add propagators and telemetry interface * add trace sampler * add test cases * implement telemetry resource * implement exporters * implement application * add telemetry module and binding * add service_provider * add telemetry facade * add telemetry setup * change setup package to main * update go mod * expose propagator method * add alias for common methods * ... * add insecure in grpc * remove unnecessary nil check * make propagator mandatory * optimise telemetry setup * optimise telemetry application * optimise telemetry application * use config struct instead of using config facade * remove support/config * optimise setup.go * optimise telemetry/setup * optimise telemetry/setup

📑 Description
RelatedTo goravel/goravel#726
Summary
Introduces a new
Telemetrymodule providing OpenTelemetry-based distributed tracing for Goravel applications.Features:
Note
Currently It doesn't support custom exporter, I will add this feature in next couple of PR
Usage
Configuration (
.env)Creating Traces
Context Propagation
Shutdown
Configuration Reference
OTEL_TRACES_EXPORTERotlpotlp,zipkin,console,noneOTEL_TRACES_SAMPLER_TYPEalways_onalways_on,always_off,traceidratioOTEL_PROPAGATORStracecontext,baggagetracecontext,baggage,b3,b3multi✅ Checks