gocbopentelemetry

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

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/nicksherron/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 OpenTelemetryCounter

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

func NewOpenTelemetryCounter

func NewOpenTelemetryCounter(ctx context.Context, counter metric.Int64Counter) *OpenTelemetryCounter

func (*OpenTelemetryCounter) IncrementBy

func (nm *OpenTelemetryCounter) IncrementBy(num uint64)

type OpenTelemetryMeter

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

func NewOpenTelemetryMeter

func NewOpenTelemetryMeter(provider metric.MeterProvider) *OpenTelemetryMeter

func (*OpenTelemetryMeter) Counter

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

func (*OpenTelemetryMeter) ValueRecorder

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

type OpenTelemetryMeterValueRecorder

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

func NewOpenTelemetryValueRecorder

func NewOpenTelemetryValueRecorder(ctx context.Context, valueRecorder metric.Int64ValueRecorder) *OpenTelemetryMeterValueRecorder

func (*OpenTelemetryMeterValueRecorder) RecordValue

func (nm *OpenTelemetryMeterValueRecorder) RecordValue(val uint64)

type OpenTelemetryRequestSpan

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

func NewOpenTelemetryRequestSpan

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

func (*OpenTelemetryRequestSpan) AddEvent

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

func (*OpenTelemetryRequestSpan) Context

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

func (*OpenTelemetryRequestSpan) End

func (span *OpenTelemetryRequestSpan) End()

func (*OpenTelemetryRequestSpan) SetAttribute

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

type OpenTelemetryRequestTracer

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

func NewOpenTelemetryRequestTracer

func NewOpenTelemetryRequestTracer(provider trace.TracerProvider) *OpenTelemetryRequestTracer

func (*OpenTelemetryRequestTracer) RequestSpan

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

Jump to

Keyboard shortcuts

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