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

ArgumentError thrown from auto-instrumentation code when running OpenTelemetry in parallel #3575

Open
anandhasudhan opened this issue Apr 5, 2024 · 6 comments
Assignees
Labels
bug Involves a bug community Was opened by a community member tracing

Comments

@anandhasudhan
Copy link

anandhasudhan commented Apr 5, 2024

Current behaviour
When running Datadog and OpenTelemetry in parallel, the auto-instrumentation code from datadog throws an ArgumentError since it ends up calling the opentelemetry library code. It appears that datadog instrumentation is clashing with the opentelemetry instrumentation. I briefly looked at the ddtrace code and it has this method annotate_span_with_response! that takes 3 arguments and opentelemetry code has the same method annotate_span_with_response! that takes 2 arguments.

The ArgumentError we received was for this particular method where opentelemetry expected 2 arguments but received 3 (from the datadog instrumentation). Although, they have their own separate name spaces, I'm not sure why datadog called the opentelemetry library code.

Expected behaviour
Datadog does not call the opentelemetry library code and continues instrumenting my application code without errors when opentelemetry is enabled.

Steps to reproduce
Run datadog and opentelemetry in parallel. The auto-instrumentation code from datadog ends up calling the opentelemetry library code resulting in ArgumentError.

Below is the complete stack trace for the ArgumentError when running datadog and opentelemetry in parallel.

