Module: Datadog::Tracing::Contrib::Mysql2::Instrumentation::InstanceMethods
- Defined in:
- lib/datadog/tracing/contrib/mysql2/instrumentation.rb
Overview
Mysql2::Client patch instance methods
Instance Method Summary collapse
Instance Method Details
#query(sql, options = {}) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/datadog/tracing/contrib/mysql2/instrumentation.rb', line 22 def query(sql, = {}) service = Datadog.configuration_for(self, :service_name) || datadog_configuration[:service_name] on_error = Datadog.configuration_for(self, :on_error) || datadog_configuration[:on_error] Tracing.trace(Ext::SPAN_QUERY, service: service, on_error: on_error) do |span, trace_op| span.resource = sql span.type = Tracing::Metadata::Ext::SQL::TYPE if datadog_configuration[:peer_service] span.set_tag( Tracing::Metadata::Ext::TAG_PEER_SERVICE, datadog_configuration[:peer_service] ) end # Tag original global service name if not used if span.service != Datadog.configuration.service span.set_tag(Tracing::Contrib::Ext::Metadata::TAG_BASE_SERVICE, Datadog.configuration.service) end span.set_tag(Contrib::Ext::DB::TAG_SYSTEM, Ext::TAG_SYSTEM) span.set_tag(Tracing::Metadata::Ext::TAG_KIND, Tracing::Metadata::Ext::SpanKind::TAG_CLIENT) span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT) span.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_QUERY) span.set_tag(Tracing::Metadata::Ext::TAG_PEER_HOSTNAME, [:host]) # Set analytics sample rate Contrib::Analytics.set_sample_rate(span, analytics_sample_rate) if analytics_enabled? span.set_tag(Contrib::Ext::DB::TAG_INSTANCE, [:database]) span.set_tag(Ext::TAG_DB_NAME, [:database]) span.set_tag(Tracing::Metadata::Ext::NET::TAG_TARGET_HOST, [:host]) span.set_tag(Tracing::Metadata::Ext::NET::TAG_TARGET_PORT, [:port]) Contrib::SpanAttributeSchema.set_peer_service!(span, Ext::PEER_SERVICE_SOURCES) sql = inject_propagation(span, sql, trace_op) super(sql, ) end end |