Documentation ¶
Overview ¶
Package xtrace provides xtrace-based runtime components to be used by blueprint application workflows and blueprint generated code. The package provides the following runtime components: (i) XTracerImpl: a client-wrapper implementation of the XTracer interface to a xtrace server. Used by the xtrace plugin for providing context propagation between multiple processes. (ii) XTraceLogger: an xtrace-based logger implementation of the [Logger] interface. Once initialized, the logger sets itself as the default logger for logging across blueprint applications.
Index ¶
- type XTraceLogger
- func (l *XTraceLogger) Debug(ctx context.Context, format string, args ...any) (context.Context, error)
- func (l *XTraceLogger) Error(ctx context.Context, format string, args ...any) (context.Context, error)
- func (l *XTraceLogger) Info(ctx context.Context, format string, args ...any) (context.Context, error)
- func (l *XTraceLogger) Logf(ctx context.Context, opts backend.LogOptions, format string, args ...any) (context.Context, error)
- func (l *XTraceLogger) Warn(ctx context.Context, format string, args ...any) (context.Context, error)
- type XTracer
- type XTracerImpl
- func (xt *XTracerImpl) Get(ctx context.Context) (tracingplane.BaggageContext, error)
- func (xt *XTracerImpl) IsTracing(ctx context.Context) (bool, error)
- func (xt *XTracerImpl) Log(ctx context.Context, msg string) (context.Context, error)
- func (xt *XTracerImpl) LogWithTags(ctx context.Context, msg string, tags ...string) (context.Context, error)
- func (xt *XTracerImpl) Merge(ctx context.Context, other tracingplane.BaggageContext) (context.Context, error)
- func (xt *XTracerImpl) Set(ctx context.Context, baggage tracingplane.BaggageContext) (context.Context, error)
- func (xt *XTracerImpl) StartTask(ctx context.Context, tags ...string) (context.Context, error)
- func (xt *XTracerImpl) StopTask(ctx context.Context) (context.Context, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type XTraceLogger ¶
Implementation of the backend.Logger interface Note: This logger should only be used in conjunction with the XTracerImpl tracer. Using this logger without using the XTracerImpl tracer would result in no-op logging behavior.
func NewXTraceLogger ¶
func NewXTraceLogger(ctx context.Context, addr string) (*XTraceLogger, error)
Returns a new instance of XTracerImpl that connects to a xtrace server running at `addr`. REQUIRED: An xtrace server must be running at `addr`
func (*XTraceLogger) Debug ¶
func (l *XTraceLogger) Debug(ctx context.Context, format string, args ...any) (context.Context, error)
Implements backend.Logger
func (*XTraceLogger) Error ¶
func (l *XTraceLogger) Error(ctx context.Context, format string, args ...any) (context.Context, error)
Implements backend.Logger
func (*XTraceLogger) Info ¶
func (l *XTraceLogger) Info(ctx context.Context, format string, args ...any) (context.Context, error)
Implements backend.Logger
type XTracer ¶
type XTracer interface { // Creates an event in the current trace with `msg` as content. Log(ctx context.Context, msg string) (context.Context, error) // Creates an event in the current trace with `msg` as content along with `tags` as the keywords for the text. LogWithTags(ctx context.Context, msg string, tags ...string) (context.Context, error) // Starts a new trace with given `tags` StartTask(ctx context.Context, tags ...string) (context.Context, error) // Stops the current running trace. StopTask(ctx context.Context) (context.Context, error) // Merges the incoming `other` baggage into the current trace's existing baggage. Merge(ctx context.Context, other tracingplane.BaggageContext) (context.Context, error) // Sets the current trace's `baggage` to the one provided. Set(ctx context.Context, baggage tracingplane.BaggageContext) (context.Context, error) // Returns the current trace's baggage. Get(ctx context.Context) (tracingplane.BaggageContext, error) // Returns true if there is an ongoing trace. IsTracing(ctx context.Context) (bool, error) }
Represents the XTrace tracer interface exposed to applications and used by the xtrace plugin.
type XTracerImpl ¶
type XTracerImpl struct {
XTracer
}
Implementation of the XTracer interface
func NewXTracerImpl ¶
func NewXTracerImpl(ctx context.Context, addr string) (*XTracerImpl, error)
Returns a new instance of XTracerImpl that connects to a xtrace server running at `addr`. REQUIRED: An xtrace server must be running at `addr`
func (*XTracerImpl) Get ¶
func (xt *XTracerImpl) Get(ctx context.Context) (tracingplane.BaggageContext, error)
Implements the XTracer interface
func (*XTracerImpl) IsTracing ¶
func (xt *XTracerImpl) IsTracing(ctx context.Context) (bool, error)
Implements the XTracer interface
func (*XTracerImpl) LogWithTags ¶
func (xt *XTracerImpl) LogWithTags(ctx context.Context, msg string, tags ...string) (context.Context, error)
Implements the XTracer interface
func (*XTracerImpl) Merge ¶
func (xt *XTracerImpl) Merge(ctx context.Context, other tracingplane.BaggageContext) (context.Context, error)
Implements the XTracer interface
func (*XTracerImpl) Set ¶
func (xt *XTracerImpl) Set(ctx context.Context, baggage tracingplane.BaggageContext) (context.Context, error)
Implements the XTracer interface