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

Accept Distributed Trace Headers From New Relic #5078

Open
maxcroy1 opened this issue Aug 30, 2024 · 2 comments
Open

Accept Distributed Trace Headers From New Relic #5078

maxcroy1 opened this issue Aug 30, 2024 · 2 comments

Comments

@maxcroy1
Copy link

Is your feature request related to a problem? Please describe.

Our team is utilizing GraphQL-Ruby for a subgraph within an Apollo Federated Supergraph. To achieve comprehensive observability, we're relying on New Relic Distributed Tracing to monitor how requests flow through our various services within the supergraph.

However, we've encountered a roadblock: New Relic tracing currently doesn't accept traceparent or tracestate headers, which limits our ability to achieve the desired level of observability.

Describe the solution you'd like

It would be great if enabling New Relic tracing in GraphQL-Ruby would automatically support distributed tracing, provided it's activated in the project's newrelic.yml configuration file. This feature would streamline our observability efforts without requiring additional effort.

Describe alternatives you've considered

I'm exploring the possibility of extending the GraphQL::Tracing::NewRelicTrace module to add this support. However, this approach is proving to be complex and time-consuming.

Additional context

None

@rmosolgo
Copy link
Owner

Hey, thanks for the detailed write-up. It seems like NewRelicTrace would need some way of pulling the current request info (traceparent and tracestate) out of the query context: { ... } so that it could send the right data to New Relic.

Here are the places where NewRelicTrace calls New Relic's Ruby API:

NewRelic::Agent::MethodTracerHelpers.trace_execution_scoped("#{platform_key}") do

NewRelic::Agent::MethodTracerHelpers.trace_execution_scoped(platform_key) do

NewRelic::Agent::MethodTracerHelpers.trace_execution_scoped(platform_key) do

NewRelic::Agent::MethodTracerHelpers.trace_execution_scoped(platform_key) do

Looking at the source for that method in NewRelic's library, it looks like it accepts an options Hash but only uses the :code_information key from it:

https://github.com/newrelic/newrelic-ruby-agent/blob/ef2c632c83ba2ac93695ef9eb11ef2a223b7812b/lib/new_relic/agent/method_tracer_helpers.rb#L19C48-L19C55

So the first question is ... once we get the distributed trace info from HTTP headers, how do we give it to NewRelic? Did you find a Ruby API for setting that information?

@maxcroy1
Copy link
Author

maxcroy1 commented Sep 3, 2024

I believe I did. Based on my understanding, I think this should do the trick? https://github.com/newrelic/newrelic-ruby-agent/blob/ef2c632c83ba2ac93695ef9eb11ef2a223b7812b/lib/new_relic/agent/distributed_tracing.rb#L98C7-L135C10

With that said, I think we're also going to need to leverage this to make sure any downstream services can also be included in the trace: https://github.com/newrelic/newrelic-ruby-agent/blob/ef2c632c83ba2ac93695ef9eb11ef2a223b7812b/lib/new_relic/agent/distributed_tracing.rb#L44

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