tracing

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2023 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsTraceSensitiveAttributesEnabled added in v1.0.4

func IsTraceSensitiveAttributesEnabled() bool

IsTraceSensitiveAttributesEnabled returns if sensitive data traced with TraceLogger.SetSensitiveAttributes will trace the data. Defaults to false, which means that function is a noop and does nothing.

func ObjectAttribute added in v1.0.4

func ObjectAttribute(key string, value interface{}) attribute.KeyValue

ObjectAttribute writes the specified value as a json encoded value.

Types

type RootTraceLogger

type RootTraceLogger interface {
	TraceLogger

	// Close the tracer and send data to the telemetry collector
	Close()
}

func NewRootLogger

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

NewRootLogger creates a new TraceLogger and stores in on the context

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)

	// SetSensitiveAttributes applies attributes that contain SENSITIVE DATA. It is only enabled on debug builds of Porter with the traceSensitiveAttributes build tag set.
	SetSensitiveAttributes(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 logs a message at the error level and marks the current span as failed.
	Errorf(format string, arg ...interface{}) error

	// ShouldLog returns if the current log level includes the specified level.
	ShouldLog(level zapcore.Level) bool

	// IsTracingEnabled returns if the current logger is configed to send trace data.
	IsTracingEnabled() bool
}

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 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.

type Tracer

type Tracer struct {
	trace.Tracer

	// IsNoOp indicates that this tracer is a no-op, it doesn't do anything
	IsNoOp bool
	// contains filtered or unexported fields
}

Tracer wraps an open telemetry tracer connection in Porter so that its cleanup function can be moved around with it.

func NewTracer

func NewTracer(t trace.Tracer, cleanup TracerCleanup) Tracer

NewTracer wraps an open telemetry tracer and its cleanup function.

func (Tracer) Close

func (t Tracer) Close(ctx context.Context) error

Close the tracer, releasing resources and sending the data to the collector.

type TracerCleanup

type TracerCleanup func(ctx context.Context) error

Jump to

Keyboard shortcuts

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