tracing

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package tracing provides business-specific distributed tracing utilities

Index

Constants

View Source
const (
	ErrorCategoryValidation     = "validation"
	ErrorCategoryDatabase       = "database"
	ErrorCategoryAuthentication = "authentication"
	ErrorCategoryAuthorization  = "authorization"
	ErrorCategoryExternal       = "external_service"
	ErrorCategoryInternal       = "internal"
	ErrorCategoryNetwork        = "network"
	ErrorCategoryTimeout        = "timeout"
	ErrorCategoryRateLimit      = "rate_limit"
	ErrorCategoryBusiness       = "business_logic"
)

ErrorCategory constants for categorizing errors

View Source
const (
	ErrorSeverityLow      = "low"
	ErrorSeverityMedium   = "medium"
	ErrorSeverityHigh     = "high"
	ErrorSeverityCritical = "critical"
)

ErrorSeverity constants for error severity levels

Variables

This section is empty.

Functions

func InitGlobalBusinessTracer

func InitGlobalBusinessTracer(config BusinessTracerConfig)

InitGlobalBusinessTracer initializes the global business tracer

func RecordDetailedError

func RecordDetailedError(ctx context.Context, errorInfo ErrorInfo)

RecordDetailedError records an error with detailed information using the global tracer

func RecordError

func RecordError(ctx context.Context, err error)

RecordError records an error in the current span using the global tracer

func RecordErrorWithCategory

func RecordErrorWithCategory(ctx context.Context, err error, operation string, userID *int64)

RecordErrorWithCategory records an error with automatic categorization using the global tracer

func TraceAuthentication

func TraceAuthentication(ctx context.Context, username string, authType string, f func(context.Context) error) error

TraceAuthentication traces authentication operations using the global tracer

func TraceBusinessTransaction

func TraceBusinessTransaction(ctx context.Context, transactionName string, f func(context.Context) error) error

TraceBusinessTransaction traces multi-step business transactions using the global tracer

func TraceChannelOperation

func TraceChannelOperation(ctx context.Context, channelID int32, userID int32, operation string, f func(context.Context) error) error

TraceChannelOperation traces channel-related operations using the global tracer

func TraceChannelSearch

func TraceChannelSearch(ctx context.Context, userID int32, query string, f func(context.Context) (int, error)) (int, error)

TraceChannelSearch traces channel search operations using the global tracer

func TraceOperation

func TraceOperation(ctx context.Context, operationName string, f func(context.Context) error) error

TraceOperation wraps a business operation with tracing using the global tracer

func TraceUserActivation

func TraceUserActivation(ctx context.Context, username, token string, f func(context.Context) error) error

TraceUserActivation traces user activation operations using the global tracer

func TraceUserRegistration

func TraceUserRegistration(ctx context.Context, username, email string, stage string, f func(context.Context) error) error

TraceUserRegistration traces user registration operations using the global tracer

Types

type BusinessTracer

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

BusinessTracer provides tracing utilities for business logic operations

func GetGlobalBusinessTracer

func GetGlobalBusinessTracer() *BusinessTracer

GetGlobalBusinessTracer returns the global business tracer

func NewBusinessTracer

func NewBusinessTracer(config BusinessTracerConfig) *BusinessTracer

NewBusinessTracer creates a new business tracer

func (*BusinessTracer) AddAttributes

func (bt *BusinessTracer) AddAttributes(ctx context.Context, attrs ...attribute.KeyValue)

AddAttributes adds attributes to the current span

func (*BusinessTracer) RecordDetailedError

func (bt *BusinessTracer) RecordDetailedError(ctx context.Context, errorInfo ErrorInfo)

RecordDetailedError records an error with detailed information in the current span

func (*BusinessTracer) RecordError

func (bt *BusinessTracer) RecordError(ctx context.Context, err error)

RecordError records an error in the current span

func (*BusinessTracer) RecordErrorWithCategory

func (bt *BusinessTracer) RecordErrorWithCategory(ctx context.Context, err error, operation string, userID *int64)

RecordErrorWithCategory records an error with automatic categorization

func (*BusinessTracer) SetStatus

func (bt *BusinessTracer) SetStatus(ctx context.Context, code codes.Code, description string)

SetStatus sets the status of the current span

func (*BusinessTracer) StartSpan

func (bt *BusinessTracer) StartSpan(ctx context.Context, operationName string, opts ...trace.SpanStartOption) (context.Context, trace.Span)

StartSpan creates a new child span for business operations

func (*BusinessTracer) TraceAuthentication

func (bt *BusinessTracer) TraceAuthentication(ctx context.Context, username string, authType string, f func(context.Context) error) error

TraceAuthentication traces authentication operations

func (*BusinessTracer) TraceBusinessTransaction

func (bt *BusinessTracer) TraceBusinessTransaction(ctx context.Context, transactionName string, f func(context.Context) error) error

TraceBusinessTransaction traces multi-step business transactions

func (*BusinessTracer) TraceChannelOperation

func (bt *BusinessTracer) TraceChannelOperation(ctx context.Context, channelID int32, userID int32, operation string, f func(context.Context) error) error

TraceChannelOperation traces channel-related operations

func (*BusinessTracer) TraceChannelSearch

func (bt *BusinessTracer) TraceChannelSearch(ctx context.Context, userID int32, query string, f func(context.Context) (int, error)) (int, error)

TraceChannelSearch traces channel search operations

func (*BusinessTracer) TraceOperation

func (bt *BusinessTracer) TraceOperation(ctx context.Context, operationName string, f func(context.Context) error) error

TraceOperation wraps a business operation with tracing

func (*BusinessTracer) TraceUserActivation

func (bt *BusinessTracer) TraceUserActivation(ctx context.Context, username, token string, f func(context.Context) error) error

TraceUserActivation traces user activation operations

func (*BusinessTracer) TraceUserRegistration

func (bt *BusinessTracer) TraceUserRegistration(ctx context.Context, username, email string, stage string, f func(context.Context) error) error

TraceUserRegistration traces user registration operations

type BusinessTracerConfig

type BusinessTracerConfig struct {
	TracerProvider trace.TracerProvider
	ServiceName    string
}

BusinessTracerConfig holds configuration for business tracing

type ErrorInfo

type ErrorInfo struct {
	Error      error
	Category   string
	Severity   string
	UserID     *int64
	Operation  string
	StackTrace []string
	Context    map[string]interface{}
}

ErrorInfo contains detailed information about an error for tracing

Jump to

Keyboard shortcuts

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