Skip to content

test(telemetry): keep EventStore span assertions anchored in runtime behavior#84

Merged
yordis merged 1 commit intomainfrom
yordis/test-event-store-runtime-spans
Apr 16, 2026
Merged

test(telemetry): keep EventStore span assertions anchored in runtime behavior#84
yordis merged 1 commit intomainfrom
yordis/test-event-store-runtime-spans

Conversation

@yordis
Copy link
Copy Markdown
Member

@yordis yordis commented Apr 16, 2026

  • keep EventStore OpenTelemetry coverage tied to emitted runtime spans instead of handcrafted telemetry payloads
  • keep exception coverage grounded in a real application lookup failure instead of fabricated stop metadata

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 16, 2026

PR Summary

Low Risk
Test-only changes that adjust how telemetry spans are asserted, with no production logic modifications; main risk is increased test flakiness due to runtime supervision/timing.

Overview
Refactors EventStore OpenTelemetry tests to assert against real runtime spans by starting DefaultApp and invoking actual EventStore APIs (append/forward/subscribe/ack/snapshot ops), ensuring span names and attributes match what’s emitted in practice.

Reworks error/exception coverage: adds targeted synthetic tests for internal branches (:stop with :error, :exception events) and validates exception events/handler attachment via a real “unstarted app lookup” failure, with new helpers to reliably await spans and assert exception event attributes.

Reviewed by Cursor Bugbot for commit 6d15172. Bugbot is set up for automated code reviews on this repo. Configure here.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 16, 2026

Warning

Rate limit exceeded

@yordis has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 37 minutes and 53 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 37 minutes and 53 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 30bbaa4b-cebc-4249-9ee0-0db99c19868a

📥 Commits

Reviewing files that changed from the base of the PR and between 146a2a2 and 6d15172.

📒 Files selected for processing (1)
  • test/opentelemetry/event_store_test.exs

Walkthrough

The test refactors OpenTelemetry span tests from synthetic telemetry events to runtime integration tests that start Commanded.DefaultApp and exercise real Commanded.EventStore APIs, adds runtime span/assertion helpers, expands coverage (subscriptions, snapshots, stream ops), and adds exception-span validation.

Changes

Cohort / File(s) Summary
EventStore OpenTelemetry tests
test/opentelemetry/event_store_test.exs
Replaced synthetic :telemetry.execute/3 span generation with a describe "runtime spans" suite that starts Commanded.DefaultApp and drives spans via real Commanded.EventStore calls (append_to_stream, stream_forward, subscribe_to, ack_event, snapshot ops, subscribe/unsubscribe/delete_subscription, missing-stream stream_forward). Updated span name/attribute expectations to reference DefaultApp and added tests for exception-span emission when app is misconfigured.
Test helpers & assertions
test/opentelemetry/event_store_test.exs
Added helpers: assert_receive_span_named/2, receive_span_named/2 for waiting on spans by name, assert_exception_event/3 to inspect emitted exception events, assert_handler_attached/1 to verify telemetry handler registration, plus build_snapshot/1 and unique_subscription_name/0. Removed prior synthetic "error handling" tests.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 I hopped through spans both true and new,

DefaultApp woke and traces grew,
Helpers caught the sneaky error bell,
Streams and subs now tell their tale well,
A carrot toast to tests — hop, review! 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: updating telemetry tests to anchor EventStore span assertions in runtime behavior rather than handcrafted payloads.
Description check ✅ Passed The description is directly related to the changeset, explaining the rationale for moving from handcrafted telemetry payloads to runtime spans and real application lookup failures.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch yordis/test-event-store-runtime-spans

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@test/opentelemetry/event_store_test.exs`:
- Around line 411-421: The test currently unpacks OpenTelemetry events using raw
tuple patterns in assert_exception_event (it calls :otel_events.list(events) and
matches {:event, ...} and {:attributes, ...}), which relies on internal tuple
layout; change this to use the OpenTelemetry record pattern matching or
accessors instead (match the returned event as `#event`{attributes: attrs_tuple}
or use the Event#event.attributes accessor) and then extract attrs_map from that
record before asserting attrs_map[:"exception.type"] == exception_type so the
test uses the public record API and is resilient to layout changes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b4085b71-a115-476a-9efb-632fa651f579

📥 Commits

Reviewing files that changed from the base of the PR and between 7c79d31 and 67f2a46.

📒 Files selected for processing (1)
  • test/opentelemetry/event_store_test.exs

Comment thread test/opentelemetry/event_store_test.exs Outdated
@yordis yordis force-pushed the yordis/test-event-store-runtime-spans branch 2 times, most recently from 146a2a2 to 89f83a7 Compare April 16, 2026 16:40
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
@yordis yordis force-pushed the yordis/test-event-store-runtime-spans branch from 89f83a7 to 6d15172 Compare April 16, 2026 16:49
@yordis yordis merged commit 4d2a1a9 into main Apr 16, 2026
3 checks passed
@yordis yordis deleted the yordis/test-event-store-runtime-spans branch April 16, 2026 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant