Skip to content

Commit

Permalink
feat: setup datadog instrumentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Saad Yousaf authored and Saad Yousaf committed Apr 5, 2024
1 parent 0dc490e commit bcaddca
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions Gemfile3
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,4 @@ gem "rack-contrib", :git => 'https://github.com/rack/rack-contrib.git', :ref =>


gem "timecop", "~> 0.9.5"
gem 'ddtrace', require: 'ddtrace/auto_instrument'
20 changes: 20 additions & 0 deletions Gemfile3.lock
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ GEM
bigdecimal
rexml
dalli (3.2.8)
datadog-ci (0.8.3)
msgpack
ddtrace (1.21.1)
datadog-ci (~> 0.8.1)
debase-ruby_core_source (= 3.3.1)
libdatadog (~> 6.0.0.2.0)
libddwaf (~> 1.14.0.0.0)
msgpack
debase-ruby_core_source (3.3.1)
delayed_job (4.1.11)
activesupport (>= 3.0, < 8.0)
delayed_job_mongoid (3.0.0)
Expand Down Expand Up @@ -107,6 +116,15 @@ GEM
i18n (1.14.1)
concurrent-ruby (~> 1.0)
kgio (2.11.4)
libdatadog (6.0.0.2.0)
libdatadog (6.0.0.2.0-aarch64-linux)
libdatadog (6.0.0.2.0-x86_64-linux)
libddwaf (1.14.0.0.0-aarch64-linux)
ffi (~> 1.0)
libddwaf (1.14.0.0.0-arm64-darwin)
ffi (~> 1.0)
libddwaf (1.14.0.0.0-x86_64-linux)
ffi (~> 1.0)
listen (3.8.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
Expand All @@ -128,6 +146,7 @@ GEM
mongoid_magic_counter_cache (1.1.1)
mongoid
rake
msgpack (1.7.2)
multi_json (1.15.0)
multipart-post (2.4.0)
mustermann (3.0.0)
Expand Down Expand Up @@ -235,6 +254,7 @@ DEPENDENCIES
bundler
codecov
dalli
ddtrace
delayed_job
delayed_job_mongoid
elasticsearch (~> 7.8.0)
Expand Down
1 change: 1 addition & 0 deletions config.ru
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ use Mongoid::QueryCache::Middleware

require './app'
run Sinatra::Application

11 changes: 11 additions & 0 deletions config/unicorn_tcp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
timeout 25
preload_app true

service_name = 'forum'

# Add Datadog APM configuration
Datadog.configure do |c|
c.use :rails, service_name: service_name
c.use :sinatra, service_name: service_name
end

listen_host = ENV['LISTEN_HOST'] || '0.0.0.0'
listen_port = ENV['LISTEN_PORT'] || '4567'
listen "#{listen_host}:#{listen_port}", :tcp_nopush => true, :backlog => 512
Expand All @@ -20,8 +28,11 @@
after_fork do |server, worker|
::Mongoid.default_client.close
::Mongoid.default_client.reconnect
Datadog.tracer.provider.context_flush
Datadog.tracer.provider.context_flush
end

before_fork do |server, worker|
::Mongoid.disconnect_clients
Datadog.tracer.shutdown! if defined?(Datadog) && Datadog.tracer
end

0 comments on commit bcaddca

Please sign in to comment.