tracing

package
v1.0.0-alpha.13 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2022 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TraceLogger

type TraceLogger interface {
	// StartSpan retrieves a logger from the current context and starts a new span
	// named after the current function.
	StartSpan(attrs ...attribute.KeyValue) (context.Context, TraceLogger)

	// StartSpanWithName retrieves a logger from the current context and starts a span with
	// the specified name.
	StartSpanWithName(ops string, attrs ...attribute.KeyValue) (context.Context, TraceLogger)

	// SetAttributes applies additional key/value pairs to the current trace span.
	SetAttributes(attrs ...attribute.KeyValue)

	// EndSpan finishes the span and submits it to the otel endpoint.
	EndSpan(opts ...trace.SpanEndOption)

	// Debug logs a message at the debug level.
	Debug(msg string, attrs ...attribute.KeyValue)

	// Debugf formats a message and logs it at the debug level.
	Debugf(format string, args ...interface{})

	// Info logs a message at the info level.
	Info(msg string, attrs ...attribute.KeyValue)

	// Infof formats a message and logs it at the info level.
	Infof(format string, args ...interface{})

	// Warn logs a message at the warning level.
	Warn(msg string, attrs ...attribute.KeyValue)

	// Warnf formats a message and prints it at the warning level.
	Warnf(format string, args ...interface{})

	// Error logs a message at the error level, when the specified error is not nil,
	// and marks the current span as failed.
	// Example: return log.Error(err)
	// Only log it in the function that generated the error, not when bubbling
	// it up the call stack.
	Error(err error, attrs ...attribute.KeyValue) error

	// Errorf formats an error message and logs it at the error level,
	// and marks the current span as failed.
	// Example: return log.Errorf("oops something happened")
	// Only log it in the function that generated the error, not when bubbling
	// it up the call stack.
	Errorf(msg string, args ...interface{}) error
}

TraceLogger how porter emits traces and logs to any configured listeners.

func LoggerFromContext

func LoggerFromContext(ctx context.Context) TraceLogger

LoggerFromContext retrieves a logger from the specified context. When the context is missing a logger/tracer, no-op implementations are provided.

func NewRootLogger

func NewRootLogger(ctx context.Context, span trace.Span, logger *zap.Logger, tracer trace.Tracer) (context.Context, TraceLogger)

NewRootLogger creates a new TraceLogger and stores in on the context

func StartSpan

func StartSpan(ctx context.Context, attrs ...attribute.KeyValue) (context.Context, TraceLogger)

StartSpan retrieves a logger from the current context and starts a new span named after the current function.

func StartSpanWithName

func StartSpanWithName(ctx context.Context, op string, attrs ...attribute.KeyValue) (context.Context, TraceLogger)

StartSpanWithName retrieves a logger from the current context and starts a span with the specified name.

Jump to

Keyboard shortcuts

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