-
Notifications
You must be signed in to change notification settings - Fork 377
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../../configuration/settings' | ||
require_relative '../ext' | ||
|
||
module Datadog | ||
module Tracing | ||
module Contrib | ||
module Stripe | ||
module Configuration | ||
# Custom settings for the Stripe integration | ||
# @public_api | ||
class Settings < Contrib::Configuration::Settings | ||
option :enabled do |o| | ||
o.default { env_to_bool(Ext::ENV_ENABLED, true) } | ||
o.lazy | ||
end | ||
|
||
option :analytics_enabled do |o| | ||
o.default { env_to_bool(Ext::ENV_ANALYTICS_ENABLED, false) } | ||
o.lazy | ||
end | ||
|
||
option :analytics_sample_rate do |o| | ||
o.default { env_to_float(Ext::ENV_ANALYTICS_SAMPLE_RATE, 1.0) } | ||
o.lazy | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# frozen_string_literal: true | ||
|
||
module Datadog | ||
module Tracing | ||
module Contrib | ||
module Stripe | ||
# Stripe integration constants | ||
# @public_api Changing resource names, tag names, or environment variables creates breaking changes. | ||
module Ext | ||
ENV_ENABLED = 'DD_TRACE_STRIPE_ENABLED' | ||
ENV_ANALYTICS_ENABLED = 'DD_TRACE_STRIPE_ANALYTICS_ENABLED' | ||
ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_STRIPE_ANALYTICS_SAMPLE_RATE' | ||
SPAN_REQUEST = 'stripe.request' | ||
SPAN_TYPE_REQUEST = 'custom' | ||
TAG_COMPONENT = 'stripe' | ||
TAG_OPERATION_REQUEST = 'request' | ||
TAG_REQUEST_HTTP_STATUS = 'stripe.request.http_status' | ||
TAG_REQUEST_ID = 'stripe.request.id' | ||
TAG_REQUEST_METHOD = 'stripe.request.method' | ||
TAG_REQUEST_NUM_RETRIES = 'stripe.request.num_retries' | ||
TAG_REQUEST_PATH = 'stripe.request.path' | ||
end | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../integration' | ||
require_relative 'configuration/settings' | ||
require_relative 'patcher' | ||
|
||
module Datadog | ||
module Tracing | ||
module Contrib | ||
module Stripe | ||
# Description of Stripe integration | ||
class Integration | ||
include Contrib::Integration | ||
|
||
MINIMUM_VERSION = Gem::Version.new('5.15.0') | ||
|
||
# @public_api Changing the integration name or integration options can cause breaking changes | ||
register_as :stripe | ||
|
||
def self.version | ||
Gem.loaded_specs['stripe'] && Gem.loaded_specs['stripe'].version | ||
end | ||
|
||
def self.loaded? | ||
!defined?(::Stripe).nil? | ||
end | ||
|
||
def self.compatible? | ||
super && version >= MINIMUM_VERSION | ||
end | ||
|
||
def new_configuration | ||
Configuration::Settings.new | ||
end | ||
|
||
def patcher | ||
Patcher | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# frozen_string_literal: true | ||
# typed: false | ||
|
||
require_relative '../patcher' | ||
require_relative 'request' | ||
|
||
module Datadog | ||
module Tracing | ||
module Contrib | ||
module Stripe | ||
# Provides instrumentation for `stripe` through the Stripe instrumentation framework | ||
module Patcher | ||
include Contrib::Patcher | ||
|
||
module_function | ||
|
||
def target_version | ||
Integration.version | ||
end | ||
|
||
def patch | ||
::Stripe::Instrumentation.subscribe(:request_begin, :datadog_tracing) { |event| Request.start_span(event) } | ||
::Stripe::Instrumentation.subscribe(:request_end, :datadog_tracing) { |event| Request.finish_span(event) } | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |