Skip to content

Latest commit

 

History

History

OpenTelemetry Instrumentation Helpers: MySQL

This Ruby gem contains logic shared among MySQL adapter libraries, such as mysql2 and trilogy. It's intended for use by by gem authors instrumenting MySQL adapter libraries.

Usage

Add the gem to your instrumentation's gemspec file:

# opentelemetry-instrumentation-your-gem.gemspec
  spec.add_dependency 'opentelemetry-helpers-mysql'

Add the gem to your instrumentation's Gemfile:

# Gemfile

group :test, :development do
  gem 'opentelemetry-helpers-mysql', path: '../../helpers/mysql'
end

Make sure the Instrumentation class for your gem contains configuration options for:

  • :span_name: The type of span name desired for the trace. Example: option :span_name, default: :statement_type, validate: %I[statement_type db_name db_operation_and_name]

Examples

To set the span name in your library:

tracer.in_span(
  OpenTelemetry::Helpers::MySQL.database_span_name(sql, operation, database_name, config),
  attributes: attributes.merge!(OpenTelemetry::Instrumentation::Mysql2.attributes),
  kind: :client
) do
  super(sql, options)
end

How can I get involved?

The opentelemetry-helpers-mysql gem source is on github, along with related gems including opentelemetry-instrumentation-mysql2 and opentelemetry-instrumentation-trilogy.

The OpenTelemetry Ruby gems are maintained by the OpenTelemetry Ruby special interest group (SIG). You can get involved by joining us on our GitHub Discussions, Slack Channel or attending our weekly meeting. See the meeting calendar for dates and times. For more information on this and other language SIGs, see the OpenTelemetry community page.

License

The opentelemetry-helpers-mysql gem is distributed under the Apache 2.0 license. See LICENSE for more information.