Accept Distributed Trace Headers From New Relic
Opened this issue · 2 comments
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
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:
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:
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?
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