package semconv
import "github.com/XSAM/otelsql/internal/semconv"
Package semconv contains semantic convention definitions and utilities for database attributes used by the otelsql package.
Index ¶
- Constants
- func ErrorTypeAttributes(err error) []attribute.KeyValue
- func NewDBQueryTextAttributes(optInType OTelSemConvStabilityOptInType) func(query string) []attribute.KeyValue
- type OTelSemConvStabilityOptInType
Constants ¶
const OTelSemConvStabilityOptIn = "OTEL_SEMCONV_STABILITY_OPT_IN"
OTelSemConvStabilityOptIn is an environment variable. It can be set to "database/dup" to emit both the old and the stable database conventions, allowing for a seamless transition.
https://opentelemetry.io/docs/specs/semconv/database/
Functions ¶
func ErrorTypeAttributes ¶
ErrorTypeAttributes converts an error to a slice of attribute.KeyValue.
func NewDBQueryTextAttributes ¶
func NewDBQueryTextAttributes(optInType OTelSemConvStabilityOptInType) func(query string) []attribute.KeyValue
NewDBQueryTextAttributes returns a function that generates appropriate database query attributes based on the provided OTelSemConvStabilityOptInType.
- OTelSemConvStabilityOptInNone: Only legacy db.statement attribute
- OTelSemConvStabilityOptInDup: Both legacy db.statement and stable db.query.text attributes
- OTelSemConvStabilityOptInStable: Only stable db.query.text attribute
Types ¶
type OTelSemConvStabilityOptInType ¶
type OTelSemConvStabilityOptInType int
OTelSemConvStabilityOptInType represents the type of semantic convention stability opt-in.
const ( // OTelSemConvStabilityOptInNone indicates no opt-in. // This is the default behavior. It only emits the old database semantic conventions. OTelSemConvStabilityOptInNone OTelSemConvStabilityOptInType = iota // OTelSemConvStabilityOptInDup indicates to emit both old and new stable database conventions. OTelSemConvStabilityOptInDup // OTelSemConvStabilityOptInStable indicates to only emit new stable database conventions. OTelSemConvStabilityOptInStable )
func ParseOTelSemConvStabilityOptIn ¶
func ParseOTelSemConvStabilityOptIn() OTelSemConvStabilityOptInType
ParseOTelSemConvStabilityOptIn reads the OTEL_SEMCONV_STABILITY_OPT_IN environment variable and returns the corresponding OTelSemConvStabilityOptInType value based on its content. It prioritizes checking for "database/dup" before "database" to determine the opt-in type.
Source Files ¶
- Version
- v0.39.0 (latest)
- Published
- Jun 5, 2025
- Platform
- linux/amd64
- Imports
- 9 packages
- Last checked
- 1 day ago –
Tools for package owners.