Skip to content
/ otelsql Public
forked from XSAM/otelsql

OpenTelemetry instrumentation for database/sql

License

Notifications You must be signed in to change notification settings

ccpost/otelsql

 
 

Repository files navigation

otelsql

ci codecov Go Report Card Documentation

It is an OpenTelemetry instrumentation for Golang database/sql, a port from open-telemetry/opentelemetry-go-contrib#505.

It can only instrument traces for the present.

Install

$ go get github.com/XSAM/otelsql

Features

Feature Description Status Reason
Rows, RowsClose If set to true, will enable the creation of spans on corresponding calls. Enabled by default We need to know the status of Rows
Query If set to true, will enable recording of sql queries in spans. Enabled by default db.statement will need this, which is a required attribute. https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/semantic_conventions/database.md
Ping If set to true, will enable the creation of spans on Ping requests. Implemented Ping has context argument, but it might no needs to record.
RowsNext If set to true, will enable the creation of events on corresponding calls. This can result in many events. Implemented It provides more visibility.
DisableErrSkip If set to true, will suppress driver.ErrSkip errors in spans. Implemented ErrSkip error might annoying
RecordError If set to true, will invoke the specified function which decides if the error should be recorded or not Implemented This gives the opportunity to check driver specific error codes and not record those that might not be a relevant error (eg. MySQL 1062 Duplicate Entry might be handled in the app and should not be recorded as an error).
AllowRoot If set to true, will allow otelsql to create root spans in absence of existing spans or even context. Implemented It might helpful while debugging missing operations.
RowsAffected, LastInsertID If set to true, will enable the creation of spans on RowsAffected/LastInsertId calls. Dropped Don't know its use cases. We might add this later based on the users' feedback.
QueryParams If set to true, will enable recording of parameters used with parametrized queries. Dropped It will cause high cardinality values and security problems.

Example

See example

Why port this?

Based on this comment, OpenTelemetry SIG team like to see broader usage and community consensus on an approach before they commit to the level of support that would be required of a package in contrib. But it is painful for users without a stable version, and they have to use replacement in go.mod to use this instrumentation.

Therefore, I host this module independently for convenience and make improvements based on users' feedback.

About

OpenTelemetry instrumentation for database/sql

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 91.1%
  • Makefile 5.5%
  • Shell 2.6%
  • Dockerfile 0.8%