Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewTraceLoggerObservability ¶
func NewTraceLoggerObservability(ctx context.Context, trace trace.Tracer, logger logger.LoggerInterface, counter *prometheus.CounterVec, duration *prometheus.HistogramVec) *traceLoggerObservability
NewTraceLoggerObservability creates a new traceLoggerObservability instance.
It takes context.Context, trace.Tracer, logger.LoggerInterface, prometheus.CounterVec, and prometheus.HistogramVec as input.
The returned traceLoggerObservability instance includes the input parameters and can be used to start tracing and logging, as well as recording metrics.
If the input context is canceled, the tracing and logging will be stopped.
Types ¶
type TraceLoggerObservability ¶
type TraceLoggerObservability interface {
// StartTracingAndLogging starts tracing for a method, logs that the method has started,
// and returns a span, a function to end the span with a status, the initial status of the span,
// and a function to log success messages.
//
// Parameters:
// - method: The name of the method to trace and log.
// - attrs: Optional attributes to add to the span.
//
// Returns:
// - trace.Span: The OpenTelemetry span for the traced method.
// - func(string): Function to end the span with a given status, recording metrics.
// - string: Initial status of the operation, defaulting to "success".
// - func(string, ...zap.Field): Function to log success messages with optional fields.
StartTracingAndLogging(method string, attrs ...attribute.KeyValue) (
trace.Span,
func(string),
string,
func(string, ...zap.Field),
)
// RecordMetrics records a Prometheus metric for the given method and status.
// It increments a counter and records the duration since the provided start time.
RecordMetrics(method, status string, start time.Time)
}
TraceLoggerObservability provides tracing, logging, and request metrics.
Click to show internal directories.
Click to hide internal directories.