From 283a891e9290fc9fdbfd082f3bde48863f1c6f45 Mon Sep 17 00:00:00 2001 From: Renaud Chaput Date: Thu, 16 May 2024 11:28:10 +0200 Subject: [PATCH] Allow to customise the OTEL service name prefix (#30322) --- config/initializers/opentelemetry.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/config/initializers/opentelemetry.rb b/config/initializers/opentelemetry.rb index e50132d461..9af0ab89c8 100644 --- a/config/initializers/opentelemetry.rb +++ b/config/initializers/opentelemetry.rb @@ -53,10 +53,12 @@ if ENV.keys.any? { |name| name.match?(/OTEL_.*_ENDPOINT/) } }, }) + prefix = ENV.fetch('OTEL_SERVICE_NAME_PREFIX', 'mastodon') + c.service_name = case $PROGRAM_NAME - when /puma/ then 'mastodon/web' + when /puma/ then "#{prefix}/web" else - "mastodon/#{$PROGRAM_NAME.split('/').last}" + "#{prefix}/#{$PROGRAM_NAME.split('/').last}" end c.service_version = Mastodon::Version.to_s end