lib/ddtrace/contrib/rest_client/request_patch.rb in ddtrace-0.20.0 vs lib/ddtrace/contrib/rest_client/request_patch.rb in ddtrace-0.21.0
- old
+ new
@@ -45,10 +45,14 @@
end
end
def datadog_tag_request(uri, span)
span.resource = method.to_s.upcase
+
+ # Set analytics sample rate
+ Contrib::Analytics.set_sample_rate(span, analytics_sample_rate) if analytics_enabled?
+
span.set_tag(Datadog::Ext::HTTP::URL, uri.path)
span.set_tag(Datadog::Ext::HTTP::METHOD, method.to_s.upcase)
span.set_tag(Datadog::Ext::NET::TARGET_HOST, uri.host)
span.set_tag(Datadog::Ext::NET::TARGET_PORT, uri.port)
end
@@ -80,11 +84,21 @@
raise e
ensure
span.finish
end
+ private
+
def datadog_configuration
Datadog.configuration[:rest_client]
+ end
+
+ def analytics_enabled?
+ Contrib::Analytics.enabled?(datadog_configuration[:analytics_enabled])
+ end
+
+ def analytics_sample_rate
+ datadog_configuration[:analytics_sample_rate]
end
end
end
end
end