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

Add automatic distributed trace to rack if ids are present #141

Closed

Conversation

whithajess
Copy link
Contributor

If trace and span ids are present in the request use them in the trace.

@cabello
Copy link
Contributor

cabello commented Jun 21, 2017

If this works, it addresses my request #89 🎉

@whithajess
Copy link
Contributor Author

@cabello Tested and working we have AMQP between our services so in the call to that I put in the parent_span and parent_trace ids (in the fake html) and it comes through to the service and it all links up perfectly.

@whithajess
Copy link
Contributor Author

@ufoot Do you need me to do anything else to this PR to get it merged? We are using changes in production and would love to get this merged so I do not have to manage my fork.

}

# Merge distributed trace ids if present
unless env['HTTP_X_DDTRACE_PARENT_TRACE_ID'].nil? || env['HTTP_X_DDTRACE_PARENT_SPAN_ID'].nil?
Copy link
Contributor

Choose a reason for hiding this comment

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

Have these headers been documented as the "canonical" headers to use for distributed traces? I've seen various values used throughout clients for different languages.

Would be nice if there was a strict contract for this between all languages.

Copy link
Contributor Author

@whithajess whithajess Jun 29, 2017

Choose a reason for hiding this comment

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

They are documented in http://www.rubydoc.info/github/DataDog/dd-trace-rb/ as the example for distributed tracing so I would say yes? I also want to add setting these in the net/http middleware which would mean you wouldn't even have to manually set them if it was included.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As part of this patch I could add to the documentation that the rack middleware will automatically do distributed tracing based on these headers also?

Copy link
Member

Choose a reason for hiding this comment

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

Hi all, indeed the plan is to have these headers be the same for all languages, obviously. Sorry for the delay, we're still discussing a few points here, as we know once this is officially released, there's no way back, any update would be a breaking change for you. Still, I understand the frustration of maintaining your fork @cabello ... BTW @whithajess this should probably be merged/rebased with some upcoming PR which changes the way we deal with the current span. I'm leaving a small comment in the code about this. Thanks for your patience, we'll get this one moving on, for sure!

Copy link
Member

Choose a reason for hiding this comment

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

@ejholmes indeed there are still different values around but as I said just above, plan is really to have all of them aligned. There has been recent moves on Python recently concerning this: https://github.com/DataDog/dd-trace-py/blob/c609a9054c479b6e394eb807520567b000f1aace/ddtrace/contrib/aiohttp/middlewares.py#L12 and in Go too: https://github.com/DataDog/dd-trace-go/blob/f3e02e97f8a21336bac49d9071d27edd98885da3/tracer/contrib/tracegrpc/grpc.go#L17 and Ruby, with the help of this patch, should follow.

@cabello
Copy link
Contributor

cabello commented Jun 30, 2017

Looking forward to having this merged, I am tired of keeping my fork. 👍

parent = @buffer.get()
span.set_parent(parent)
if span.parent_id.zero? || span.parent_id.nil?
parent = @buffer.get()
Copy link
Member

Choose a reason for hiding this comment

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

Side note, this would probably need to be merged with #145 but I could take care of that (the change concerning this buffer is not small, it... disappeared).

@ufoot
Copy link
Member

ufoot commented Jul 7, 2017

FYI I merged this PR with another PR (#145) which should ship soon. The result of the merge is here: #151 I basically:

  • resolved merge conflicts
  • added a test
  • added an option to disable the feature (disabled by default) to avoid side effects
  • updated the docs

@ufoot ufoot added this to the 0.8.0 milestone Jul 20, 2017
@ufoot
Copy link
Member

ufoot commented Jul 21, 2017

FYI, has been merged with #151 so master now has support for this. We only have packaging & QA tasks now before releasing this feature in the official gem. Thanks for your contributions @whithajess and @cabello , much appreciated.

@ufoot ufoot closed this Jul 21, 2017
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.

4 participants