/usr/src/app/vendor/bundle/ruby/2.6.0/gems/opentelemetry-instrumentation-net_http-0.21.1/lib/opentelemetry/instrumentation/net/http/patches/instrumentation.rb:77:in `annotate_span_with_response!': wrong number of arguments (given 3, expected 2) (ArgumentError)
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/ddtrace-1.10.1/lib/datadog/tracing/contrib/http/instrumentation.rb:59:in `block in request'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/ddtrace-1.10.1/lib/datadog/tracing/trace_operation.rb:192:in `block in measure'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/ddtrace-1.10.1/lib/datadog/tracing/span_operation.rb:150:in `measure'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/ddtrace-1.10.1/lib/datadog/tracing/trace_operation.rb:192:in `measure'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/ddtrace-1.10.1/lib/datadog/tracing/tracer.rb:380:in `start_span'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/ddtrace-1.10.1/lib/datadog/tracing/tracer.rb:160:in `block in trace'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/ddtrace-1.10.1/lib/datadog/tracing/context.rb:43:in `activate!'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/ddtrace-1.10.1/lib/datadog/tracing/tracer.rb:159:in `trace'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/ddtrace-1.10.1/lib/datadog/tracing.rb:16:in `trace'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/ddtrace-1.10.1/lib/datadog/tracing/contrib/http/instrumentation.rb:40:in `request'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/opentelemetry-instrumentation-net_http-0.21.1/lib/opentelemetry/instrumentation/net/http/patches/instrumentation.rb:38:in `block in request'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/opentelemetry-api-1.1.0/lib/opentelemetry/trace.rb:72:in `block in with_span'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/opentelemetry-api-1.1.0/lib/opentelemetry/context.rb:87:in `with_value'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/opentelemetry-api-1.1.0/lib/opentelemetry/trace.rb:72:in `with_span'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/opentelemetry-api-1.1.0/lib/opentelemetry/trace/tracer.rb:29:in `in_span'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/opentelemetry-instrumentation-net_http-0.21.1/lib/opentelemetry/instrumentation/net/http/patches/instrumentation.rb:31:in `request'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/webmock-3.6.2/lib/webmock/http_lib_adapters/net_http.rb:97:in `block in request'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/webmock-3.6.2/lib/webmock/http_lib_adapters/net_http.rb:110:in `block in request'
	from /usr/local/lib/ruby/2.6.0/net/http.rb:920:in `start'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/webmock-3.6.2/lib/webmock/http_lib_adapters/net_http.rb:109:in `request'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/sentry-ruby-5.5.0/lib/sentry/net/http.rb:29:in `request'
	from /usr/local/lib/ruby/2.6.0/net/http.rb:1228:in `get'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/faraday-0.15.4/lib/faraday/adapter/net_http.rb:85:in `perform_request'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/faraday-0.15.4/lib/faraday/adapter/net_http.rb:43:in `block in call'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/faraday-0.15.4/lib/faraday/adapter/net_http.rb:92:in `with_net_http_connection'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/faraday-0.15.4/lib/faraday/adapter/net_http.rb:38:in `call'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/faraday-0.15.4/lib/faraday/request/url_encoded.rb:15:in `call'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/faraday-0.15.4/lib/faraday/rack_builder.rb:143:in `build_response'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/faraday-0.15.4/lib/faraday/connection.rb:387:in `run_request'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/faraday-0.15.4/lib/faraday/connection.rb:138:in `get'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/faraday-0.15.4/lib/faraday.rb:103:in `method_missing'
	from /usr/src/app/lib/avant/webpack/webpack.rb:55:in `load_manifest'
	from /usr/src/app/lib/avant/webpack/webpack.rb:44:in `initialize'
	from /usr/src/app/lib/avant/webpack/webpack.rb:12:in `new'
	from /usr/src/app/lib/avant/webpack/webpack.rb:12:in `manifest'
	from /usr/src/app/config/initializers/webpack.rb:9:in `block in <top (required)>'
	from /usr/src/app/config/initializers/webpack.rb:9:in `each'
	from /usr/src/app/config/initializers/webpack.rb:9:in `<top (required)>'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/activesupport-4.2.11.3/lib/active_support/dependencies.rb:268:in `load'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/activesupport-4.2.11.3/lib/active_support/dependencies.rb:268:in `block in load'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/activesupport-4.2.11.3/lib/active_support/dependencies.rb:240:in `load_dependency'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/activesupport-4.2.11.3/lib/active_support/dependencies.rb:268:in `load'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/railties-4.2.11.3/lib/rails/engine.rb:652:in `block in load_config_initializer'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/activesupport-4.2.11.3/lib/active_support/notifications.rb:166:in `instrument'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/railties-4.2.11.3/lib/rails/engine.rb:651:in `load_config_initializer'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/railties-4.2.11.3/lib/rails/engine.rb:616:in `block (2 levels) in <class:Engine>'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/railties-4.2.11.3/lib/rails/engine.rb:615:in `each'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/railties-4.2.11.3/lib/rails/engine.rb:615:in `block in <class:Engine>'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/railties-4.2.11.3/lib/rails/initializable.rb:30:in `instance_exec'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/railties-4.2.11.3/lib/rails/initializable.rb:30:in `run'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/railties-4.2.11.3/lib/rails/initializable.rb:55:in `block in run_initializers'
	from /usr/local/lib/ruby/2.6.0/tsort.rb:228:in `block in tsort_each'
	from /usr/local/lib/ruby/2.6.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
	from /usr/local/lib/ruby/2.6.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
	from /usr/local/lib/ruby/2.6.0/tsort.rb:431:in `each_strongly_connected_component_from'
	from /usr/local/lib/ruby/2.6.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/railties-4.2.11.3/lib/rails/initializable.rb:44:in `each'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/railties-4.2.11.3/lib/rails/initializable.rb:44:in `tsort_each_child'
	from /usr/local/lib/ruby/2.6.0/tsort.rb:415:in `call'
	from /usr/local/lib/ruby/2.6.0/tsort.rb:415:in `each_strongly_connected_component_from'
	from /usr/local/lib/ruby/2.6.0/tsort.rb:349:in `block in each_strongly_connected_component'
	from /usr/local/lib/ruby/2.6.0/tsort.rb:347:in `each'
	from /usr/local/lib/ruby/2.6.0/tsort.rb:347:in `call'
	from /usr/local/lib/ruby/2.6.0/tsort.rb:347:in `each_strongly_connected_component'
	from /usr/local/lib/ruby/2.6.0/tsort.rb:226:in `tsort_each'
	from /usr/local/lib/ruby/2.6.0/tsort.rb:205:in `tsort_each'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/railties-4.2.11.3/lib/rails/initializable.rb:54:in `run_initializers'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/railties-4.2.11.3/lib/rails/application.rb:352:in `initialize!'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/railties-4.2.11.3/lib/rails/railtie.rb:194:in `public_send'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/railties-4.2.11.3/lib/rails/railtie.rb:194:in `method_missing'
	from /usr/src/app/config/environment.rb:5:in `<top (required)>'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/activesupport-4.2.11.3/lib/active_support/dependencies.rb:274:in `require'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/activesupport-4.2.11.3/lib/active_support/dependencies.rb:274:in `block in require'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/activesupport-4.2.11.3/lib/active_support/dependencies.rb:240:in `load_dependency'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/activesupport-4.2.11.3/lib/active_support/dependencies.rb:274:in `require'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/sidekiq-4.2.10/lib/sidekiq/cli.rb:244:in `boot_system'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/sidekiq-4.2.10/lib/sidekiq/cli.rb:50:in `run'
	from /usr/src/app/vendor/gems/sidekiq-ent-1.5.4/lib/sidekiq-ent/swarm.rb:179:in `block in forkit'
	from /usr/src/app/vendor/gems/sidekiq-ent-1.5.4/lib/sidekiq-ent/swarm.rb:175:in `fork'
	from /usr/src/app/vendor/gems/sidekiq-ent-1.5.4/lib/sidekiq-ent/swarm.rb:175:in `forkit'
	from /usr/src/app/vendor/gems/sidekiq-ent-1.5.4/lib/sidekiq-ent/swarm.rb:171:in `spawn'
	from /usr/src/app/vendor/gems/sidekiq-ent-1.5.4/lib/sidekiq-ent/swarm.rb:82:in `monitor'
	from /usr/src/app/vendor/gems/sidekiq-ent-1.5.4/lib/sidekiq-ent/swarm.rb:42:in `start_and_monitor'
	from /usr/src/app/vendor/gems/sidekiq-ent-1.5.4/bin/sidekiqswarm:51:in `<top (required)>'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/bin/sidekiqswarm:23:in `load'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/bin/sidekiqswarm:23:in `<top (required)>'
	from /usr/local/lib/ruby/2.6.0/bundler/cli/exec.rb:74:in `load'
	from /usr/local/lib/ruby/2.6.0/bundler/cli/exec.rb:74:in `kernel_load'
	from /usr/local/lib/ruby/2.6.0/bundler/cli/exec.rb:28:in `run'
	from /usr/local/lib/ruby/2.6.0/bundler/cli.rb:463:in `exec'
	from /usr/local/lib/ruby/2.6.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
	from /usr/local/lib/ruby/2.6.0/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
	from /usr/local/lib/ruby/2.6.0/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
	from /usr/local/lib/ruby/2.6.0/bundler/cli.rb:27:in `dispatch'
	from /usr/local/lib/ruby/2.6.0/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
	from /usr/local/lib/ruby/2.6.0/bundler/cli.rb:18:in `start'
	from /usr/local/lib/ruby/gems/2.6.0/gems/bundler-1.17.2/exe/bundle:30:in `block in <top (required)>'
	from /usr/local/lib/ruby/2.6.0/bundler/friendly_errors.rb:124:in `with_friendly_errors'
	from /usr/local/lib/ruby/gems/2.6.0/gems/bundler-1.17.2/exe/bundle:22:in `<top (required)>'
	from /usr/local/bin/bundle:23:in `load'
	from /usr/local/bin/bundle:23:in `<main>'

