telemetry

package
v0.2.24 Latest Latest
Warning

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

Go to latest
Published: May 18, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ComponentGraphQL  = "graphql"
	ComponentPostgres = "postgres"
	ComponentREST     = "rest"
	ComponentService  = "service"
	ComponentListener = "listener"
	ComponentCronJob  = "cron"
)

Component tag constants

View Source
const (
	SpanTagTenant   = "tenant"
	SpanTagUserId   = "user.id"
	SpanTagEntityId = "entity.id"
)
View Source
const (
	SpanKindInternal = "internal"
	SpanKindServer   = "server"
	SpanKindClient   = "client"
	SpanKindConsumer = "consumer"
)

SpanKind constants

Variables

This section is empty.

Functions

func ExtractOTelSpanID added in v0.2.1

func ExtractOTelSpanID(span trace.Span) string

ExtractOTelSpanID extracts OpenTelemetry span ID from span

func ExtractOTelTraceID added in v0.2.1

func ExtractOTelTraceID(span trace.Span) string

ExtractOTelTraceID extracts OpenTelemetry trace ID from span

func FinishSpans

func FinishSpans(spans *Spans)

FinishSpans ends OpenTelemetry spans

func GetDefaultServiceSpanAttributes added in v0.2.1

func GetDefaultServiceSpanAttributes(ctx context.Context) []attribute.KeyValue

GetDefaultServiceSpanAttributes returns default attributes for service spans

func InitOpenTelemetry

func InitOpenTelemetry(ctx context.Context, cfg *OpenTelemetryConfig) error

InitOpenTelemetry initializes OpenTelemetry with the given configuration

func LogInfo

func LogInfo(ctx context.Context, msg string, fields ...log.Field)

func Recover added in v0.2.15

func Recover(spans *Spans, logger logger.Logger)

func RecoveryWithTelemetry added in v0.2.24

func RecoveryWithTelemetry(log logger.Logger) gin.HandlerFunc

RecoveryWithTelemetry creates a gin middleware that recovers from panics and logs them to both Jaeger and OpenTelemetry

func SetDefaultServiceSpanAttributes added in v0.2.1

func SetDefaultServiceSpanAttributes(ctx context.Context, span trace.Span)

SetDefaultServiceSpanAttributes sets default attributes on a span

func SetSpanKindConsumer

func SetSpanKindConsumer(spans *Spans)

func SetSpanKindDatabase

func SetSpanKindDatabase(spans *Spans)

func SetSpanKindInternal

func SetSpanKindInternal(spans *Spans)

Span Kind Helpers

func SetSpanKindServer

func SetSpanKindServer(spans *Spans)

func TagComponentCronJob

func TagComponentCronJob(spans *Spans)

func TagComponentGraphQL

func TagComponentGraphQL(spans *Spans)

Component Tagging Helpers

func TagComponentListener

func TagComponentListener(spans *Spans)

func TagComponentPostgres

func TagComponentPostgres(spans *Spans)

func TagComponentREST

func TagComponentREST(spans *Spans)

func TagComponentService

func TagComponentService(spans *Spans)

Types

type OpenTelemetryConfig

type OpenTelemetryConfig struct {
	Enabled     bool   `env:"OTEL_ENABLED" envDefault:"true"`
	Endpoint    string `env:"OTEL_ENDPOINT" envDefault:"otel-collector:4319"`
	ServiceName string `env:"OTEL_SERVICE_NAME" envDefault:"mailstack"`
	Timeout     int    `env:"OTEL_TIMEOUT" envDefault:"30"`
}

type SpanOptions added in v0.2.1

type SpanOptions struct {
	NewRoot bool
}

SpanOptions defines options for span creation

func WithNewRoot added in v0.2.1

func WithNewRoot() SpanOptions

WithForceNewTrace returns a SpanOptions that forces creation of a new trace

type Spans

type Spans struct {
	OTel trace.Span
}

Types and Constants

func StartCronSpan

func StartCronSpan(ctx context.Context, operationName string, opts ...SpanOptions) (*Spans, context.Context)

Component-specific Span Starters

func StartGraphQLSpan

func StartGraphQLSpan(ctx context.Context, operationName string, opts ...SpanOptions) (*Spans, context.Context)

func StartListenerSpan

func StartListenerSpan(ctx context.Context, operationName string, opts ...SpanOptions) (*Spans, context.Context)

func StartPostgresSpan

func StartPostgresSpan(ctx context.Context, operationName string, opts ...SpanOptions) (*Spans, context.Context)

func StartRestSpan

func StartRestSpan(ctx context.Context, operationName string, opts ...SpanOptions) (*Spans, context.Context)

func StartServiceSpan

func StartServiceSpan(ctx context.Context, operationName string, opts ...SpanOptions) (*Spans, context.Context)

func StartSpan added in v0.2.15

func StartSpan(ctx context.Context, operationName string, opts ...SpanOptions) (*Spans, context.Context)

Core Span Operations

func (*Spans) Finish added in v0.2.1

func (s *Spans) Finish()

Finish ends OpenTelemetry spans

func (*Spans) LogFields

func (s *Spans) LogFields(fields ...log.Field)

Logging Methods

func (*Spans) LogKV

func (s *Spans) LogKV(alternatingKeyValues ...interface{})

func (*Spans) LogObjectAsJson

func (s *Spans) LogObjectAsJson(key string, obj interface{})

func (*Spans) TagBool

func (s *Spans) TagBool(key string, value bool)

func (*Spans) TagEntity

func (s *Spans) TagEntity(entityId string)

func (*Spans) TagInt

func (s *Spans) TagInt(key string, value int)

func (*Spans) TagString

func (s *Spans) TagString(key, value string)

Tagging Methods

func (*Spans) TagStringSlice

func (s *Spans) TagStringSlice(key string, value []string)

func (*Spans) TagUint32 added in v0.2.1

func (s *Spans) TagUint32(key string, value uint32)

func (*Spans) TraceError

func (s *Spans) TraceError(err error)

Jump to

Keyboard shortcuts

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