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

Fix span name for HTTPClient calls #1244

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
4 changes: 2 additions & 2 deletions pkg/export/otel/traces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -956,12 +956,12 @@ func TestTracesInstrumentations(t *testing.T) {
{
name: "all instrumentations",
instr: []string{instrumentations.InstrumentationALL},
expected: []string{"GET /foo", "PUT", "/grpcFoo", "/grpcGoo", "SELECT credentials", "SET", "GET", "important-topic publish", "important-topic process"},
expected: []string{"GET /foo", "PUT /bar", "/grpcFoo", "/grpcGoo", "SELECT credentials", "SET", "GET", "important-topic publish", "important-topic process"},
},
{
name: "http only",
instr: []string{instrumentations.InstrumentationHTTP},
expected: []string{"GET /foo", "PUT"},
expected: []string{"GET /foo", "PUT /bar"},
},
{
name: "grpc only",
Expand Down
4 changes: 1 addition & 3 deletions pkg/internal/request/span.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,16 +416,14 @@ func (s *Span) ServiceGraphKind() string {

func (s *Span) TraceName() string {
switch s.Type {
case EventTypeHTTP:
case EventTypeHTTP, EventTypeHTTPClient:
name := s.Method
if s.Route != "" {
name += " " + s.Route
}
return name
case EventTypeGRPC, EventTypeGRPCClient:
return s.Path
case EventTypeHTTPClient:
return s.Method
case EventTypeSQLClient:
operation := s.Method
if operation == "" {
Expand Down
10 changes: 5 additions & 5 deletions test/integration/traces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ func testNestedHTTPTracesKProbes(t *testing.T) {

// Check the information of the java parent span
res = trace.FindByOperationName("GET /jtrace")
require.Len(t, res, 1)
require.Len(t, res, 2)
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah right, I guess now multiple spans will match with the same URL path. I think we need to extend FindOperationByName to use an optional parameter which is the span kind and look for the server span. Otherwise many other tests will have an issue.

parent = res[0]
require.NotEmpty(t, parent.TraceID)
require.Equal(t, traceID, parent.TraceID)
Expand All @@ -772,7 +772,7 @@ func testNestedHTTPTracesKProbes(t *testing.T) {

// Check the information of the nodejs parent span
res = trace.FindByOperationName("GET /traceme")
require.Len(t, res, 1)
require.Len(t, res, 2)
parent = res[0]
require.NotEmpty(t, parent.TraceID)
require.Equal(t, traceID, parent.TraceID)
Expand All @@ -792,7 +792,7 @@ func testNestedHTTPTracesKProbes(t *testing.T) {

// Check the information of the go parent span
res = trace.FindByOperationName("GET /gotracemetoo")
require.Len(t, res, 1)
require.Len(t, res, 2)
parent = res[0]
require.NotEmpty(t, parent.TraceID)
traceID = parent.TraceID // we reset the traceID here
Expand All @@ -812,7 +812,7 @@ func testNestedHTTPTracesKProbes(t *testing.T) {

// Check the information of the python parent span
res = trace.FindByOperationName("GET /tracemetoo")
require.Len(t, res, 1)
require.Len(t, res, 2)
parent = res[0]
require.NotEmpty(t, parent.TraceID)
require.Equal(t, traceID, parent.TraceID)
Expand All @@ -832,7 +832,7 @@ func testNestedHTTPTracesKProbes(t *testing.T) {

// Check the information of the rails parent span
res = trace.FindByOperationName("GET /users")
require.Len(t, res, 1)
require.Len(t, res, 2)
parent = res[0]
require.NotEmpty(t, parent.TraceID)
require.Equal(t, traceID, parent.TraceID)
Expand Down
Loading