Module: Datadog::Tracing::Contrib::Integration
- Included in:
- ActionCable::Integration, ActionMailer::Integration, ActionPack::Integration, ActionView::Integration, ActiveJob::Integration, ActiveModelSerializers::Integration, ActiveRecord::Integration, ActiveSupport::Integration, Aws::Integration, ConcurrentRuby::Integration, Dalli::Integration, DelayedJob::Integration, Elasticsearch::Integration, Ethon::Integration, Excon::Integration, Faraday::Integration, GRPC::Integration, Grape::Integration, GraphQL::Integration, HTTP::Integration, Hanami::Integration, Httpclient::Integration, Httprb::Integration, Kafka::Integration, Lograge::Integration, MongoDB::Integration, Mysql2::Integration, OpenSearch::Integration, Pg::Integration, Presto::Integration, Qless::Integration, Que::Integration, Racecar::Integration, Rack::Integration, Rails::Integration, Rake::Integration, Redis::Integration, Resque::Integration, RestClient::Integration, Roda::Integration, SemanticLogger::Integration, Sequel::Integration, Shoryuken::Integration, Sidekiq::Integration, Sinatra::Integration, Sneakers::Integration, Stripe::Integration, SuckerPunch::Integration, Trilogy::Integration
- Defined in:
- lib/datadog/tracing/contrib/integration.rb
Overview
Integration provides the basic contract of a tracing integration.
An example for a simple instrumentation of a fictional ‘BillingApi::Client`:
“‘ require ’ddtrace’
module BillingApi
class Integration
include ::Datadog::Tracing::Contrib::Integration
register_as :billing_api # Register in the global tracing registry
def self.available?
defined?(::BillingApi::Client) # Check if the target for instrumentation is present.
end
def new_configuration
Settings.new
end
def patcher
Patcher
end
end
class Settings < ::Datadog::Tracing::Contrib::Configuration::Settings
# Custom service name, if a separate service is desirable for BillingApi calls.
option :service, default: nil
end
module Patcher
include ::Datadog::Tracing::Contrib::Patcher
def self.patch
::BillingApi::Client.prepend(Instrumentation)
end
end
module Instrumentation
def api_request!(env)
Tracing.trace('billing.request',
type: 'http',
service: Datadog.configuration.tracing[:billing_api][:service]) do |span|
span.resource = env[:route].to_s
span.set_tag('client_id', env[:client][:id])
super
end
end
end
end
Datadog.configure do |c|
c.tracing.instrument :billing_api # Settings (e.g. `service:`) can be provided as keyword arguments.
end “‘
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
70 71 72 73 74 |
# File 'lib/datadog/tracing/contrib/integration.rb', line 70 def self.included(base) base.include(Configurable) base.include(Patchable) base.include(Registerable) end |