dd-trace-rb
dd-trace-rb copied to clipboard
Rails Auto Instrument not setting `_dd.base_service` for supported auto instrument integrations.
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]]
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"
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: