package tracing
import "github.com/Azure/azure-sdk-for-go/sdk/azcore/tracing"
Package tracing contains the definitions needed to support distributed tracing.
Index ¶
- type Attribute
- type Provider
- func NewProvider(newTracerFn func(name, version string) Tracer, options *ProviderOptions) Provider
- func (p Provider) NewTracer(name, version string) (tracer Tracer)
- type ProviderOptions
- type Span
- func NewSpan(impl SpanImpl) Span
- func (s Span) AddEvent(name string, attrs ...Attribute)
- func (s Span) End(opts *SpanEndOptions)
- func (s Span) SetAttributes(attrs ...Attribute)
- func (s Span) SetStatus(code SpanStatus, desc string)
- type SpanEndOptions
- type SpanImpl
- type SpanKind
- type SpanOptions
- type SpanStatus
- type Tracer
- func NewTracer(newSpanFn func(ctx context.Context, spanName string, options *SpanOptions) (context.Context, Span), options *TracerOptions) Tracer
- func (t Tracer) Enabled() bool
- func (t *Tracer) SetAttributes(attrs ...Attribute)
- func (t Tracer) SpanFromContext(ctx context.Context) Span
- func (t Tracer) Start(ctx context.Context, spanName string, options *SpanOptions) (context.Context, Span)
- type TracerOptions
Types ¶
type Attribute ¶
type Attribute struct { // Key is the name of the attribute. Key string // Value is the attribute's value. // Types that are natively supported include int64, float64, int, bool, string. // Any other type will be formatted per rules of fmt.Sprintf("%v"). Value any }
Attribute is a key-value pair.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider is the factory that creates Tracer instances. It defaults to a no-op provider.
func NewProvider ¶
func NewProvider(newTracerFn func(name, version string) Tracer, options *ProviderOptions) Provider
NewProvider creates a new Provider with the specified values.
- newTracerFn is the underlying implementation for creating Tracer instances
- options contains optional values; pass nil to accept the default value
func (Provider) NewTracer ¶
NewTracer creates a new Tracer for the specified name and version.
- name - the name of the tracer object, typically the fully qualified name of the service client
- version - the version of the module in which the service client resides
type ProviderOptions ¶
type ProviderOptions struct { }
ProviderOptions contains the optional values when creating a Provider.
type Span ¶
type Span struct {
// contains filtered or unexported fields
}
Span is a single unit of a trace. A trace can contain multiple spans. A zero-value Span provides a no-op implementation.
func NewSpan ¶
NewSpan creates a Span with the specified implementation.
func (Span) AddEvent ¶
AddEvent adds a named event with an optional set of attributes to the span.
func (Span) End ¶
func (s Span) End(opts *SpanEndOptions)
End terminates the span and MUST be called before the span leaves scope. Any further updates to the span will be ignored after End is called.
func (Span) SetAttributes ¶
SetAttributes sets the specified attributes on the Span. Any existing attributes with the same keys will have their values overwritten.
func (Span) SetStatus ¶
func (s Span) SetStatus(code SpanStatus, desc string)
SetStatus sets the status on the span along with a description.
type SpanEndOptions ¶
type SpanEndOptions struct { }
SpanEndOptions contains the optional values for the Span.End() method.
type SpanImpl ¶
type SpanImpl struct { // End contains the implementation for the Span.End method. End func() // SetAttributes contains the implementation for the Span.SetAttributes method. SetAttributes func(...Attribute) // AddEvent contains the implementation for the Span.AddEvent method. AddEvent func(string, ...Attribute) // SetStatus contains the implementation for the Span.SetStatus method. SetStatus func(SpanStatus, string) }
SpanImpl abstracts the underlying implementation for Span, allowing it to work with various tracing implementations. Any zero-values will have their default, no-op behavior.
type SpanKind ¶
type SpanKind int
SpanKind represents the role of a Span inside a Trace. Often, this defines how a Span will be processed and visualized by various backends.
const ( // SpanKindInternal indicates the span represents an internal operation within an application. SpanKindInternal SpanKind = 1 // SpanKindServer indicates the span covers server-side handling of a request. SpanKindServer SpanKind = 2 // SpanKindClient indicates the span describes a request to a remote service. SpanKindClient SpanKind = 3 // SpanKindProducer indicates the span was created by a messaging producer. SpanKindProducer SpanKind = 4 // SpanKindConsumer indicates the span was created by a messaging consumer. SpanKindConsumer SpanKind = 5 )
type SpanOptions ¶
type SpanOptions struct { // Kind indicates the kind of Span. Kind SpanKind // Attributes contains key-value pairs of attributes for the span. Attributes []Attribute }
SpanOptions contains optional settings for creating a span.
type SpanStatus ¶
type SpanStatus int
SpanStatus represents the status of a span.
const ( // SpanStatusUnset is the default status code. SpanStatusUnset SpanStatus = 0 // SpanStatusError indicates the operation contains an error. SpanStatusError SpanStatus = 1 // SpanStatusOK indicates the operation completed successfully. SpanStatusOK SpanStatus = 2 )
type Tracer ¶
type Tracer struct {
// contains filtered or unexported fields
}
Tracer is the factory that creates Span instances.
func NewTracer ¶
func NewTracer(newSpanFn func(ctx context.Context, spanName string, options *SpanOptions) (context.Context, Span), options *TracerOptions) Tracer
NewTracer creates a Tracer with the specified values.
- newSpanFn is the underlying implementation for creating Span instances
- options contains optional values; pass nil to accept the default value
func (Tracer) Enabled ¶
Enabled returns true if this Tracer is capable of creating Spans.
func (*Tracer) SetAttributes ¶
SetAttributes sets attrs to be applied to each Span. If a key from attrs already exists for an attribute of the Span it will be overwritten with the value contained in attrs.
func (Tracer) SpanFromContext ¶
SpanFromContext returns the Span associated with the current context. If the provided context has no Span, false is returned.
func (Tracer) Start ¶
func (t Tracer) Start(ctx context.Context, spanName string, options *SpanOptions) (context.Context, Span)
Start creates a new span and a context.Context that contains it.
- ctx is the parent context for this span. If it contains a Span, the newly created span will be a child of that span, else it will be a root span
- spanName identifies the span within a trace, it's typically the fully qualified API name
- options contains optional values for the span, pass nil to accept any defaults
type TracerOptions ¶
type TracerOptions struct { // SpanFromContext contains the implementation for the Tracer.SpanFromContext method. SpanFromContext func(context.Context) Span }
TracerOptions contains the optional values when creating a Tracer.
Source Files ¶
- Version
- v1.7.0-beta.2
- Published
- Jun 6, 2023
- Platform
- windows/amd64
- Imports
- 1 packages
- Last checked
- 8 minutes ago –
Tools for package owners.