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

Rails Auto Instrument not setting _dd.base_service for supported auto instrument integrations. #3973

Open
jatindhankhar opened this issue Oct 4, 2024 · 1 comment
Labels
bug Involves a bug community Was opened by a community member

Comments

@jatindhankhar
Copy link

Current behaviour

Auto Instrumentation in the tracing tag isn't setting the _dd.base_service which leads to un-necessary service creation in the APM services page, ideally these services should be clubbed inside the main service.

[
 Name: redis.command
Span ID: 2021611852373594644
Parent ID: 0
Trace ID: 136909362328890433043090706524994463831
Type: redis
Service: service-name-here
Resource: GET
Error: 0
Start: 1728039096734483968
End: 1728039096742849024
Duration: 0.008146000000124332
Tags: [
   env => development,
   component => redis,
   operation => command,
   peer.hostname => localhost,
   span.kind => client,
   db.system => redis,
   out.host => localhost,
   db.redis.database_index => 0,
   redis.raw_command => GET 1,
   _dd.peer.service.source => peer.hostname,
   peer.service => localhost]
Metrics: [
   out.port => 6379.0,
   out.redis_db => 0.0,
   _dd.top_level => 1.0]]

Image

Expected behaviour

[
 Name: redis.command
Span ID: 1232186374065000963
Parent ID: 0
Trace ID: 136909365101876121041739081064156880567
Type: redis
Service: external-access-manager-service_redis
Resource: GET
Error: 0
Start: 1728039131787262976
End: 1728039131791028992
Duration: 0.0037690000026486814
Tags: [
   env => development,
   _dd.base_service => service-name-here
   component => redis,
   operation => command,
   peer.hostname => localhost,
   span.kind => client,
   db.system => redis,
   out.host => localhost,
   db.redis.database_index => 0,
   redis.raw_command => GET 1,
   _dd.peer.service.source => peer.hostname,
   peer.service => localhost]
Metrics: [
   out.port => 6379.0,
   out.redis_db => 0.0,
   _dd.top_level => 1.0]]

Had to add following line

config.tracing.instrument :redis, service_name: config.service + "_" + "redis"

Image

Steps to reproduce

Using Datadog's automatic instrumenation guide - https://docs.datadoghq.com/tracing/trace_collection/automatic_instrumentation/dd_libraries/ruby/ by setting

Gemfile

source 'https://rubygems.org'
gem 'datadog', require: 'datadog/auto_instrument'

config/initializers/datadog.rb

Datadog.configure do |config|
  ## https://docs.datadoghq.com/containers/amazon_ecs/apm/?tab=ec2metadataendpoint#imdsv2.
  ## For task running inside ECS we need to fetch the host IP where the container is running as a daemon :|
  # https://docs.datadoghq.com/tracing/trace_collection/automatic_instrumentation/dd_libraries/ruby/#additional-configuration
  config.service = 'service_name'
  config.agent.host = fetch_ecs_host_ip
  config.profiling.enabled = true
  config.env = Rails.env
  # Changes the default value for service_name to the application service name across all instrumentation
  config.tracing.contrib.global_default_service_name.enabled = true
  config.diagnostics.debug = true
end

How does datadog help you?

Environment

  • datadog version: 2.3.0
  • Configuration block
Datadog.configure do |config|
  ## https://docs.datadoghq.com/containers/amazon_ecs/apm/?tab=ec2metadataendpoint#imdsv2.
  ## For task running inside ECS we need to fetch the host IP where the container is running as a daemon :|
  # https://docs.datadoghq.com/tracing/trace_collection/automatic_instrumentation/dd_libraries/ruby/#additional-configuration
  config.service = 'service_name'
  config.agent.host = fetch_ecs_host_ip
  config.profiling.enabled = true
  config.env = Rails.env
  # Changes the default value for service_name to the application service name across all instrumentation
  config.tracing.contrib.global_default_service_name.enabled = true
  config.diagnostics.debug = true
end
  • Ruby version: ruby 3.3.0p0
  • Operating system: Not Relevant
  • Relevant library versions:
@jatindhankhar jatindhankhar added bug Involves a bug community Was opened by a community member labels Oct 4, 2024
@jatindhankhar
Copy link
Author

integrations.each do |integration_name|
c.tracing.instrument integration_name
end
end
end
end

This should be changed to

integrations.each do |integration_name|
  c.tracing.instrument service_name: config.service + "_" + integration_name
end

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
Projects
None yet
Development

No branches or pull requests

1 participant