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

Enable a callback to send custom tags to datadog tracing #4066

Closed
nithinpb opened this issue May 13, 2022 · 2 comments · Fixed by #4067
Closed

Enable a callback to send custom tags to datadog tracing #4066

nithinpb opened this issue May 13, 2022 · 2 comments · Fixed by #4067

Comments

@nithinpb
Copy link

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

We'd like to be able send custom tags along with the logs for datadog traces. We need this to classify some of our logs based on custom business logic. This can be done via setting the tag on DataDog::Span object.

Describe the solution you'd like

We'd like to set a callback method from our code while initializing datadog tracing class. Before yielding the control back to the graphql resolution method, we'd like to invoke the callback method with span argument. Doing so, we can set the tag on the span as per our business requirement.

module GraphQL
  module Tracing
    class DataDogTracing < PlatformTracing
      def initialize(options = nil)
        @callback = options[:callback] unless options.nil?
        super options
      end
...
          @callback.call(span)
          yield
...

Describe alternatives you've considered

There does not seem to be any other alternative to this solution as we need access to the DataDog::Span object while tracer.trace is invoked.

Additional context

No

@rmosolgo
Copy link
Owner

What do you think of the approach described in #4067?

In that approach, you can make a subclass and implement def prepare_span(...) to apply tags. (Method calls are faster than proc calls, and IMO, a more Ruby-ish style!)

@nithinpb
Copy link
Author

@rmosolgo : This works as well. Thanks!

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 a pull request may close this issue.

2 participants