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

Support empty url path in HTTP client probe #810

Merged
merged 6 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ OpenTelemetry Go Automatic Instrumentation adheres to [Semantic Versioning](http
### Fixed

- Change HTTP client span name to `{http.request.method}` ([#775](https://github.com/open-telemetry/opentelemetry-go-instrumentation/pull/775))
- Support empty url path in HTTP client probe ([#810](https://github.com/open-telemetry/opentelemetry-go-instrumentation/pull/810))
RonFed marked this conversation as resolved.
Show resolved Hide resolved


## [v0.12.0-alpha] - 2024-04-10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ int uprobe_Transport_roundTrip(struct pt_regs *ctx) {
bpf_probe_read(&url_ptr, sizeof(url_ptr), (void *)(req_ptr+url_ptr_pos));
if (!get_go_string_from_user_ptr((void *)(url_ptr+path_ptr_pos), httpReq->path, sizeof(httpReq->path))) {
bpf_printk("uprobe_Transport_roundTrip: Failed to get path from Request.URL");
return 0;
}

// get host from Request
Expand Down
5 changes: 4 additions & 1 deletion internal/pkg/instrumentation/bpf/net/http/client/probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,13 @@ func convertEvent(e *event) []*probe.SpanEvent {

attrs := []attribute.KeyValue{
semconv.HTTPRequestMethodKey.String(method),
semconv.URLPath(path),
semconv.HTTPResponseStatusCodeKey.Int(int(e.StatusCode)),
}

if path != "" {
attrs = append(attrs, semconv.URLPath(path))
}

// Server address and port
serverAddr, serverPort := http.ServerAddressPortAttributes(e.Host[:])
if serverAddr.Valid() {
Expand Down
8 changes: 4 additions & 4 deletions internal/test/e2e/databasesql/traces.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,15 @@
}
},
{
"key": "url.path",
"key": "http.response.status_code",
"value": {
"stringValue": "/query_db"
"intValue": "200"
}
},
{
"key": "http.response.status_code",
"key": "url.path",
"value": {
"intValue": "200"
"stringValue": "/query_db"
}
},
{
Expand Down
8 changes: 4 additions & 4 deletions internal/test/e2e/gin/traces.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@
}
},
{
"key": "url.path",
"key": "http.response.status_code",
"value": {
"stringValue": "/hello-gin"
"intValue": "200"
}
},
{
"key": "http.response.status_code",
"key": "url.path",
"value": {
"intValue": "200"
"stringValue": "/hello-gin"
}
},
{
Expand Down
8 changes: 4 additions & 4 deletions internal/test/e2e/nethttp/traces.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@
}
},
{
"key": "url.path",
"key": "http.response.status_code",
"value": {
"stringValue": "/hello"
"intValue": "200"
}
},
{
"key": "http.response.status_code",
"key": "url.path",
"value": {
"intValue": "200"
"stringValue": "/hello"
}
},
{
Expand Down
8 changes: 4 additions & 4 deletions internal/test/e2e/nethttp_custom/traces.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@
}
},
{
"key": "url.path",
"key": "http.response.status_code",
"value": {
"stringValue": "/hello"
"intValue": "200"
}
},
{
"key": "http.response.status_code",
"key": "url.path",
"value": {
"intValue": "200"
"stringValue": "/hello"
}
},
{
Expand Down
Loading