How does ddtrace help you?

Environment

  • ddtrace version: 1.10.1
  • Configuration block (Datadog.configure ...):
  Datadog.configure do |c|
    c.env     = ENV['DD_SERVICE_ENV']
    c.version = ENV['DEVOPS_GIT_SHA']

    c.tracing.enabled = true
    c.agent.host = ENV['DD_AGENT_HOST']
    c.agent.port = Integer(ENV['DD_PORT']) if ENV['DD_PORT'].present?

    location = Rails.logger&.logdev&.dev || STDOUT
    c.logger.instance = Datadog::Core::Logger.new(location)
    c.logger.level = ENV.fetch('DD_LOG_LEVEL', 'warn')
    c.diagnostics.startup_logs.enabled = ENV.fetch('DD_STARTUP_LOGS_ENABLED', "false") == "true"

    c.tracing.instrument :rails
    c.tracing.instrument :redis
    c.tracing.instrument :http
    c.tracing.instrument :rest_client
    c.tracing.instrument :sidekiq,
                         service_name:        Datadog::Tracing::Contrib::Sidekiq::Ext::SERVICE_NAME,
                         client_service_name: Datadog::Tracing::Contrib::Sidekiq::Ext::CLIENT_SERVICE_NAME
    c.tracing.instrument :aws
    c.tracing.instrument :grape, service_name: Datadog::Tracing::Contrib::Grape::Ext::TAG_COMPONENT
    c.tracing.instrument :dalli
    c.tracing.instrument :concurrent_ruby
  end
  • Ruby version: 2.6.10
  • Operating system: Linux
  • **Relevant library versions:
ddtrace | 1.10.1
opentelemetry-api | 1.1.0
opentelemetry-common | 0.19.7
opentelemetry-instrumentation-all | 0.33.0
opentelemetry-instrumentation-sidekiq | 0.22.1
opentelemetry-instrumentation-net_http | 0.21.1
@anandhasudhan anandhasudhan added bug Involves a bug community Was opened by a community member labels Apr 5, 2024
@delner
Copy link
Contributor

delner commented Apr 9, 2024

@anandhasudhan Thanks for reporting this! Just want to let you know the team has seen this, and is starting to look at it. I'll tag in someone here to walk through this issue with you.

@delner delner assigned delner and marcotc and unassigned delner Apr 9, 2024
@delner delner added the tracing label Apr 9, 2024
@anandhasudhan
Copy link
Author

@marcotc Thanks for looking into this.

For additional context, I initialized 1_datadog.rb first and then 2_opentelemetry.rb. I tried changing the order to initialize 1_opentelemetry.rb first and then 2_datadog.rb. The opposite seems to happen. ie. open telemetry code ends up calling data dog code and throws the ArgumentError.

Argument Error Stack trace
ArgumentError: wrong number of arguments (given 2, expected 3)
/usr/src/app/vendor/bundle/ruby/2.6.0/gems/ddtrace-1.10.1/lib/datadog/tracing/contrib/http/instrumentation.rb:91:in `annotate_span_with_response!': wrong number of arguments (given 2, expected 3) (ArgumentError)
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/opentelemetry-instrumentation-net_http-0.21.1/lib/opentelemetry/instrumentation/net/http/patches/instrumentation.rb:39:in `block (2 levels) in request'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/opentelemetry-instrumentation-net_http-0.21.1/lib/opentelemetry/instrumentation/net/http/patches/instrumentation.rb:38:in `tap'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/opentelemetry-instrumentation-net_http-0.21.1/lib/opentelemetry/instrumentation/net/http/patches/instrumentation.rb:38:in `block in request'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/opentelemetry-api-1.1.0/lib/opentelemetry/trace.rb:72:in `block in with_span'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/opentelemetry-api-1.1.0/lib/opentelemetry/context.rb:87:in `with_value'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/opentelemetry-api-1.1.0/lib/opentelemetry/trace.rb:72:in `with_span'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/opentelemetry-api-1.1.0/lib/opentelemetry/trace/tracer.rb:29:in `in_span'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/opentelemetry-instrumentation-net_http-0.21.1/lib/opentelemetry/instrumentation/net/http/patches/instrumentation.rb:31:in `request'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/ddtrace-1.10.1/lib/datadog/tracing/contrib/http/instrumentation.rb:55:in `block in request'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/ddtrace-1.10.1/lib/datadog/tracing/trace_operation.rb:192:in `block in measure'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/ddtrace-1.10.1/lib/datadog/tracing/span_operation.rb:150:in `measure'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/ddtrace-1.10.1/lib/datadog/tracing/trace_operation.rb:192:in `measure'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/ddtrace-1.10.1/lib/datadog/tracing/tracer.rb:380:in `start_span'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/ddtrace-1.10.1/lib/datadog/tracing/tracer.rb:160:in `block in trace'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/ddtrace-1.10.1/lib/datadog/tracing/context.rb:43:in `activate!'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/ddtrace-1.10.1/lib/datadog/tracing/tracer.rb:159:in `trace'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/ddtrace-1.10.1/lib/datadog/tracing.rb:16:in `trace'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/ddtrace-1.10.1/lib/datadog/tracing/contrib/http/instrumentation.rb:40:in `request'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/opentelemetry-exporter-otlp-0.23.0/lib/opentelemetry/exporter/otlp/exporter.rb:163:in `block (2 levels) in send_bytes'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/opentelemetry-exporter-otlp-0.23.0/lib/opentelemetry/exporter/otlp/exporter.rb:237:in `measure_request_duration'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/opentelemetry-exporter-otlp-0.23.0/lib/opentelemetry/exporter/otlp/exporter.rb:163:in `block in send_bytes'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/opentelemetry-exporter-otlp-0.23.0/lib/opentelemetry/exporter/otlp/exporter.rb:131:in `block in around_request'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/opentelemetry-common-0.19.7/lib/opentelemetry/common/utilities.rb:92:in `block in untraced'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/opentelemetry-api-1.1.0/lib/opentelemetry/context.rb:87:in `with_value'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/opentelemetry-common-0.19.7/lib/opentelemetry/common/utilities.rb:91:in `untraced'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/opentelemetry-exporter-otlp-0.23.0/lib/opentelemetry/exporter/otlp/exporter.rb:131:in `around_request'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/opentelemetry-exporter-otlp-0.23.0/lib/opentelemetry/exporter/otlp/exporter.rb:155:in `send_bytes'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/opentelemetry-exporter-otlp-0.23.0/lib/opentelemetry/exporter/otlp/exporter.rb:89:in `export'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/opentelemetry-sdk-1.1.0/lib/opentelemetry/sdk/trace/export/batch_span_processor.rb:187:in `block in export_batch'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/opentelemetry-sdk-1.1.0/lib/opentelemetry/sdk/trace/export/batch_span_processor.rb:187:in `synchronize'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/opentelemetry-sdk-1.1.0/lib/opentelemetry/sdk/trace/export/batch_span_processor.rb:187:in `export_batch'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/opentelemetry-sdk-1.1.0/lib/opentelemetry/sdk/trace/export/batch_span_processor.rb:170:in `block in work'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/opentelemetry-sdk-1.1.0/lib/opentelemetry/sdk/trace/export/batch_span_processor.rb:159:in `loop'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/opentelemetry-sdk-1.1.0/lib/opentelemetry/sdk/trace/export/batch_span_processor.rb:159:in `work'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/opentelemetry-sdk-1.1.0/lib/opentelemetry/sdk/trace/export/batch_span_processor.rb:180:in `block in reset_on_fork'
	from /usr/src/app/vendor/bundle/ruby/2.6.0/gems/hamelin-1.1.3/lib/hamelin/core_ext/threads.rb:14:in `block in initialize'

I came across this PR where it indicates that opentelemetry tracers have been built using the datadog auto-instrumentation library as a starting point and wonder if that could have any impact here.

I've provided my Opentelemetry configuration below.

OpenTelemetry configuration
require 'opentelemetry/sdk'
require 'opentelemetry/instrumentation/all'
require 'opentelemetry-exporter-otlp'

OpenTelemetry::SDK.configure do |c|
  c.service_name = 'basic-web'

  c.use 'OpenTelemetry::Instrumentation::ActiveSupport'
  c.use 'OpenTelemetry::Instrumentation::Rack'
  c.use 'OpenTelemetry::Instrumentation::AwsSdk'
  c.use 'OpenTelemetry::Instrumentation::HTTP'
  c.use 'OpenTelemetry::Instrumentation::ConcurrentRuby'
  c.use 'OpenTelemetry::Instrumentation::Dalli'
  c.use 'OpenTelemetry::Instrumentation::Ethon'
  c.use 'OpenTelemetry::Instrumentation::Faraday'
  c.use 'OpenTelemetry::Instrumentation::HttpClient'
  c.use 'OpenTelemetry::Instrumentation::Net::HTTP'
  c.use 'OpenTelemetry::Instrumentation::Rake'
  c.use 'OpenTelemetry::Instrumentation::Redis'
  c.use 'OpenTelemetry::Instrumentation::RestClient'
  c.use 'OpenTelemetry::Instrumentation::Sidekiq'

  c.add_span_processor(
    OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor.new(
      OpenTelemetry::Exporter::OTLP::Exporter.new(endpoint: "http://#{ENV['DD_AGENT_HOST']}:4318/v1/traces")
    )
  )
end

@agunn-so
Copy link

Seeing this as well, following

@marcotc
Copy link
Member

marcotc commented Jun 28, 2024

I'm taking a look into this issue next week. I'll report back.

@Ataraxic
Copy link

Ran into this as well. Subscribed. Thanks.

@anandhasudhan
Copy link
Author

Based on my investigation, I realized that it is not possible to have both data dog and opentelemetry auto-instrumentation code running in parallel. Please correct me if I'm wrong.

I took a deep dive at the implementation of both datadog and opentelemetry auto-instrumentation code. Both overload the request method in the Net::HTTP module. So when datadog is trying to instrument the HTTP requests, it ends up calling opentelemetry code since that overloads the same set of methods (annotate_span_with_response!) in the Net::HTTP module leading to argument errors. To run both datadog and opentelemetry code in parallel, we would need to create our own wrapper class that encapsulates both the datadog and opentelemetry tracing logic at which point it's better to avoid and just use one library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Involves a bug community Was opened by a community member tracing
Projects
None yet
Development

No branches or pull requests

5 participants