Skip to content

Enrichment status code #2178#2213

Open
hectar-glitches wants to merge 10 commits into
open-telemetry:mainfrom
hectar-glitches:enrichment-status-code
Open

Enrichment status code #2178#2213
hectar-glitches wants to merge 10 commits into
open-telemetry:mainfrom
hectar-glitches:enrichment-status-code

Conversation

@hectar-glitches

Copy link
Copy Markdown
Contributor

Summary

Add HTTP response status code matching to enrichment rules

Closes #2178

Add http_response_status_code to the enrichment rule block, allowing rules to filter by response status code range. This lets users capture HTTP body data only for specific responses (e.g. 5xx errors) without dropping entire traces.

Validation

@hectar-glitches hectar-glitches requested a review from a team as a code owner June 1, 2026 16:21
@codecov

codecov Bot commented Jun 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 44.44444% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.91%. Comparing base (db7eae0) to head (a37aeee).

Files with missing lines Patch % Lines
pkg/ebpf/common/http/http_enrichment.go 20.00% 20 Missing ⚠️
pkg/config/payload_extraction.go 75.00% 4 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2213      +/-   ##
==========================================
+ Coverage   67.52%   68.91%   +1.39%     
==========================================
  Files         320      320              
  Lines       42409    42446      +37     
==========================================
+ Hits        28635    29252     +617     
+ Misses      12148    11489     -659     
- Partials     1626     1705      +79     
Flag Coverage Δ
integration-test 50.19% <44.44%> (+4.20%) ⬆️
integration-test-arm 27.47% <0.00%> (-0.75%) ⬇️
integration-test-vm-5.15-lts ?
integration-test-vm-6.18-lts ?
k8s-integration-test 37.96% <0.00%> (+0.08%) ⬆️
oats-test 36.35% <0.00%> (-0.14%) ⬇️
unittests 61.98% <36.11%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread pkg/config/payload_extraction.go Outdated
Enrichment EnrichmentConfig `yaml:"enrichment"`
}

type HTTPResponseStatusCodeRange struct {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

question: should we reuse MatchDefinition in pkg/filter/matcher.go which is more complete and already implemented?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I will use MatchDefinition, i had not noticed it earlier

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

seems like there's an import cycle, we should probably move MatchDefinition somewhere else (maybe config?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

on it

Comment thread pkg/config/payload_extraction.go Outdated
URLPathPatterns []services.GlobAttr `yaml:"url_path_patterns"`
// Methods is a list of HTTP methods this rule applies to (shared). Empty means all methods.
Methods []HTTPMethod `yaml:"methods"`
// HTTPResponseStatusCode filters this rule to only when the response code matches teh given

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
// HTTPResponseStatusCode filters this rule to only when the response code matches teh given
// HTTPResponseStatusCode filters this rule to only when the response code matches the given

Comment thread pkg/config/payload_extraction.go Outdated
Methods []HTTPMethod `yaml:"methods"`
// HTTPResponseStatusCode filters this rule to only when the response code matches teh given
// range
HTTPResponseStatusCode *HTTPResponseStatusCodeRange `yaml:"http_response_status_code"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: this is already part of an "http_"-named struct, so I would omit the http_ prefix from the field name and yaml tag

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed the http_ prefix — field and yaml tag are now response_status_code.

Comment thread devdocs/config/CONFIG.md Outdated
Comment on lines +776 to +777
| `greater_equals` | `integer` | | Matches if the response status code is greater than or equal to this value |
| `less_equals` | `integer` | | Matches if the response status code is less than or equal to this value |

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

maybe just call these min and max? or is there prior convention on the _equals pattern?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Kept _equals since MatchDefinition in pkg/filter/matcher.go already establishes that convention in this codebase.

@grcevski

Copy link
Copy Markdown
Contributor

@hectar-glitches if you run make lint on the command line you should be able to see the lint errors. I think all other comments are resolved.

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.

Support HTTP response status code matching in HTTP body extraction enrichment rules

4 participants