Skip to content

Latest commit

 

History

History
53 lines (37 loc) · 2.4 KB

File metadata and controls

53 lines (37 loc) · 2.4 KB

OpenTelemetry Sql Helpers

Todo: Add a description.

How do I get started?

Install the gem using:

gem install opentelemetry-helpers-sql

Or, if you use bundler, include opentelemetry-helpers-sql in your Gemfile.

Usage

This gem is intended to be used by the instrumentation libraries to provide a common set of helpers for SQL-related spans. It is not intended to be used directly by applications.

Some Database libraries do not have enough context to add sufficient details to client spans. In these cases, you can use the OpenTelemetry::Helpers::Sql.with_attributes to create a set of shared attributes to amend to a database span.

# Higher-level instrumentation e.g. ORM
OpenTelemetry::Helpers::Sql.with_attributes({ 'code.namespace' => 'Acme::Customer', 'code.function' => 'truncate!', 'db.operation.name' => 'TRUNCATE', 'db.namespace' => 'customers' }) do
  client.query('TRUNCATE customers')
end

# Client snippet
class OtherSqlClient
  def query(sql)
    tracer.in_span("query", attributes: OpenTelemetry::Helpers::Sql.attributes.merge('db.statement' => sql, 'db.system' => 'other_sql')) do
      connection.query(sql)
    end
  end
end

How can I get involved?

The opentelemetry-helpers-sql gem source is on github, along with related gems including opentelemetry-api and opentelemetry-sdk.

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-sql gem is distributed under the Apache 2.0 license. See LICENSE for more information.