tracer

package
v0.0.25 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package tracer to trace function span to apm supported apm is elastic apm, pinpoint apm & opentelemetry

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Setup

func Setup(opts ...Option)

Setup ...

Types

type Option

type Option func(opt *option)

Option ...

func WithElastic

func WithElastic() Option

WithElastic setup tracer package with elastic apm tracing.

func WithOpenTelemetry

func WithOpenTelemetry(tracerName string) Option

WithOpenTelemetry setup tracer package with opentelemetry apm tracing.

func WithPinpoint

func WithPinpoint() Option

WithPinpoint setup tracer package with pinpoint apm tracing.

type Span

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

Span describes an operation within a transaction.

func NewSpan

func NewSpan(ctx context.Context, lvl SpanLevel) (context.Context, *Span)

NewSpan returns span based on layer type.

func RepositoryFuncSpan

func RepositoryFuncSpan(ctx context.Context) (context.Context, *Span)

RepositoryFuncSpan returns span for repository layer type.

func ServiceFuncSpan

func ServiceFuncSpan(ctx context.Context) (context.Context, *Span)

ServiceFuncSpan returns span for service layer type.

func (*Span) AddEvent

func (s *Span) AddEvent(eventName string, opts ...otelTrace.EventOption)

AddEvent proxy opentelemetry func.

func (*Span) End

func (s *Span) End()

End ends span event.

func (*Span) SetAttributes

func (s *Span) SetAttributes(kv ...attribute.KeyValue)

SetAttributes proxy opentelemetry func.

type SpanLevel

type SpanLevel string

SpanLevel describes span at source code logic level.

var (
	// SpanLvlServiceLogic for service function / methods.
	SpanLvlServiceLogic SpanLevel = "service"
	// SpanLvlDBQuery for db query call / repository level.
	SpanLvlDBQuery SpanLevel = "database"
	// SpanLvlHTTPCall for HTTP api client api call level.
	SpanLvlHTTPCall SpanLevel = "http.client"
	// SpanLvlGrpcCall for gRPC api client api call level.
	SpanLvlGrpcCall SpanLevel = "grpc.client"
	// SpanLvlHandler for http controller / handler func.
	SpanLvlHandler SpanLevel = "handler"
)

Jump to

Keyboard shortcuts

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