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

New Span being created for each HTTP request in OpenTracingServerFilter #236

Open
achatterjee104 opened this issue Jan 25, 2023 Discussed in #230 · 3 comments
Open

New Span being created for each HTTP request in OpenTracingServerFilter #236

achatterjee104 opened this issue Jan 25, 2023 Discussed in #230 · 3 comments
Assignees

Comments

@achatterjee104
Copy link

Discussed in #230

Originally posted by achatterjee104 January 20, 2023

Expectation

Scenario 1:

  1. There are 2 REST services - service-A and service-B
  2. A request comes to service-A and its OpenTracingServerFilter creates a new span, say [trace-id=1, span-id=1]
  3. service-A invokes service-B, waits for its response and then returns the consolidated result
  4. service-B will get the request with [trace-id=1, span-id=1] and it should created its new span [trace-id=1, span-id=2] (since trace-id is already present)
  5. At the end, there will be 2 spans (span-id=1 & span-id=2) as child of trace-id=1

Scenario 2:

  1. There is a REST service with 2 endpoints - /books & /authors
  2. A request comes to /books and its OpenTracingServerFilter creates a new span, say [trace-id=1, span-id=1]
  3. /books endpoint internally invokes /authors endpoint (via a REST call), waits for its response and then returns the consolidated result
  4. during /authors endpoint call, the OpenTracingServerFilter will get the request with [trace-id=1, span-id=1] and it should created its new span [trace-id=1, span-id=2] (since trace-id is already present)
  5. At the end, there will be 2 spans (span-id=1 & span-id=2) as child of trace-id=1

Ref: This guide says "Whenever a Micronaut server receives a request, it creates a new span"

From Source Code

From OpenTracingServerFilter,

Tracer.SpanBuilder spanBuilder = continued ? null : newSpan(request, initSpanContext(request))

it seems to be creating new span everytime, irrespective of presence of existing trace-id.

@n0tl3ss
Copy link
Member

n0tl3ss commented Jan 25, 2023

Hi @achatterjee104 can you give better explanation. What is now happening, and what should happened? My understanding that trace-id identifies whole trace with all spans on it. I don't see a problem with creating a new span.

@achatterjee104
Copy link
Author

Hi @n0tl3ss I have not tested scenario 1, but in scenario 2, I could see 4th step is not being followed - it is creating new trace-id for /authors request instead of creating new span under the existing trace-id that was created for /books request.

I also could not see any place where this trace-id is actually created in the code. Can you please point me to that place, it will help me to track the flow more closely.

@n0tl3ss
Copy link
Member

n0tl3ss commented Jan 25, 2023

Hi @achatterjee104 I will have to follow the guide myself then I will see what is happening :) I will report back to you.

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

No branches or pull requests

2 participants