Conversation
PR SummaryAdds application-level tracing for command dispatch with OpenTelemetry and updates configuration/tests accordingly.
Written by Cursor Bugbot for commit b5e979f. This will update automatically on new commits. Configure here. |
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (6)
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughAdds OpenTelemetry instrumentation for Commanded application dispatch: registers telemetry handlers for dispatch start/stop/exception, extracts/propagates trace context, starts/ends consumer spans with messaging/code/commanded attributes, and records errors/exceptions and span status. Changes
Sequence Diagram(s)sequenceDiagram
participant App as Commanded App
participant Telemetry as Telemetry Handler
participant OTEL as OpenTelemetry API
participant Span as Span Context
App->>Telemetry: emit [:commanded, :application, :dispatch, :start] (meta)
Telemetry->>OTEL: extract trace context from meta
OTEL->>Span: start consumer span "dispatch {handler}" with attributes
note right of Span: messaging, code, commanded attrs
App->>Telemetry: emit [:commanded, :application, :dispatch, :stop] (meta)
Telemetry->>Span: restore span, record error attrs if present
Span->>Span: set status / end
rect rgba(255, 0, 0, 0.5)
App->>Telemetry: emit [:commanded, :application, :dispatch, :exception] (kind, reason, stacktrace)
Telemetry->>Span: restore span, set exception attrs, record exception, set error status
Span->>Span: end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
e1da358 to
cea7eab
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@test/opentelemetry/application_test.exs`:
- Around line 273-276: Replace the raw tuple pattern matching when inspecting
span events with the public record syntax and conversion utilities: use
:otel_events.list(events) to get events, find the exception event using the
event record pattern (e.g., event(name: :exception) or matching event(name: n)
and checking n == :exception) instead of matching {:event, ...}, then extract
attributes via the event(attributes: exc_attrs) record and convert to a map with
:otel_attributes.map(exc_attrs). Update references to the variables
exception_event and attrs_map accordingly so tests use event(...) records and
:otel_attributes.map/1 rather than raw tuple destructuring.
🧹 Nitpick comments (2)
test/opentelemetry/application_test.exs (2)
52-63: Consider adding anidempotent_setupor guard.The "fail fast" behavior via
MatchErroris documented here as intentional, but in production this could cause issues ifsetup/0is accidentally called twice during application startup. Consider whether a guard check or explicit error with a helpful message would be more user-friendly.
108-112: Redundant setup block.This nested
setupduplicates the outer setup block (lines 10-17). The detach and setup are already performed before each test by the outer setup.♻️ Suggested fix
Remove this redundant setup block since the outer setup already handles handler initialization:
describe "error handling" do - setup do - detach_handlers() - OTelApplication.setup() - :ok - end - test "sets error status when dispatch returns error in stop" do
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
No description provided.