v1.6.10 Latest Latest

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

Go to latest
Published: May 7, 2024 License: BSD-3-Clause Imports: 4 Imported by: 8




This section is empty.


This section is empty.


func AppendTracingContext

func AppendTracingContext(goCtx context.Context, tracingContext TracingContext) context.Context

func Enabled

func Enabled() bool

func RegisterTracer

func RegisterTracer(t Tracer) error

RegisterTracer registers the configured tracer


type CarrierFormat

type CarrierFormat byte

CarrierFormat defines the format of the propogation that needs to injected or extracted

const (
	// Binary represents trace context as opaque binary data.
	Binary CarrierFormat = iota
	// TextMap represents trace context as key:value string pairs.
	// Unlike HTTPHeaders, the TextMap format does not restrict the key or
	// value character sets in any way.
	// HTTPHeaders represents trace context as HTTP header string pairs.
	// Unlike TextMap, the HTTPHeaders format requires that the keys and values
	// be valid as HTTP headers as-is (i.e., character casing may be unstable
	// and special characters are disallowed in keys, values should be
	// URL-escaped, etc).
	// Lambda represents trace context as a special header which can be only used
	// with flogo xray tracing

type Config

type Config struct {
	Operation string
	Tags      map[string]interface{}
	Logger    log.Logger

type Tracer

type Tracer interface {
	// Implement Start() and Stop() methods to manage tracer lifecycle. These methods will be called during engine startup and engine shutdown.

	// Name() returns the name of the registered tracer
	Name() string

	// Extract() returns a TracingContext given `format` and `carrier`.
	// FlogoTracer defines a common set of `format` values, and each has an expected `carrier` type.
	// After extracting the trace context from the incoming request, the trace context must be appended
	// to the go context to propogate it to the action handler.
	// See trace.AppendTracingContext() and trace.ExtractTracingContext().
	// Example usage:
	//	tr := trace.GetTracer()
	//	tctx, err := tr.Extract(trace.HTTPHeaders, httpReq)
	//	if err != nil {
	//		log.Errorf("failed to extract tracing context due to error: %s", err.Error())
	//	}
	//	ctx := trace.AppendTracingContext(context.Background(), tctx)
	//	..
	//	results, err := handler.Handle(ctx, outputData)
	Extract(format CarrierFormat, carrier interface{}) (TracingContext, error)

	// Inject() takes the tracing context `tctx` and injects the current trace context for
	// propagation within `carrier`. The actual type of `carrier` depends on the value of `format`.
	// trace.Tracer defines a common set of `format` values, and each has an expected `carrier` type.
	// Example usage:
	// tracer := trace.GetTracer()
	// err = tracer.Inject(ctx.TracingContext(), trace.HTTPHeaders, req)
	Inject(tCtx TracingContext, format CarrierFormat, carrier interface{}) error

	// StartTrace() returns a wrapped implementation specific trace created by the underlying tracing implementation.
	// Non nil parent can be used to establish parent-child relationship between trace object.
	StartTrace(config Config, parent TracingContext) (TracingContext, error)

	// FinishTrace() finishes a wrapped implementation specific trace
	// Non nil error indicates failure
	FinishTrace(tContext TracingContext, err error) error

Tracer interface to configure individual tracers

func GetTracer

func GetTracer() Tracer

GetTracer returns the instance of the registered tracer. If no tracer is registered, a noop tracer is returned

type TracingContext

type TracingContext interface {
	// TraceObject() returns underlying tracing implementation
	TraceObject() interface{}
	// SetTags() allows you to set one or more tags to tracing object
	SetTags(tags map[string]interface{}) bool
	// SetTags() allows you to add tag to tracing object
	SetTag(tagKey string, tagValue interface{}) bool
	// LogKV() allows you to log additional details about the entity being traced
	LogKV(kvs map[string]interface{}) bool
	// TraceID() returns trace ID
	TraceID() string
	// SpanID() returns span ID
	SpanID() string

func ExtractTracingContext

func ExtractTracingContext(goCtx context.Context) TracingContext

Jump to

Keyboard shortcuts

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