Package otelmongo instruments

This package is compatable with v0.2.0 of

`NewMonitor` will return an event.CommandMonitor which is used to trace requests.

This code was originally based on the following: - -





View Source
const (
	DBApplicationKey = attribute.Key("db.application")
	DBNameKey        = attribute.Key("")
	DBSystemKey      = attribute.Key("db.system")
	DBInstanceKey    = attribute.Key("db.instance")
	DBUserKey        = attribute.Key("db.user")
	DBStatementKey   = attribute.Key("db.statement")
View Source
const (
	// PeerHostname records the host name of the peer.
	PeerHostnameKey = attribute.Key("peer.hostname")
	// PeerPort records the port number of the peer.
	PeerPortKey = attribute.Key("peer.port")
View Source
const (
	TargetHostKey  = attribute.Key("")
	TargetPortKey  = attribute.Key("out.port")
	ServiceNameKey = attribute.Key("")
	DBOperationKey = attribute.Key("db.operation")
	ErrorKey       = attribute.Key("error")
	ErrorMsgKey    = attribute.Key("error.msg")


This section is empty.


func DBApplication

func DBApplication(dbApplication string) attribute.KeyValue

DBApplication indicates the application using the database.

func DBInstance

func DBInstance(dbInstance string) attribute.KeyValue

DBInstance indicates the instance name of Database.

func DBName

func DBName(dbName string) attribute.KeyValue

DBName indicates the database name.

func DBOperation

func DBOperation(operation string) attribute.KeyValue

DBOperation defines the name of the operation.

func DBStatement

func DBStatement(dbStatement string) attribute.KeyValue

DBStatement records a database statement for the given database type.

func DBSystem

func DBSystem(dbType string) attribute.KeyValue

DBSystem indicates the system of Database.

func DBUser

func DBUser(dbUser string) attribute.KeyValue

DBUser indicates the user name of Database, e.g. "readonly_user" or "reporting_user".

func Error

func Error(err bool) attribute.KeyValue

Error specifies whether an error occurred.

func ErrorMsg

func ErrorMsg(errorMsg string) attribute.KeyValue

ErrorMsg specifies the error message.

func NewMonitor

func NewMonitor(serviceName string, opts ...Option) *event.CommandMonitor

NewMonitor creates a new mongodb event CommandMonitor.

func PeerHostname

func PeerHostname(peerHostname string) attribute.KeyValue

PeerHostname records the host name of the peer.

func PeerPort

func PeerPort(peerport string) attribute.KeyValue

PeerPort records the port number of the peer.

func ServiceName

func ServiceName(serviceName string) attribute.KeyValue

ServiceName defines the Service name for this Span.

func TargetHost

func TargetHost(targetHost string) attribute.KeyValue

TargetHost sets the target host address.

func TargetPort

func TargetPort(targetPort string) attribute.KeyValue

TargetPort sets the target host port.


type Option

type Option func(*config)

Option specifies instrumentation configuration options.

func WithCommandAttributeDisabled

func WithCommandAttributeDisabled(disabled bool) Option

WithCommandAttributeDisabled specifies if the MongoDB command is added as an attribute to Spans or not. The MongoDB command will be added as an attribute to Spans by default if this option is not provided.

func WithTracerProvider

func WithTracerProvider(provider trace.TracerProvider) Option

WithTracerProvider specifies a tracer provider to use for creating a tracer. If none is specified, the global provider is used.