-
Notifications
You must be signed in to change notification settings - Fork 1
Add tracing support with OpenTelemetry #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #58 +/- ##
============================================
+ Coverage 78.87% 79.38% +0.50%
- Complexity 362 408 +46
============================================
Files 36 39 +3
Lines 1302 1470 +168
Branches 164 185 +21
============================================
+ Hits 1027 1167 +140
- Misses 190 201 +11
- Partials 85 102 +17 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
WalkthroughAdds OpenTelemetry tracing: new SpanCollector and SpanData DTO, integrates span collection into request logging and filter, exposes tracing flag in RequestLoggingConfig, renames ApitallyAppender to LogAppender, introduces ApitallySpanCollector bridge, updates ApitallyClient, and adds OpenTelemetry SDK dependency and related tests. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@src/main/java/io/apitally/common/ApitallyClient.java`:
- Around line 89-92: Currently ApitallyClient constructs SpanCollector with a
computed boolean (requestLoggingConfig.isEnabled() &&
requestLoggingConfig.isTracingEnabled()); change it to pass the full
RequestLoggingConfig instance instead so SpanCollector can read config at
runtime. Update the instantiation in ApitallyClient to new
SpanCollector(requestLoggingConfig) and modify the SpanCollector
constructor/signature to accept a RequestLoggingConfig (and internally evaluate
isEnabled/isTracingEnabled as needed), removing reliance on the precomputed
boolean; preserve existing semantics while enabling future runtime config
access.
In `@src/main/java/io/apitally/spring/ApitallySpanCollector.java`:
- Around line 33-47: The IllegalStateException branch in
initializeTracer(SpanCollector spanCollector) sets tracer from
GlobalOpenTelemetry but never informs users that the local SpanProcessor (this)
cannot be registered against an already-built provider; update that branch to
log a warning via logger.warn explaining that OpenTelemetry was already
configured, the local SdkTracerProvider/SdkSpanProcessor could not be attached
(so onStart/onEnd won't run), and that we're using the pre-existing tracer
instead, then proceed to set the tracer on spanCollector
(SpanCollector.setTracer(tracer)); reference initializeTracer,
SdkTracerProvider, GlobalOpenTelemetry, spanCollector, and logger in your
change.
🧹 Nitpick comments (1)
src/test/java/io/apitally/spring/app/TestController.java (1)
56-59: Consider using try-finally for proper span lifecycle.While this is test code, using try-finally ensures the span is always ended, even if an exception occurs. This also demonstrates the recommended pattern for span management.
Suggested improvement
Tracer tracer = GlobalOpenTelemetry.getTracer("test"); Span childSpan = tracer.spanBuilder("fetchItemFromDatabase").startSpan(); - childSpan.setAttribute("item.id", id); - childSpan.end(); - - TestItem item = new TestItem(id, "bob"); + try { + childSpan.setAttribute("item.id", id); + } finally { + childSpan.end(); + } + TestItem item = new TestItem(id, "bob");
Summary by CodeRabbit
New Features
Configuration
Refactor
Tests
✏️ Tip: You can customize this high-level summary in your review settings.