8000 Added new response body size to metrics/traces by almostinf · Pull Request #1801 · grafana/beyla · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Added new response body size to metrics/traces #1801

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

Merged
merged 14 commits into from
Apr 16, 2025

Conversation

almostinf
Copy link
Contributor
@almostinf almostinf commented Apr 6, 2025

Added response body size handling in ebpf/metrics/traces

TODO:

  • Fix failed pipelines
  • Add Integration tests

Closes #1286

@almostinf almostinf requested review from grafsean and a team as code owners April 6, 2025 16:06
@CLAassistant
Copy link
CLAassistant commented Apr 6, 2025

CLA assistant check
All committers have signed the CLA.

@almostinf almostinf force-pushed the feature/response-size branch from 16f6e01 to 9858e85 Compare April 6, 2025 16:20
Copy link
Contributor
@marctc marctc left a comment

Choose a reason for hiding this comment

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

Thanks a lot for this! We probably should update integration tests as well (inred_test.go).

go.mod Outdated
@@ -39,7 +39,6 @@ require (
go.opentelemetry.io/collector/config/confighttp v0.122.1
go.opentelemetry.io/collector/config/configopaque v1.28.1
go.opentelemetry.io/collector/config/configretry v1.28.1
go.opentelemetry.io/collector/config/configtelemetry v0.122.1
Copy link
Contributor
@marctc marctc Apr 7, 2025

Choose a reason for hiding this comment

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

Why is this removed? Did we forget to remove it in our PRs updating OTEL?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought it was missing after go mod tidy && go mod vendor, but I got it back

@@ -44,7 +44,7 @@
"conn": {
"versions": {
"oldest": "1.40.0",
"newest": "1.45.1"
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if we should modify this file manually. It's being updated thru this https://github.com/grafana/go-offsets-tracker

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I updated that file by running the command:

make update-offsets

Is that wrong? btw my current version is go 1.24.2

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I probably did something wrong, I rolled back the changes in the offsets.json file except for adding an offset for net/http.Response.ContentLength

Copy link
codecov bot commented Apr 7, 2025

Codecov Report

Attention: Patch coverage is 93.44262% with 12 lines in your changes missing coverage. Please review.

Project coverage is 68.03%. Comparing base (a8dac3a) to head (39feacf).
Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
pkg/export/otel/metrics.go 75.00% 9 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1801      +/-   ##
==========================================
+ Coverage   67.84%   68.03%   +0.18%     
==========================================
  Files         225      225              
  Lines       22966    23067     +101     
==========================================
+ Hits        15582    15694     +112     
+ Misses       6601     6593       -8     
+ Partials      783      780       -3     
Flag Coverage Δ
integration-test 55.33% <91.80%> (+0.25%) ⬆️
k8s-integration-test 53.57% <85.24%> (+0.24%) ⬆️
oats-test 34.96% <38.25%> (-0.03%) ⬇️
unittests 43.93% <79.78%> (+0.15%) ⬆️

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

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

Copy link
Contributor
@rafaelroquetto rafaelroquetto left a comment

Choose a reason for hiding this comment

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

This is fantastic!!! Thank you so much for this!

sizeof(trace->response_length),
(void *)(resp_ptr + response_length_ptr_pos));

bpf_dbg_printk("response_length %d, offset %d, resp_ptr %lx",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
bpf_dbg_printk("response_length %d, offset %d, resp_ptr %lx",
bpf_dbg_printk("response_length %llu, offset %llu, resp_ptr %llx",

(it's possible other parts of our code carry the same mistake, so I understand if you were just being consistent here)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you, corrected

@@ -45,6 +45,7 @@ typedef struct http_request_trace_t {
u16 status;
connection_info_t conn __attribute__((aligned(8)));
s64 content_length;
s64 response_length;
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be u64, or is the original value being read signed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the original value can be a sign value, -1 is returned when the length is unknown

bpf/headers.go Outdated
@@ -2,4 +2,4 @@

package bpf

import _ "github.com/grafana/beyla/v2/bpf/headers"
import _ "github.com/grafana/beyla/v2/bpf"
Copy link
8000 Contributor

Choose a reason for hiding this comment

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

Sorry about that - hopefully you can rebase once #1808 has been merged

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not a problem, I pulled up the actual main :)

@rafaelroquetto
Copy link
Contributor

make clang-format should fix the clang-format check error.
There's also make install-hooks which installs a pre-commit hook that runs clang-format automatically

@grafsean
Copy link
Contributor

👍 for the minimal docs additions.

@rafaelroquetto
Copy link
Contributor

I see you're still having issues with clang-format, what version are you using? We are using clang-format-19. The error probably stems from some implicit configuration that we should make explicit (not the scope of this PR though).
Let me know if there's any way I can help you with that (for instance, by pulling your branch and raising a PR against it).

@almostinf
Copy link
Contributor Author

@rafaelroquetto yes, I think I was previously running clang-format with version 20, now I installed llvm@19 and the formatting seems to work fine, thanks :)

@almostinf
Copy link
Contributor Author

The precommit hook with a different version of clang replaced my changes and I didn't notice

Copy link
Contributor
@rafaelroquetto rafaelroquetto left a comment

Choose a reason for hiding this comment

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

Amazing @almostinf ! Thank you so much for this, top notch contribution!

982F

@rafaelroquetto rafaelroquetto merged commit ef50447 into grafana:main Apr 16, 2025
16 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.

RED metrics for response size
5 participants
0