Skip to content

Agent configuration settings ignored when using OpenTracing #1563

Open

Description

Following the Quickstart for OpenTracing documentation, I've created the following sample:

require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'

  gem 'ddtrace', path: '.'
  gem 'opentracing'
end

require 'opentracing'
require 'ddtrace'
require 'ddtrace/opentracer'

# # Activate the Datadog tracer for OpenTracing
OpenTracing.global_tracer = Datadog::OpenTracer::Tracer.new

Datadog.configure do |c|
  c.diagnostics.debug = true
  c.tracer.hostname = 'foo'
end

OpenTracing.start_active_span('operation_name') do |scope|
  # do nothing
end

Contrary to what may be expected, the hostname specified in the Datadog.configure block is completely ignored:

D, [2021-06-21T10:33:12.268754 #34028] DEBUG -- ddtrace: [ddtrace] (/Users/ivo.anjo/datadog/dd-trace-rb/lib/ddtrace/tracer.rb:363:in `write') Writing 1 spans (enabled: true)
D, [2021-06-21T10:33:12.268954 #34028] DEBUG -- ddtrace: [ddtrace] (/Users/ivo.anjo/datadog/dd-trace-rb/lib/ddtrace/tracer.rb:366:in `write') [
 Name: operation_name
Span ID: 2361826171763954817
Parent ID: 0
Trace ID: 3477994216835371584
Type:
Service: opentracing-testcase
Resource: operation_name
Error: 0
Start: 1624267992268434944
End: 1624267992268709888
Duration: 0.000275
Allocations: 48
Tags: [
   runtime-id => 46a72af0-fd9a-41c1-abb1-f7309fe96819]
Metrics: [
   _dd.agent_psr => 1.0,
   system.pid => 34028.0,
   _sampling_priority_v1 => 1.0]]

D, [2021-06-21T10:33:12.269029 #34028] DEBUG -- ddtrace: [ddtrace] (/Users/ivo.anjo/datadog/dd-trace-rb/lib/ddtrace/workers.rb:72:in `block in start') Starting thread for: #<Datadog::Workers::AsyncTransport:0x00007f8d2b985a20>
E, [2021-06-21T10:33:12.270126 #34028] ERROR -- ddtrace: [ddtrace] (/Users/ivo.anjo/datadog/dd-trace-rb/lib/ddtrace/transport/http/client.rb:35:in `rescue in send_request') Internal error during HTTP transport request. Cause: Failed to open TCP connection to 127.0.0.1:8126 (Connection refused - connect(2) for "127.0.0.1" port 8126) Location: /Users/ivo.anjo/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/net/http.rb:960:in `initialize'
I, [2021-06-21T10:33:12.270512 #34028]  INFO -- ddtrace: [ddtrace] (/Users/ivo.anjo/datadog/dd-trace-rb/lib/ddtrace/diagnostics/environment_logger.rb:31:in `log_environment!') DATADOG TRACER CONFIGURATION - {"date":"2021-06-21T10:33:12+01:00","os_name":"x86_64-apple-darwin19","version":"0.50.0","lang":"ruby","lang_version":"2.7.3","enabled":true,"service":"opentracing-testcase","agent_url":"http://127.0.0.1:8126?timeout=1","agent_error":"Datadog::Transport::InternalErrorResponse ok?: unsupported?:, not_found?:, client_error?:, server_error?:, internal_error?:true, payload:, error_type:Errno::ECONNREFUSED error:Failed to open TCP connection to 127.0.0.1:8126 (Connection refused - connect(2) for \"127.0.0.1\" port 8126)","debug":true,"analytics_enabled":false,"runtime_metrics_enabled":false,"vm":"ruby-2.7.3","partial_flushing_enabled":false,"priority_sampling_enabled":false,"health_metrics_enabled":false}
W, [2021-06-21T10:33:12.270545 #34028]  WARN -- ddtrace: [ddtrace] (/Users/ivo.anjo/datadog/dd-trace-rb/lib/ddtrace/diagnostics/environment_logger.rb:35:in `log_error!') DATADOG TRACER DIAGNOSTIC - Agent Error: Datadog::Transport::InternalErrorResponse ok?: unsupported?:, not_found?:, client_error?:, server_error?:, internal_error?:true, payload:, error_type:Errno::ECONNREFUSED error:Failed to open TCP connection to 127.0.0.1:8126 (Connection refused - connect(2) for "127.0.0.1" port 8126)

It seems configuration via code is broken for this usecase. Using environment variables (e.g. DD_AGENT_HOST) still works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

bugInvolves a bugcommunityWas opened by a community membertracing

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions