semconv

package
v0.41.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package semconv contains semantic convention definitions and utilities for database attributes used by the otelsql package.

Index

Constants

View Source
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/

Variables

This section is empty.

Functions

func ErrorTypeAttributes

func ErrorTypeAttributes(err error) []attribute.KeyValue

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL