gocbopentelemetry

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 License: Apache-2.0 Imports: 9 Imported by: 1

README

Couchbase Gocb Opentelemetry

This is the official Couchbase Go OpenTelemetry wrapper for use with the [http://github.com/couchbase/gocb] (Couchbase Go Client).

This repository provides wrappers for tracing and metrics and will remain v0.x until a time when Opentelemetry Go itself is stable.

Installing

go get github.com/couchbase/gocb-opentelemetry

Tracing

tp := sdktrace.NewTracerProvider(sdktrace.WithSpanProcessor(bsp))
defer tp.Shutdown(ctx)

cluster, err := gocb.Connect(server, gocb.ClusterOptions{
    Authenticator: gocb.PasswordAuthenticator{
        Username: user,
        Password: password,
    },
    Tracer: NewOpenTelemetryRequestTracer(tp),
})
if err != nil {
	panic(err)
}
defer cluster.Close(nil)

b := cluster.Bucket(bucket)
err = b.WaitUntilReady(5*time.Second, nil)
if err != nil {
    panic(err)
}

ctx, span := tracer.Start(ctx, "myparentoperation")
_, err = col.Upsert("someid", "someval", &gocb.UpsertOptions{
    ParentSpan: NewOpenTelemetryRequestSpan(ctx, span),
})
span.End()
if err != nil {
    panic(err)
}

Note that you do not need to call End on wrapped spans, the returned RequestSpan is just a wrapper around the span provided.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OpenTelemetryMeter

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

OpenTelemetryMeter is an implementation of the gocb Meter interface which wraps an OpenTelemetry meter.

func NewOpenTelemetryMeter

func NewOpenTelemetryMeter(provider metric.MeterProvider) *OpenTelemetryMeter

NewOpenTelemetryMeter creates a new OpenTelemetryMeter.

func (*OpenTelemetryMeter) Counter

func (meter *OpenTelemetryMeter) Counter(name string, tags map[string]string) (gocb.Counter, error)

Counter provides a wrapped OpenTelemetry Counter.

func (*OpenTelemetryMeter) Provider added in v0.2.0

func (meter *OpenTelemetryMeter) Provider() metric.MeterProvider

func (*OpenTelemetryMeter) ValueRecorder

func (meter *OpenTelemetryMeter) ValueRecorder(name string, tags map[string]string) (gocb.ValueRecorder, error)

ValueRecorder provides a wrapped OpenTelemetry ValueRecorder.

func (*OpenTelemetryMeter) Wrapped added in v0.2.0

func (meter *OpenTelemetryMeter) Wrapped() metric.Meter

type OpenTelemetryRequestSpan

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

OpenTelemetryRequestSpan is an implementation of the gocb Span interface which wraps an OpenTelemetry span.

func NewOpenTelemetryRequestSpan

func NewOpenTelemetryRequestSpan(ctx context.Context, span trace.Span) *OpenTelemetryRequestSpan

NewOpenTelemetryRequestSpan creates a new OpenTelemetryRequestSpan.

func (*OpenTelemetryRequestSpan) AddEvent

func (span *OpenTelemetryRequestSpan) AddEvent(key string, timestamp time.Time)

AddEvent adds an event to this span.

func (*OpenTelemetryRequestSpan) Context

func (span *OpenTelemetryRequestSpan) Context() gocb.RequestSpanContext

Context returns the RequestSpanContext for this span.

func (*OpenTelemetryRequestSpan) End

func (span *OpenTelemetryRequestSpan) End()

End completes the span.

func (*OpenTelemetryRequestSpan) SetAttribute

func (span *OpenTelemetryRequestSpan) SetAttribute(key string, value interface{})

SetAttribute adds an attribute to this span.

func (*OpenTelemetryRequestSpan) Wrapped added in v0.2.0

func (span *OpenTelemetryRequestSpan) Wrapped() trace.Span

type OpenTelemetryRequestTracer

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

OpenTelemetryRequestTracer is an implementation of the gocb Tracer interface which wraps an OpenTelemetry tracer.

func NewOpenTelemetryRequestTracer

func NewOpenTelemetryRequestTracer(provider trace.TracerProvider) *OpenTelemetryRequestTracer

NewOpenTelemetryRequestTracer creates a new OpenTelemetryRequestTracer.

func (*OpenTelemetryRequestTracer) Provider added in v0.2.0

func (tracer *OpenTelemetryRequestTracer) Provider() trace.TracerProvider

func (*OpenTelemetryRequestTracer) RequestSpan

func (tracer *OpenTelemetryRequestTracer) RequestSpan(parentContext gocb.RequestSpanContext, operationName string) gocb.RequestSpan

RequestSpan provides a wrapped OpenTelemetry Span.

func (*OpenTelemetryRequestTracer) Wrapped added in v0.2.0

func (tracer *OpenTelemetryRequestTracer) Wrapped() trace.Tracer

Jump to

Keyboard shortcuts

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