From b620137ca747fbde0675e36ac185437a559fcef1 Mon Sep 17 00:00:00 2001 From: Tony Hsu Date: Fri, 2 Dec 2022 14:45:39 +0100 Subject: [PATCH] Environment variable service_name for `dalli` --- .../tracing/contrib/dalli/configuration/settings.rb | 9 ++++++++- lib/datadog/tracing/contrib/dalli/ext.rb | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/datadog/tracing/contrib/dalli/configuration/settings.rb b/lib/datadog/tracing/contrib/dalli/configuration/settings.rb index df15b502cf..f19578aafd 100644 --- a/lib/datadog/tracing/contrib/dalli/configuration/settings.rb +++ b/lib/datadog/tracing/contrib/dalli/configuration/settings.rb @@ -26,7 +26,14 @@ class Settings < Contrib::Configuration::Settings o.lazy end - option :service_name, default: Ext::DEFAULT_PEER_SERVICE_NAME + option :service_name do |o| + o.default do + ENV.fetch(Ext::ENV_SERVICE_NAME) do + Ext::DEFAULT_PEER_SERVICE_NAME + end + end + o.lazy + end end end end diff --git a/lib/datadog/tracing/contrib/dalli/ext.rb b/lib/datadog/tracing/contrib/dalli/ext.rb index e180228898..b73a5bb0b2 100644 --- a/lib/datadog/tracing/contrib/dalli/ext.rb +++ b/lib/datadog/tracing/contrib/dalli/ext.rb @@ -10,6 +10,7 @@ module Ext ENV_ENABLED = 'DD_TRACE_DALLI_ENABLED'.freeze ENV_ANALYTICS_ENABLED = 'DD_TRACE_DALLI_ANALYTICS_ENABLED'.freeze ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_DALLI_ANALYTICS_SAMPLE_RATE'.freeze + ENV_SERVICE_NAME = 'DD_TRACE_DALLI_SERVICE_NAME'.freeze QUANTIZE_MAX_CMD_LENGTH = 100 DEFAULT_PEER_SERVICE_NAME = 'memcached'.freeze SPAN_COMMAND = 'memcached.command'.freeze