Documentation ¶
Index ¶
- Constants
- Variables
- func AddImpact(ctx context.Context, level string, module string)
- func ContextWithSpan(ctx context.Context, span SpanEx) context.Context
- func Debug(ctx context.Context, a ...interface{})
- func Error(ctx context.Context, a ...interface{}) error
- func Fatal(ctx context.Context, a ...interface{})
- func Info(ctx context.Context, a ...interface{})
- func InitializeFilters(showInternal bool)
- func InternalData(a ...interface{}) string
- func MethodName(skip int) string
- func SetGlobalTracer(t *Tracer)
- func StackTrace(skip int) string
- func UpdateSpanName(ctx context.Context, a ...interface{})
- func UpdateSpanReason(ctx context.Context, a ...interface{})
- func Warn(ctx context.Context, a ...interface{})
- type Detail
- type EndOption
- type Forwarder
- type Forwarders
- type NoopSpan
- func (*NoopSpan) AddDetail(_ *Detail)
- func (*NoopSpan) AddImpact(_ string, _ string)
- func (*NoopSpan) Closed() bool
- func (*NoopSpan) End(_ ...EndOption)
- func (*NoopSpan) Modify(ctx context.Context, _ ...StartSpanOption) context.Context
- func (*NoopSpan) SetName(_ ...interface{})
- func (*NoopSpan) SetReason(_ ...interface{})
- func (*NoopSpan) SetSimEvent(_ SimEvent)
- func (*NoopSpan) SetStatus(_ log.Severity, _ string)
- func (*NoopSpan) SimEvent() SimEvent
- func (*NoopSpan) SpanContext() SpanContext
- type ReplacementRule
- type Replacements
- type SimEvent
- type SpanContext
- type SpanData
- type SpanEx
- type SpanImpl
- func (s *SpanImpl) AddDetail(detail *Detail)
- func (s *SpanImpl) AddImpact(level string, module string)
- func (s *SpanImpl) Closed() bool
- func (s *SpanImpl) End(opts ...EndOption)
- func (s *SpanImpl) Modify(ctx context.Context, options ...StartSpanOption) context.Context
- func (s *SpanImpl) SetName(a ...interface{})
- func (s *SpanImpl) SetReason(a ...interface{})
- func (s *SpanImpl) SetSimEvent(event SimEvent)
- func (s *SpanImpl) SetStatus(_ log.Severity, _ string)
- func (s *SpanImpl) SimEvent() SimEvent
- func (s *SpanImpl) SpanContext() SpanContext
- type StartSpanOption
- func WithContextValue(action decorator) StartSpanOption
- func WithForcedId(spanId uuid.UUID) StartSpanOption
- func WithImpact(impact string, element string) StartSpanOption
- func WithName(a ...interface{}) StartSpanOption
- func WithReason(reason string) StartSpanOption
- func WithSimulation(flag SimEvent) StartSpanOption
- func WithSpanContext(ctx SpanContext) StartSpanOption
- type TraceAnnotation
- type TraceDetail
- type Tracer
Constants ¶
const ( // rpc injection keys SimEventKey = "cc-simEvent" SpanIds = "cc-spanIds" ChildId = "cc-childId" // rpc infra source key values SourceIn = "in" SourceOut = "out" SourceAssumedIn = "assumedIn" )
const ( ImpactCreate = "C" ImpactRead = "R" ImpactModify = "W" ImpactDelete = "D" ImpactUse = "E" )
impact data is stored in a KeyValue pair under the ImpactKey. KV pairs have limited types that they support, so the impact targets are prefixed with the type of impact. This leaves the value as a string that can be decoded later in order to properly display the impact.
Variables ¶
var NullParentId = uuid.Nil.String()
NullParentId represents a non-existent parent ID, and hence marks a span with that ID as a root span.
var NullSpanContext = SpanContext{ TraceId: uuid.Nil, Id: uuid.Nil, }
NullSpanContext is the value used whenever a SpanContext is requested for a closed or non-existent SpanContext.
Functions ¶
func AddImpact ¶
AddImpact adds an impact claim to the current span. It does not optimize out any duplicates -- all of those are retained.
func ContextWithSpan ¶
ContextWithSpan creates a new context with a current span set to the passed span.
func InitializeFilters ¶
func InitializeFilters(showInternal bool)
func InternalData ¶
func InternalData(a ...interface{}) string
InternalData returns either the formatted string, if internal data is to be shown in the traces, or the empty string, if not.
func MethodName ¶
MethodName returns the caller's method name, without the leading directory paths.
func SetGlobalTracer ¶
func SetGlobalTracer(t *Tracer)
SetGlobalTracer is a function that replaces the global trace provider instance. It requires that the caller ensure proper synchronization.
func StackTrace ¶
StackTrace produces a formatted call stack, in the form of filename and line number. A newline splits each entry.
func UpdateSpanName ¶
UpdateSpanName replaces the current span name string with the formatted string provided. The span will end up with the last name provided.
func UpdateSpanReason ¶
UpdateSpanReason replaces the current span reason with the formatted string provided. The span will end up with the last reason provided.
Types ¶
type Detail ¶
type Detail struct { // At is the real world time when the event is recorded. At time.Time // SimAt is the simulated time tick when the event is recorded. SimAt int64 // CallersName is the short name of the function that triggered the creation // of this Detail instance. CallersName string // StackTrace contains the formatted stack trace at the time this Detail // is created. StackTrace string // Severity is the type of detail created: e.g. informational, warning, or // error. Severity pbl.Severity // Text is the description of the detail event. Text string // Action is type of detail that is being recorded: a trace event, or the // marking of a child trace span creation. Action pbl.Action // ChildId holds the trace span ID of the child trace span. It is ignored // unless the Action is for a trace span creation. ChildId uuid.UUID SimEvent SimEvent }
Detail is a structure that holds the fields that define a trace detail event.
type EndOption ¶
type EndOption func(*SpanData)
EndOption sets options and attributes when the span is ended.
func WithEndTime ¶
WithEndTime sets the end time of the span to provided time t, when it is ended.
func WithSimEndTime ¶
WithSimEndTime sets the simulated time that the span completed to the provided tick.
type Forwarder ¶
type Forwarder interface { // Close the forwarder. This flushes any in-flight export operations, and // terminates the communications with the target trace export instance. Close() // Export is a function that forwards a trace span's data fields to the // trace span exporter. Processing may be deferred until the exporter is // formally opened. Export(data *SpanData) }
Forwarder is the interface that a trace sink forwarder must implement. It handles the common lifecycle operations.
type Forwarders ¶
type Forwarders []Forwarder
Forwarders defines the type that represents a set of trace forwarder instances.
type NoopSpan ¶
type NoopSpan struct{}
NoopSpan is an empty span that is purposefully incapable of any changes. It is used as a placeholder when there is no active span.
func (*NoopSpan) SetSimEvent ¶
func (*NoopSpan) SpanContext ¶
func (*NoopSpan) SpanContext() SpanContext
type ReplacementRule ¶
type ReplacementRule struct {
// contains filtered or unexported fields
}
type Replacements ¶
type Replacements interface { Add(rule *ReplacementRule) Remove(rule *ReplacementRule) Process(text string) string }
type SimEvent ¶
type SimEvent int
func ParseSimEvent ¶
ParseSimEvent attempts to convert the supplied string to its equivalent SimEvent value. Any error results in returning an assumed in simulation state.
type SpanContext ¶
SpanContext is a structure that holds the span and trace IDs for a given span. This can be used to identify the parent span to use with a new (remote) child span.
func NewSpanContext ¶
func NewSpanContext(s string) SpanContext
NewSpanContext returns a new SpanContext instance based on the value in the supplied string. That value is expected to match the format from a SpanContext String() function. If the value cannot be parsed, the NullSpanContext is returned.
func (SpanContext) String ¶
func (s SpanContext) String() string
String is a function that returns a formatted string representing the value of the SpanContext instance.
type SpanData ¶
type SpanData struct { // ParentId, Id, and TraceId define the unique position of this trace span // in a tree of related events. ParentId uuid.UUID Id uuid.UUID TraceId uuid.UUID // Remote is a flag that is true if the initiator of this trace span did so // via some form of remote or asynchronous call. Remote bool // Name defines a summary string for this instance. Name string // Reason expands on the summary by supplying user-friendly explanatory text // for why the trace span actions happen. Reason string // StackTrace contains the formatted stack trace at the time the trace span // is created. StackTrace string // SimEvent signals whether this trace span is part of the simulation, or // part of the simulator machinery, or indeterminate. The Infrastructure // flag is an about to be obsoleted earlier form of this. SimEvent SimEvent // impact statement Impacts []string // Details [set of events] Details []*Detail // simulated start and end times SimStart int64 SimEnd int64 // real world start and end times WallStart time.Time WallEnd time.Time // contains filtered or unexported fields }
SpanData is a structure that contains the data associated with a trace span.
type SpanEx ¶
type SpanEx interface { // Modify updates the span data using the same WithXxx functions that are // used for starting a span. Modify(ctx context.Context, options ...StartSpanOption) context.Context // End terminates an open span, with the option for setting final attributes. End(opts ...EndOption) // SetReason sets the friendly description string on this span to a // formatted string using the supplied arguments. SetReason(a ...interface{}) // SetName replaces the current span name string with the formatted string // provided. SetName(a ...interface{}) // AddDetail adds the new event detail to this span AddDetail(detail *Detail) // AddImpact adds an impact claim to this span. AddImpact(level string, module string) // SetStatus sets a completion status attribute for this span. SetStatus(sev pbl.Severity, message string) // Closed returns true if this span has already ended; false, otherwise. Closed() bool // SimEvent returns the in/out/maybe simulation designator for the span. SimEvent() SimEvent // SetSimEvent updates the in/out/maybe simulation designator for the span. SetSimEvent(event SimEvent) // SpanContext returns the current trace and span UUIDs, or the empty UUID // for the values, if no span is currently active. SpanContext() SpanContext }
SpanEx is the interface for starting, modifying, or ending a tracing span. The span is a collection of related event details, including a subtree of related (child) spans.
func SpanFromContext ¶
SpanFromContext returns the current span stored in the context. Since that span may be stale, it is ignored if it is closed and the no-op span returned instead.
type SpanImpl ¶
type SpanImpl struct {
// contains filtered or unexported fields
}
SpanImpl defines the data associated with an active span. The core field in it is the span, which contains the data that is passed along to the tracer's forwarder processes.
func (*SpanImpl) SetSimEvent ¶
func (*SpanImpl) SpanContext ¶
func (s *SpanImpl) SpanContext() SpanContext
type StartSpanOption ¶
type StartSpanOption func(*SpanData)
StartSpanOption sets options and attributes when the span is started.
func WithContextValue ¶
func WithContextValue(action decorator) StartSpanOption
WithContextValue decorates the resulting context using the supplied function
func WithForcedId ¶
func WithForcedId(spanId uuid.UUID) StartSpanOption
WithForcedId forcibly sets the span ID for the new instance. This is used when the parent is asynchronously (i.e. remotely) starting a child, and therefore needs to know the span ID prior to the span's creation.
func WithImpact ¶
func WithImpact(impact string, element string) StartSpanOption
WithImpact states that the activity covered in the calling trace event had the specified impact on the specified element.
func WithName ¶
func WithName(a ...interface{}) StartSpanOption
WithName adds the supplied value as the name of the span under creation
func WithReason ¶
func WithReason(reason string) StartSpanOption
WithReason adds a friendly description for the reason behind the logic in the span.
func WithSimulation ¶
func WithSimulation(flag SimEvent) StartSpanOption
WithSimulation sets the in/out/maybe simulation state for the span under creation.
func WithSpanContext ¶
func WithSpanContext(ctx SpanContext) StartSpanOption
WithSpanContext specifies that the span is to start with the supplied parent and trace IDs, but as a remote child.
type TraceAnnotation ¶
type TraceAnnotation func(cfg *TraceDetail)
TraceAnnotation defines the type signature for an annotation function that decorates a log trace event.
func WithReplacement ¶
func WithReplacement(match *regexp.Regexp, repl string) TraceAnnotation
WithReplacement states that the event text is to be searched using the match regex, and for every occurrence that is found, it is to be replaced by the value of the repl parameter.
type TraceDetail ¶
type TraceDetail struct {
// contains filtered or unexported fields
}
TraceDetail holds attributes and processing data that is used as part of the underlying AddTrace call.
type Tracer ¶
type Tracer struct {
// contains filtered or unexported fields
}
Tracer defines the data fields for a trace provider instance. Currently, this is the set of trace sink forwarders, and the common event text filter rules. The latter is currently latent.
func Current ¶
func Current() *Tracer
Current is a function that returns the global trace provider instance. It requires that the caller ensure proper synchronization relative to replacement with a new global tracer instance.
func NewTracer ¶
func NewTracer(forwarders Forwarders, replacements Replacements) *Tracer
NewTracer constructs a new trace provider instance.
func (*Tracer) NewSpan ¶
NewSpan is the function on a trace provider instance that begins a new trace space.