Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Adjust some OpenTelemetry configuration

Christophe Bliard18b6233d5558
diff --git a/config/initializers/opentelemetry.rb b/config/initializers/opentelemetry.rb
index dc3dd5a41ad..9f4e157dc4b 100644
--- a/config/initializers/opentelemetry.rb
+++ b/config/initializers/opentelemetry.rb
@@ -53,9 +53,11 @@ Rails.application.configure do
c.resource = OpenTelemetry::SDK::Resources::Resource.create(
{
- "deployment.environment" => Rails.env,
- "service.namespace" => "openproject",
- "service.instance.id" => Socket.gethostname
+ OpenTelemetry::SemConv::Incubating::DEPLOYMENT::DEPLOYMENT_ENVIRONMENT => Rails.env,
+ OpenTelemetry::SemConv::Incubating::SERVICE::SERVICE_INSTANCE_ID => SecureRandom.uuid,
+ OpenTelemetry::SemConv::Incubating::SERVICE::SERVICE_NAME => OpenProject::OpenTelemetry.process_type,
+ OpenTelemetry::SemConv::Incubating::SERVICE::SERVICE_NAMESPACE => "openproject",
+ OpenTelemetry::SemConv::Incubating::SERVICE::SERVICE_VERSION => OpenProject::VERSION.to_s
}.transform_values(&:to_s)
)
diff --git a/lib_static/open_project/opentelemetry.rb b/lib_static/open_project/opentelemetry.rb
index d3212e9bf69..3a4e126a706 100644
--- a/lib_static/open_project/opentelemetry.rb
+++ b/lib_static/open_project/opentelemetry.rb
@@ -121,5 +121,24 @@ module OpenProject
span.set_attribute(key.to_s, value.to_s)
end
end
+
+ # Determine process type
+ def process_type # rubocop:disable Metrics/PerceivedComplexity
+ if defined?(Rails::Server)
+ "web"
+ elsif defined?(Rails::Console)
+ "console"
+ elsif defined?(Rails::Runner)
+ "runner"
+ elsif defined?(Rails::Generators)
+ "generator"
+ elsif defined?(Rake) && Rake.application.top_level_tasks.any?
+ "rake"
+ elsif defined?(GoodJob::CLI) && GoodJob::CLI.within_exec?
+ "worker"
+ else
+ "unknown"
+ end
+ end
end
end