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

Fix integration tracers initializing too early #756

Merged
merged 1 commit into from
May 16, 2019

Conversation

delner
Copy link
Contributor

@delner delner commented May 14, 2019

When configuring Datadog with OpenTracing, typically the Datadog.tracer gets swapped for the OpenTracing instance of Datadog::Tracer.

Given the original code for defining a tracer option for integrations, it was initializing its own reference to Datadog::Tracer at load time, instead of at run time. This means when OpenTracing was configured, the integrations were using the old instance created at load time, and a 2nd tracer was being used just for OpenTracing. This could manifest some strange behavior, and cause the Datadog tracer to appear misconfigured.

The interim solution is to lazy initialize tracer for integrations. It's only a short term fix though, given if you reassign the Datadog global tracer after configuring the integrations, you'll end up with the same issue. Thus with this change its recommended that integrations are only configured after the global tracer has been. e.g.

require 'ddtrace'
require 'ddtrace/opentracer'

# Activate and configure open tracing
OpenTracing.global_tracer = Datadog::OpenTracer::Tracer.new
Datadog.tracer.default_service = 'service_name'

# Then configure integration settings
Datadog.configure do |c|
  c.tracer env: "dev"
  c.use :rails
end

@delner delner added bug Involves a bug integrations Involves tracing integrations labels May 14, 2019
@delner delner requested a review from brettlangdon May 14, 2019 20:10
@delner delner self-assigned this May 14, 2019
@delner delner modified the milestones: 0.24.0, 0.23.3 May 16, 2019
@delner delner merged commit 250322f into master May 16, 2019
@delner delner deleted the fix/integration_tracer_initializing_early branch May 16, 2019 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Involves a bug integrations Involves tracing integrations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants