Skip to content

feat: add TraceIgnoreStatusCodes option#1089

Merged
giortzisg merged 10 commits intomasterfrom
feat/ignore-status-codes-option
Sep 30, 2025
Merged

feat: add TraceIgnoreStatusCodes option#1089
giortzisg merged 10 commits intomasterfrom
feat/ignore-status-codes-option

Conversation

@giortzisg
Copy link
Contributor

@giortzisg giortzisg commented Sep 19, 2025

Description

Add client option for ignoring traces with specific status codes.

Issues


Note

Adds a client option to ignore tracing for specified HTTP status codes or ranges, with implementation, tests, and an example.

  • API:
    • Add ClientOptions.TraceIgnoreStatusCodes [][]int to configure status codes/ranges to exclude from tracing.
  • Tracing:
    • Implement Span.shouldIgnoreStatusCode() to set SampledFalse and drop transactions when Data["http.response.status_code"] matches configured codes/ranges.
    • Early-return in Span.doFinish() when ignored.
  • Tests:
    • Add comprehensive cases in client_test.go covering empty/missing status, single codes, ranges, mixed lists, and non-int values.
  • Examples:
    • Add _examples/trace-ignore-status-codes/main.go demonstrating configuration and behavior.

Written by Cursor Bugbot for commit efb82ec. This will update automatically on new commits. Configure here.

@giortzisg giortzisg requested a review from cleptric September 19, 2025 07:41
@linear
Copy link

linear bot commented Sep 19, 2025

@codecov
Copy link

codecov bot commented Sep 19, 2025

Codecov Report

❌ Patch coverage is 88.88889% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.90%. Comparing base (b07461a) to head (efb82ec).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
tracing.go 88.88% 4 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1089      +/-   ##
==========================================
- Coverage   86.97%   86.90%   -0.07%     
==========================================
  Files          55       56       +1     
  Lines        6025     6072      +47     
==========================================
+ Hits         5240     5277      +37     
- Misses        641      649       +8     
- Partials      144      146       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@linear
Copy link

linear bot commented Sep 19, 2025

@giortzisg giortzisg requested a review from lcian September 19, 2025 09:41
Copy link
Member

@lcian lcian left a comment

Choose a reason for hiding this comment

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

Implementation looks good to me.

@cleptric cleptric added the Feature Issue type label Sep 22, 2025
cursor[bot]

This comment was marked as outdated.

@giortzisg giortzisg force-pushed the feat/ignore-status-codes-option branch from 58fa879 to 55f3d01 Compare September 25, 2025 08:43
@giortzisg
Copy link
Contributor Author

Going with the span attribute solution in the end, to adhere to getsentry/sentry-docs#15026

cursor[bot]

This comment was marked as outdated.

@giortzisg giortzisg requested a review from cleptric September 26, 2025 07:19
Copy link
Member

@cleptric cleptric left a comment

Choose a reason for hiding this comment

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

Missing the debug log from the spec.

cursor[bot]

This comment was marked as outdated.

Copy link
Member

@cleptric cleptric left a comment

Choose a reason for hiding this comment

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

@giortzisg giortzisg requested a review from lcian September 30, 2025 13:14
@giortzisg giortzisg requested a review from cleptric September 30, 2025 13:15
@giortzisg giortzisg merged commit 8921d3c into master Sep 30, 2025
18 checks passed
@giortzisg giortzisg deleted the feat/ignore-status-codes-option branch September 30, 2025 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature Issue type

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add option to exclude certain HTTP statuses from tracing in SDK

3 participants