Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update filter interface to process only based on spans #223

Merged
merged 4 commits into from
Nov 22, 2023

Conversation

varkey98
Copy link
Contributor

@varkey98 varkey98 commented Nov 16, 2023

Description

Updating the filter interface to have only a single method, Evaluate. And when calling evaluate, all the relevant attributes/headers are expected to be present as part of the span

Checklist:

  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Any dependent changes have been merged and published in downstream modules

if dataCaptureConfig.RpcBody.Request.Value &&
len(reqBody) > 0 && err == nil {
setTruncatedBodyAttribute("request", reqBody, int(dataCaptureConfig.BodyMaxSizeBytes.Value), span)
if dataCaptureConfig.RpcMetadata.Request.Value {
Copy link
Contributor Author

@varkey98 varkey98 Nov 17, 2023

Choose a reason for hiding this comment

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

@ryanericson @puneet-traceable @tim-mwangi This reordering was required because we now only have a single method in filter interface and the scenario of blocking based on headers was failing since the only call to filter was done on body first.

I think we should make similar changes to all instrumentations so that our issue of allow rule not taking precedence over blocking rules also will be solved.
Or we can pass flowvariable to Evaluate method to specify if we're calling for header eval or body eval

Copy link
Collaborator

Choose a reason for hiding this comment

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

So libtraceable interface only has one method called Evaluate now? Do the conditions that had it split up into various methods no longer apply?

Copy link
Contributor Author

@varkey98 varkey98 Nov 17, 2023

Choose a reason for hiding this comment

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

Yes, libtraceable interface has only one method Evaluate now.

Do the conditions that had it split up into various methods no longer apply?

This I'm not really sure. I looked through the code and couldn't find any reason why we had separate calls (maybe for consistency across agents). In both the cases we call the delegate after the body capture. I'll test with actual apps over the weekend.

Copy link
Contributor Author

@varkey98 varkey98 Nov 19, 2023

Choose a reason for hiding this comment

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

@tim-mwangi I tested with both a net/http app and and a grpc app, both of them are blocking with and w/o body, testing the remaining instrumentations as well

Copy link

codecov bot commented Nov 17, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (ce4d775) 59.03% compared to head (e912b5b) 58.77%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #223      +/-   ##
==========================================
- Coverage   59.03%   58.77%   -0.26%     
==========================================
  Files          55       55              
  Lines        2248     2205      -43     
==========================================
- Hits         1327     1296      -31     
+ Misses        861      850      -11     
+ Partials       60       59       -1     

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

@@ -103,25 +93,14 @@ func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
isMultipartFormDataBody)
}

processingBody := body
if int(h.dataCaptureConfig.BodyMaxProcessingSizeBytes.Value) < len(body) {
processingBody = body[:h.dataCaptureConfig.BodyMaxProcessingSizeBytes.Value]
Copy link
Contributor Author

@varkey98 varkey98 Nov 21, 2023

Choose a reason for hiding this comment

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

dataCaptureConfig.BodyMaxProcessingSizeBytes config is also becoming obsolete as we are using the body stored as span attribute for filter evaluation which uses BodyMaxSizeBytes

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, I'm ok with that.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you help open a ticket to deprecate body max processing size throughout? Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ryanericson ryanericson merged commit 08b9173 into hypertrace:main Nov 22, 2023
3 of 6 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.

3 participants