Skip to content

Go route harvesting - #889

Merged
grcevski merged 14 commits into
open-telemetry:mainfrom
grcevski:go_route_harvesting
Nov 13, 2025
Merged

Go route harvesting#889
grcevski merged 14 commits into
open-telemetry:mainfrom
grcevski:go_route_harvesting

Conversation

@grcevski

Copy link
Copy Markdown
Contributor

This PR adds extraction of the HTTP routes from Go programs. I've added support for the built-in Go Mux that was introduced in 1.21, Gorilla Mux and Gin. This should cover a lot of the use-cases, the rest of the frameworks will use the regular heuristic matcher.

I also looked into reading the go binary symbol tables and extracting routes like we did for Java, but it proved to not be feasible. We essentially would need to disassemble all of the code and then look for instructions that read the symbol tables, then figure out if those are actually HTTP routes.

Instead my approach uses uprobes in the frameworks to read the route value when they match it internally and determine the handler.

@grcevski
grcevski requested a review from a team as a code owner November 12, 2025 19:52
@codecov

codecov Bot commented Nov 12, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 34.11765% with 56 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.99%. Comparing base (98cc6aa) to head (07a7f58).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
.../test/integration/components/testserver/std/std.go 0.00% 19 Missing ⚠️
...tegration/components/testserver/gorilla/gorilla.go 0.00% 10 Missing ⚠️
...ration/components/testserver/gorillamid/gorilla.go 0.00% 10 Missing ⚠️
.../test/integration/components/testserver/gin/gin.go 0.00% 7 Missing ⚠️
pkg/internal/ebpf/gotracer/gotracer.go 76.00% 5 Missing and 1 partial ⚠️
pkg/ebpf/common/spanner.go 69.23% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #889      +/-   ##
==========================================
- Coverage   55.08%   54.99%   -0.09%     
==========================================
  Files         251      252       +1     
  Lines       21505    21600      +95     
==========================================
+ Hits        11845    11878      +33     
- Misses       8843     8904      +61     
- Partials      817      818       +1     
Flag Coverage Δ
integration-test 23.32% <51.28%> (+<0.01%) ⬆️
integration-test-arm 0.00% <0.00%> (ø)
integration-test-vm-${ARCH}-${KERNEL_VERSION} 0.00% <0.00%> (?)
k8s-integration-test 2.76% <0.00%> (+<0.01%) ⬆️
oats-test 0.00% <0.00%> (ø)
unittests 46.08% <11.76%> (-0.13%) ⬇️

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.

Comment thread bpf/gotracer/go_grpc.c

// Get method from the incoming call arguments
if (!read_go_str_n("method", method_ptr, (u64)method_len, &trace->path, sizeof(trace->path))) {
if (!read_go_str_n("method", method_ptr, (u64)method_len, trace->path, sizeof(trace->path))) {

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.

nice catch!

Comment thread bpf/gotracer/go_nethttp.c
req,
go_offset_of(ot, (go_offset){.v = _method_ptr_pos}),
&invocation.method,
invocation.method,

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.

man, how come this was working? nice catch

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.

madness :) I have no idea, address of an address.

@grcevski
grcevski merged commit 9a77854 into open-telemetry:main Nov 13, 2025
50 checks passed
@grcevski
grcevski deleted the go_route_harvesting branch November 13, 2025 17:38
@MrAlias MrAlias added this to the v0.3.0 milestone Dec 3, 2025
@MrAlias MrAlias mentioned this pull request Dec 3, 2025
marctc pushed a commit to grafana/opentelemetry-ebpf-instrumentation that referenced this pull request Dec 9, 2025
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