Skip to content

feat: auto-set level attribute on spans#2

Merged
loks0n merged 1 commit intomainfrom
feat-level-attribute
Feb 13, 2026
Merged

feat: auto-set level attribute on spans#2
loks0n merged 1 commit intomainfrom
feat-level-attribute

Conversation

@loks0n
Copy link
Contributor

@loks0n loks0n commented Feb 13, 2026

Summary

  • Automatically sets level=error when setError() is called, level=info otherwise
  • Explicit set('level', ...) is never overridden, giving full control when needed
  • Sentry exporter reads from span level instead of hardcoding 'error'

Test plan

  • testFinishSetsLevelInfoByDefault — default is info
  • testFinishSetsLevelErrorWhenErrorSet — error triggers error
  • testFinishDoesNotOverrideExplicitLevel — explicit level preserved
  • testLevelNotSetBeforeFinish — not prematurely set

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced automatic level detection for spans: level defaults to 'error' when an error is captured, otherwise 'info'.
    • Users can explicitly override the level attribute as needed.
    • Sentry exporter now uses dynamic level values from span attributes instead of static defaults.
  • Documentation

    • Added documentation for the level attribute behavior and override examples.

@coderabbitai
Copy link

coderabbitai bot commented Feb 13, 2026

Warning

Rate limit exceeded

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

⌛ 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.

Walkthrough

This pull request implements automatic level attribute assignment for spans. When a span is finished, the level attribute is automatically set to 'error' if an error was captured, or 'info' otherwise, unless explicitly overridden beforehand. The Sentry exporter is updated to use this dynamic level value instead of hardcoding 'error', and the level attribute is excluded from being processed as additional tags or context. Documentation and comprehensive unit tests are added to explain the behavior.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Merge Conflict Detection ⚠️ Warning ❌ Merge conflicts detected (4 files):

⚔️ README.md (content)
⚔️ src/Span/Exporter/Sentry.php (content)
⚔️ src/Span/Span.php (content)
⚔️ tests/SpanTest.php (content)

These conflicts must be resolved before merging into main.
Resolve conflicts locally and push changes to this branch.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: auto-set level attribute on spans' directly and clearly summarizes the main change: automatically setting the level attribute on spans based on error state.

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

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat-level-attribute

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.

@loks0n loks0n force-pushed the feat-level-attribute branch 2 times, most recently from 843c232 to 4ce5193 Compare February 13, 2026 17:58
Set level=error when setError() is called, level=info otherwise.
Explicit level via set('level', ...) is never overridden.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@loks0n loks0n force-pushed the feat-level-attribute branch from 4ce5193 to 6f20b78 Compare February 13, 2026 17:59
@loks0n loks0n merged commit 0284069 into main Feb 13, 2026
7 checks passed
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