opentelemetry

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

README

OpenTelemetry wrappers

OpenTelemetry wrappers propagate traces (spans) accross services.

Usage

service := micro.NewService(
    micro.Name("go.micro.srv.greeter"),
    micro.WrapClient(opentelemetry.NewClientWrapper()),
    micro.WrapHandler(open.NewHandlerWrapper()),
    micro.WrapSubscriber(opentelemetry.NewSubscriberWrapper()),
)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCallWrapper

func NewCallWrapper(opts ...Option) client.CallWrapper

NewCallWrapper accepts an opentracing Tracer and returns a Call Wrapper.

func NewClientWrapper

func NewClientWrapper(opts ...Option) client.Wrapper

NewClientWrapper returns a client.Wrapper that adds monitoring to outgoing requests.

func NewHandlerWrapper

func NewHandlerWrapper(opts ...Option) server.HandlerWrapper

NewHandlerWrapper accepts an opentracing Tracer and returns a Handler Wrapper.

func NewSubscriberWrapper

func NewSubscriberWrapper(opts ...Option) server.SubscriberWrapper

NewSubscriberWrapper accepts an opentracing Tracer and returns a Subscriber Wrapper.

func StartSpanFromContext

func StartSpanFromContext(ctx context.Context, tp trace.TracerProvider, name string, opts ...trace.SpanStartOption) (context.Context, trace.Span)

StartSpanFromContext returns a new span with the given operation name and options. If a span is found in the context, it will be used as the parent of the resulting span.

Types

type CallFilter

type CallFilter func(context.Context, client.Request) bool

CallFilter used to filter client.Call, return true to skip call trace.

type HandlerFilter

type HandlerFilter func(context.Context, server.Request) bool

HandlerFilter used to filter server.Handle, return true to skip handle trace.

type Option

type Option func(*Options)

func WithCallFilter

func WithCallFilter(filter CallFilter) Option

func WithHandleFilter

func WithHandleFilter(filter HandlerFilter) Option

func WithPublishFilter

func WithPublishFilter(filter PublishFilter) Option

func WithStreamFilter

func WithStreamFilter(filter StreamFilter) Option

func WithSubscribeFilter

func WithSubscribeFilter(filter SubscriberFilter) Option

func WithTraceProvider

func WithTraceProvider(tp trace.TracerProvider) Option

type Options

type Options struct {
	TraceProvider trace.TracerProvider

	CallFilter       CallFilter
	StreamFilter     StreamFilter
	PublishFilter    PublishFilter
	SubscriberFilter SubscriberFilter
	HandlerFilter    HandlerFilter
}

type PublishFilter

type PublishFilter func(context.Context, client.Message) bool

PublishFilter used to filter client.Publish, return true to skip publish trace.

type StreamFilter

type StreamFilter func(context.Context, client.Request) bool

StreamFilter used to filter client.Stream, return true to skip stream trace.

type SubscriberFilter

type SubscriberFilter func(context.Context, server.Message) bool

SubscriberFilter used to filter server.Subscribe, return true to skip subcribe trace.

Jump to

Keyboard shortcuts

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