mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-23 00:30:57 +01:00
Add OpenTelemetry instrumentation (#30130)
Co-authored-by: Juliano Costa <juliano.costa@datadoghq.com> Co-authored-by: Robb Kidd <robbkidd@honeycomb.io>
This commit is contained in:
parent
0d397db5dd
commit
68b9fe824d
3 changed files with 189 additions and 0 deletions
18
Gemfile
18
Gemfile
|
@ -103,6 +103,24 @@ gem 'rdf-normalize', '~> 0.5'
|
||||||
|
|
||||||
gem 'private_address_check', '~> 0.5'
|
gem 'private_address_check', '~> 0.5'
|
||||||
|
|
||||||
|
group :opentelemetry do
|
||||||
|
gem 'opentelemetry-exporter-otlp', '~> 0.26.3', require: false
|
||||||
|
gem 'opentelemetry-instrumentation-active_job', '~> 0.7.1', require: false
|
||||||
|
gem 'opentelemetry-instrumentation-active_model_serializers', '~> 0.20.1', require: false
|
||||||
|
gem 'opentelemetry-instrumentation-concurrent_ruby', '~> 0.21.2', require: false
|
||||||
|
gem 'opentelemetry-instrumentation-excon', '~> 0.22.0', require: false
|
||||||
|
gem 'opentelemetry-instrumentation-faraday', '~> 0.24.1', require: false
|
||||||
|
gem 'opentelemetry-instrumentation-http', '~> 0.23.2', require: false
|
||||||
|
gem 'opentelemetry-instrumentation-http_client', '~> 0.22.3', require: false
|
||||||
|
gem 'opentelemetry-instrumentation-net_http', '~> 0.22.4', require: false
|
||||||
|
gem 'opentelemetry-instrumentation-pg', '~> 0.27.1', require: false
|
||||||
|
gem 'opentelemetry-instrumentation-rack', '~> 0.24.1', require: false
|
||||||
|
gem 'opentelemetry-instrumentation-rails', '~> 0.30.0', require: false
|
||||||
|
gem 'opentelemetry-instrumentation-redis', '~> 0.25.3', require: false
|
||||||
|
gem 'opentelemetry-instrumentation-sidekiq', '~> 0.25.2', require: false
|
||||||
|
gem 'opentelemetry-sdk', '~> 1.4', require: false
|
||||||
|
end
|
||||||
|
|
||||||
group :test do
|
group :test do
|
||||||
# Adds RSpec Error/Warning annotations to GitHub PRs on the Files tab
|
# Adds RSpec Error/Warning annotations to GitHub PRs on the Files tab
|
||||||
gem 'rspec-github', '~> 2.4', require: false
|
gem 'rspec-github', '~> 2.4', require: false
|
||||||
|
|
108
Gemfile.lock
108
Gemfile.lock
|
@ -284,6 +284,9 @@ GEM
|
||||||
ruby-progressbar (~> 1.4)
|
ruby-progressbar (~> 1.4)
|
||||||
globalid (1.2.1)
|
globalid (1.2.1)
|
||||||
activesupport (>= 6.1)
|
activesupport (>= 6.1)
|
||||||
|
google-protobuf (3.25.3)
|
||||||
|
googleapis-common-protos-types (1.14.0)
|
||||||
|
google-protobuf (~> 3.18)
|
||||||
haml (6.3.0)
|
haml (6.3.0)
|
||||||
temple (>= 0.8.2)
|
temple (>= 0.8.2)
|
||||||
thor
|
thor
|
||||||
|
@ -483,6 +486,96 @@ GEM
|
||||||
openssl (3.2.0)
|
openssl (3.2.0)
|
||||||
openssl-signature_algorithm (1.3.0)
|
openssl-signature_algorithm (1.3.0)
|
||||||
openssl (> 2.0)
|
openssl (> 2.0)
|
||||||
|
opentelemetry-api (1.2.5)
|
||||||
|
opentelemetry-common (0.20.1)
|
||||||
|
opentelemetry-api (~> 1.0)
|
||||||
|
opentelemetry-exporter-otlp (0.26.3)
|
||||||
|
google-protobuf (~> 3.14)
|
||||||
|
googleapis-common-protos-types (~> 1.3)
|
||||||
|
opentelemetry-api (~> 1.1)
|
||||||
|
opentelemetry-common (~> 0.20)
|
||||||
|
opentelemetry-sdk (~> 1.2)
|
||||||
|
opentelemetry-semantic_conventions
|
||||||
|
opentelemetry-helpers-sql-obfuscation (0.1.0)
|
||||||
|
opentelemetry-common (~> 0.20)
|
||||||
|
opentelemetry-instrumentation-action_pack (0.9.0)
|
||||||
|
opentelemetry-api (~> 1.0)
|
||||||
|
opentelemetry-instrumentation-base (~> 0.22.1)
|
||||||
|
opentelemetry-instrumentation-rack (~> 0.21)
|
||||||
|
opentelemetry-instrumentation-action_view (0.7.0)
|
||||||
|
opentelemetry-api (~> 1.0)
|
||||||
|
opentelemetry-instrumentation-active_support (~> 0.1)
|
||||||
|
opentelemetry-instrumentation-base (~> 0.22.1)
|
||||||
|
opentelemetry-instrumentation-active_job (0.7.1)
|
||||||
|
opentelemetry-api (~> 1.0)
|
||||||
|
opentelemetry-instrumentation-base (~> 0.22.1)
|
||||||
|
opentelemetry-instrumentation-active_model_serializers (0.20.1)
|
||||||
|
opentelemetry-api (~> 1.0)
|
||||||
|
opentelemetry-instrumentation-base (~> 0.22.1)
|
||||||
|
opentelemetry-instrumentation-active_record (0.7.1)
|
||||||
|
opentelemetry-api (~> 1.0)
|
||||||
|
opentelemetry-instrumentation-base (~> 0.22.1)
|
||||||
|
opentelemetry-instrumentation-active_support (0.5.1)
|
||||||
|
opentelemetry-api (~> 1.0)
|
||||||
|
opentelemetry-instrumentation-base (~> 0.22.1)
|
||||||
|
opentelemetry-instrumentation-base (0.22.3)
|
||||||
|
opentelemetry-api (~> 1.0)
|
||||||
|
opentelemetry-registry (~> 0.1)
|
||||||
|
opentelemetry-instrumentation-concurrent_ruby (0.21.2)
|
||||||
|
opentelemetry-api (~> 1.0)
|
||||||
|
opentelemetry-instrumentation-base (~> 0.22.1)
|
||||||
|
opentelemetry-instrumentation-excon (0.22.0)
|
||||||
|
opentelemetry-api (~> 1.0)
|
||||||
|
opentelemetry-common (~> 0.20.0)
|
||||||
|
opentelemetry-instrumentation-base (~> 0.22.1)
|
||||||
|
opentelemetry-instrumentation-faraday (0.24.1)
|
||||||
|
opentelemetry-api (~> 1.0)
|
||||||
|
opentelemetry-common (~> 0.20.0)
|
||||||
|
opentelemetry-instrumentation-base (~> 0.22.1)
|
||||||
|
opentelemetry-instrumentation-http (0.23.2)
|
||||||
|
opentelemetry-api (~> 1.0)
|
||||||
|
opentelemetry-instrumentation-base (~> 0.22.1)
|
||||||
|
opentelemetry-instrumentation-http_client (0.22.3)
|
||||||
|
opentelemetry-api (~> 1.0)
|
||||||
|
opentelemetry-common (~> 0.20.0)
|
||||||
|
opentelemetry-instrumentation-base (~> 0.22.1)
|
||||||
|
opentelemetry-instrumentation-net_http (0.22.4)
|
||||||
|
opentelemetry-api (~> 1.0)
|
||||||
|
opentelemetry-common (~> 0.20.0)
|
||||||
|
opentelemetry-instrumentation-base (~> 0.22.1)
|
||||||
|
opentelemetry-instrumentation-pg (0.27.1)
|
||||||
|
opentelemetry-api (~> 1.0)
|
||||||
|
opentelemetry-helpers-sql-obfuscation
|
||||||
|
opentelemetry-instrumentation-base (~> 0.22.1)
|
||||||
|
opentelemetry-instrumentation-rack (0.24.1)
|
||||||
|
opentelemetry-api (~> 1.0)
|
||||||
|
opentelemetry-common (~> 0.20.0)
|
||||||
|
opentelemetry-instrumentation-base (~> 0.22.1)
|
||||||
|
opentelemetry-instrumentation-rails (0.30.0)
|
||||||
|
opentelemetry-api (~> 1.0)
|
||||||
|
opentelemetry-instrumentation-action_pack (~> 0.9.0)
|
||||||
|
opentelemetry-instrumentation-action_view (~> 0.7.0)
|
||||||
|
opentelemetry-instrumentation-active_job (~> 0.7.0)
|
||||||
|
opentelemetry-instrumentation-active_record (~> 0.7.0)
|
||||||
|
opentelemetry-instrumentation-active_support (~> 0.5.0)
|
||||||
|
opentelemetry-instrumentation-base (~> 0.22.1)
|
||||||
|
opentelemetry-instrumentation-redis (0.25.3)
|
||||||
|
opentelemetry-api (~> 1.0)
|
||||||
|
opentelemetry-common (~> 0.20.0)
|
||||||
|
opentelemetry-instrumentation-base (~> 0.22.1)
|
||||||
|
opentelemetry-instrumentation-sidekiq (0.25.2)
|
||||||
|
opentelemetry-api (~> 1.0)
|
||||||
|
opentelemetry-common (~> 0.20.0)
|
||||||
|
opentelemetry-instrumentation-base (~> 0.22.1)
|
||||||
|
opentelemetry-registry (0.3.1)
|
||||||
|
opentelemetry-api (~> 1.1)
|
||||||
|
opentelemetry-sdk (1.4.1)
|
||||||
|
opentelemetry-api (~> 1.1)
|
||||||
|
opentelemetry-common (~> 0.20)
|
||||||
|
opentelemetry-registry (~> 0.2)
|
||||||
|
opentelemetry-semantic_conventions
|
||||||
|
opentelemetry-semantic_conventions (1.10.0)
|
||||||
|
opentelemetry-api (~> 1.0)
|
||||||
orm_adapter (0.5.0)
|
orm_adapter (0.5.0)
|
||||||
ox (2.14.18)
|
ox (2.14.18)
|
||||||
parallel (1.24.0)
|
parallel (1.24.0)
|
||||||
|
@ -880,6 +973,21 @@ DEPENDENCIES
|
||||||
omniauth-rails_csrf_protection (~> 1.0)
|
omniauth-rails_csrf_protection (~> 1.0)
|
||||||
omniauth-saml (~> 2.0)
|
omniauth-saml (~> 2.0)
|
||||||
omniauth_openid_connect (~> 0.6.1)
|
omniauth_openid_connect (~> 0.6.1)
|
||||||
|
opentelemetry-exporter-otlp (~> 0.26.3)
|
||||||
|
opentelemetry-instrumentation-active_job (~> 0.7.1)
|
||||||
|
opentelemetry-instrumentation-active_model_serializers (~> 0.20.1)
|
||||||
|
opentelemetry-instrumentation-concurrent_ruby (~> 0.21.2)
|
||||||
|
opentelemetry-instrumentation-excon (~> 0.22.0)
|
||||||
|
opentelemetry-instrumentation-faraday (~> 0.24.1)
|
||||||
|
opentelemetry-instrumentation-http (~> 0.23.2)
|
||||||
|
opentelemetry-instrumentation-http_client (~> 0.22.3)
|
||||||
|
opentelemetry-instrumentation-net_http (~> 0.22.4)
|
||||||
|
opentelemetry-instrumentation-pg (~> 0.27.1)
|
||||||
|
opentelemetry-instrumentation-rack (~> 0.24.1)
|
||||||
|
opentelemetry-instrumentation-rails (~> 0.30.0)
|
||||||
|
opentelemetry-instrumentation-redis (~> 0.25.3)
|
||||||
|
opentelemetry-instrumentation-sidekiq (~> 0.25.2)
|
||||||
|
opentelemetry-sdk (~> 1.4)
|
||||||
ox (~> 2.14)
|
ox (~> 2.14)
|
||||||
parslet
|
parslet
|
||||||
pg (~> 1.5)
|
pg (~> 1.5)
|
||||||
|
|
63
config/initializers/opentelemetry.rb
Normal file
63
config/initializers/opentelemetry.rb
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
# Set OTEL_* environment variables according to OTel docs:
|
||||||
|
# https://opentelemetry.io/docs/concepts/sdk-configuration/
|
||||||
|
|
||||||
|
if ENV.keys.any? { |name| name.match?(/OTEL_.*_ENDPOINT/) }
|
||||||
|
require 'opentelemetry/sdk'
|
||||||
|
require 'opentelemetry/exporter/otlp'
|
||||||
|
|
||||||
|
require 'opentelemetry/instrumentation/active_job'
|
||||||
|
require 'opentelemetry/instrumentation/active_model_serializers'
|
||||||
|
require 'opentelemetry/instrumentation/concurrent_ruby'
|
||||||
|
require 'opentelemetry/instrumentation/excon'
|
||||||
|
require 'opentelemetry/instrumentation/faraday'
|
||||||
|
require 'opentelemetry/instrumentation/http'
|
||||||
|
require 'opentelemetry/instrumentation/http_client'
|
||||||
|
require 'opentelemetry/instrumentation/net/http'
|
||||||
|
require 'opentelemetry/instrumentation/pg'
|
||||||
|
require 'opentelemetry/instrumentation/rack'
|
||||||
|
require 'opentelemetry/instrumentation/rails'
|
||||||
|
require 'opentelemetry/instrumentation/redis'
|
||||||
|
require 'opentelemetry/instrumentation/sidekiq'
|
||||||
|
|
||||||
|
OpenTelemetry::SDK.configure do |c|
|
||||||
|
# use_all() attempts to load ALL the auto-instrumentations
|
||||||
|
# currently loaded by Ruby requires.
|
||||||
|
#
|
||||||
|
# Load attempts will emit an INFO or WARN to the console
|
||||||
|
# about the success/failure to wire up an auto-instrumentation.
|
||||||
|
# "WARN -- : Instrumentation: <X> failed to install" is most
|
||||||
|
# likely caused by <X> not being a Ruby library loaded by
|
||||||
|
# the application or the instrumentation has been explicitly
|
||||||
|
# disabled.
|
||||||
|
#
|
||||||
|
# To disable an instrumentation, set an environment variable
|
||||||
|
# along this pattern:
|
||||||
|
#
|
||||||
|
# OTEL_RUBY_INSTRUMENTATION_<X>_ENABLED=false
|
||||||
|
#
|
||||||
|
# For example, PostgreSQL and Redis produce a lot of child spans
|
||||||
|
# in the course of this application doing its business. To turn
|
||||||
|
# them off, set the env vars below, but recognize that you will
|
||||||
|
# be missing details about what particular calls to the
|
||||||
|
# datastores are slow.
|
||||||
|
#
|
||||||
|
# OTEL_RUBY_INSTRUMENTATION_PG_ENABLED=false
|
||||||
|
# OTEL_RUBY_INSTRUMENTATION_REDIS_ENABLED=false
|
||||||
|
|
||||||
|
c.use_all({
|
||||||
|
'OpenTelemetry::Instrumentation::Rack' => {
|
||||||
|
use_rack_events: false, # instead of events, use middleware; allows for untraced_endpoints to ignore child spans
|
||||||
|
untraced_endpoints: ['/health'],
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
c.service_name = case $PROGRAM_NAME
|
||||||
|
when /puma/ then 'mastodon/web'
|
||||||
|
else
|
||||||
|
"mastodon/#{$PROGRAM_NAME.split('/').last}"
|
||||||
|
end
|
||||||
|
c.service_version = Mastodon::Version.to_s
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue