otelgocql

package module
v0.43.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2023 License: Apache-2.0 Imports: 9 Imported by: 6

Documentation

Overview

Package otelgocql instruments the github.com/gocql/gocql package.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSessionWithTracing

func NewSessionWithTracing(ctx context.Context, cluster *gocql.ClusterConfig, options ...Option) (*gocql.Session, error)

NewSessionWithTracing creates a new session using the given cluster configuration enabling tracing for queries, batch queries, and connection attempts. You may use additional observers and disable specific tracing using the provided `TracedSessionOption`s.

Example
// Create a cluster
host := "localhost"
cluster := gocql.NewCluster(host)

// Create a session with tracing
_, err := NewSessionWithTracing(
	context.Background(),
	cluster,
	// Include any options here
)

if err != nil {
	log.Fatalf("failed to create session, %v", err)
}

// Begin using the session
Output:

func SemVersion deprecated added in v0.24.0

func SemVersion() string

SemVersion is the semantic version to be supplied to tracer/meter creation.

Deprecated: Use Version instead.

func Version added in v0.24.0

func Version() string

Version is the current release version of the gocql instrumentation.

Types

type OTelBatchObserver

type OTelBatchObserver struct {
	// contains filtered or unexported fields
}

OTelBatchObserver implements the gocql.BatchObserver interface to provide instrumentation to gocql batch queries.

func (*OTelBatchObserver) ObserveBatch

func (o *OTelBatchObserver) ObserveBatch(ctx context.Context, observedBatch gocql.ObservedBatch)

ObserveBatch is called once per batch query, and provides instrumentation for it.

type OTelConnectObserver

type OTelConnectObserver struct {
	// contains filtered or unexported fields
}

OTelConnectObserver implements the gocql.ConnectObserver interface to provide instrumentation to connection attempts made by the session.

func (*OTelConnectObserver) ObserveConnect

func (o *OTelConnectObserver) ObserveConnect(observedConnect gocql.ObservedConnect)

ObserveConnect is called once per connection attempt, and provides instrumentation for it.

type OTelQueryObserver

type OTelQueryObserver struct {
	// contains filtered or unexported fields
}

OTelQueryObserver implements the gocql.QueryObserver interface to provide instrumentation to gocql queries.

func (*OTelQueryObserver) ObserveQuery

func (o *OTelQueryObserver) ObserveQuery(ctx context.Context, observedQuery gocql.ObservedQuery)

ObserveQuery is called once per query, and provides instrumentation for it.

type Option added in v0.22.0

type Option interface {
	// contains filtered or unexported methods
}

Option applies a configuration option.

func WithBatchInstrumentation

func WithBatchInstrumentation(enabled bool) Option

WithBatchInstrumentation will enable and disable insturmentation of batch queries. Defaults to enabled.

func WithBatchObserver

func WithBatchObserver(observer gocql.BatchObserver) Option

WithBatchObserver sets an additional BatchObserver to the session configuration. Use this if there is an existing BatchObserver that you would like called. It will be called after the OpenTelemetry implementation, if it is not nil. Defaults to nil.

func WithConnectInstrumentation

func WithConnectInstrumentation(enabled bool) Option

WithConnectInstrumentation will enable and disable instrumentation of connection attempts. Defaults to enabled.

func WithConnectObserver

func WithConnectObserver(observer gocql.ConnectObserver) Option

WithConnectObserver sets an additional ConnectObserver to the session configuration. Use this if there is an existing ConnectObserver that you would like called. It will be called after the OpenTelemetry implementation, if it is not nil. Defaults to nil.

func WithMeterProvider

func WithMeterProvider(provider metric.MeterProvider) Option

WithMeterProvider will set the meter provider used to get a meter for creating instruments. Defaults to global.GetMeterProvider().

func WithQueryInstrumentation

func WithQueryInstrumentation(enabled bool) Option

WithQueryInstrumentation will enable and disable instrumentation of queries. Defaults to enabled.

func WithQueryObserver

func WithQueryObserver(observer gocql.QueryObserver) Option

WithQueryObserver sets an additional QueryObserver to the session configuration. Use this if there is an existing QueryObserver that you would like called. It will be called after the OpenTelemetry implementation, if it is not nil. Defaults to nil.

func WithTracerProvider

func WithTracerProvider(provider trace.TracerProvider) Option

WithTracerProvider will set the trace provider used to get a tracer for creating spans. Defaults to TracerProvider().

Directories

Path Synopsis
example module
test module

Jump to

Keyboard shortcuts

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