Repository navigation
Conversation
PR SummaryIntroduces OTEL instrumentation for Commanded EventStore operations, with explicit opt-in configuration.
Written by Cursor Bugbot for commit 3f26c90. This will update automatically on new commits. Configure here. |
|
Caution Review failedThe pull request is closed. 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 EventStore OpenTelemetry instrumentation: new Changes
Sequence Diagram(s)sequenceDiagram
participant ES as EventStore (operation)
participant TEL as :telemetry
participant HND as Commanded.OpenTelemetry.EventStore
participant OT as OpenTelemetry API
ES->>TEL: emit [:commanded, :event_store, action, :start]
TEL->>HND: handle start event
HND->>HND: extract metadata & build attributes
HND->>OT: start_span(name, attributes)
ES->>TEL: emit [:commanded, :event_store, action, :stop]
TEL->>HND: handle stop event
HND->>HND: resume span, attach error attrs if present
HND->>OT: set_status_if_error(), end_span()
ES->>TEL: emit [:commanded, :event_store, action, :exception]
TEL->>HND: handle exception event
HND->>HND: normalize exception, record details, set error attrs
HND->>OT: record_exception(), set_error_status(), end_span()
Estimated Code Review Effort🎯 4 (Complex) | ⏱️ ~45 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. ✨ Finishing touches
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 |
02337d8 to
0ea2229
Compare
5b3f1d8 to
a4b536c
Compare
b4eafb7 to
897f6a2
Compare
9a328cb to
b012f60
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@test/support/factory.ex`:
- Around line 949-959: Group all clauses of build_telemetry_event/2 by moving
the block of event_store_* clauses (for example
build_telemetry_event(:event_store_append_to_stream_start, opts) and the other
build_telemetry_event(:event_store_*, opts) functions) so they appear
immediately after the existing build_telemetry_event clauses and before
build_account_scenario, ensuring no other unrelated function definitions sit
between them; this will remove the compiler warning about scattered clauses.
♻️ Duplicate comments (6)
test/support/test_domain.ex (1)
8-44: Consider removing@derive Jason.Encoderif unused by OpenTelemetry tests.The
Jason.Encoderderivations were flagged in a previous review. The OpenTelemetry instrumentation doesn't appear to serialize these structs to JSON—span attributes use atomic values directly. If these derivations are indeed unused, consider removing them to keep the PR focused.test/opentelemetry/event_store_test.exs (2)
8-8: VerifyCommanded.OpenTelemetryCasemodule name matches the actual definition.A previous review flagged a potential mismatch between
Commanded.OpenTelemetryCaseused here andCommanded.OpenTelemetry.Casein the support file. Ensure the module names are consistent.
15-26:@eventslist is duplicated across multiple files.This list is duplicated in the implementation module and test files. A previous review suggested consolidating this to reduce maintenance burden when adding new event types.
lib/commanded/opentelemetry/event_store.ex (3)
13-24:@eventslist is duplicated across multiple files.This list is duplicated in the test file and factory test file. Consider exposing this as a public function or module attribute to allow tests to reference it directly.
26-42: Missing event store telemetry handler cleanup in shared test case.A previous review noted that
OpenTelemetryCasedoesn't include event_store events in its detachment list. The tests work around this with per-testdetach_handlers, but adding cleanup to the shared case would be more robust.
186-189: Inconsistent nil guard inextract_source_uuid.The first clause guards against
nilwithwhen not is_nil(uuid), but the second clause for nested snapshot data lacks this guard. This was flagged in a previous review and creates inconsistent behavior.
🧹 Nitpick comments (1)
test/opentelemetry/event_store_test.exs (1)
359-365: Accessing internal tuple structures of OTel events is fragile.The test relies on the internal structure of OpenTelemetry event tuples (
{:event, _timestamp, :exception, attrs_tuple}and{:attributes, _, _, _, attrs_map}). These internal representations may change between library versions.Consider using the public API or record accessors if available, or add a comment acknowledging this coupling to internal structures.
0fa874b to
8ce2a61
Compare
63eaa7b to
985e8e3
Compare
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
No description provided.