tracing API

tracing

package

API reference for the tracing package.

Imports

(1)
I
interface

Span

Span represents a tracing span that can be ended and annotated.

pkg/tracing/tracer.go:8-12
type Span interface

Methods

End
Method
func End(...)
SetAttributes
Method

Parameters

kv ...Attribute
func SetAttributes(...)
RecordError
Method

Parameters

err error
func RecordError(...)
S
struct

Attribute

Attribute is a key-value pair for span metadata.

pkg/tracing/tracer.go:15-18
type Attribute struct

Fields

Name Type Description
Key string
Value any
I
interface

Tracer

Tracer creates new spans.

pkg/tracing/tracer.go:21-23
type Tracer interface

Methods

StartSpan
Method

Parameters

name string
func StartSpan(...)
S
struct
Implements: Span

noopSpan

pkg/tracing/tracer.go:25-25
type noopSpan struct

Methods

End
Method
func (noopSpan) End()
{}
SetAttributes
Method

Parameters

kv ...Attribute
func (noopSpan) SetAttributes(kv ...Attribute)
{}
RecordError
Method

Parameters

err error
func (noopSpan) RecordError(err error)
{}
S
struct
Implements: Tracer

noopTracer

pkg/tracing/tracer.go:31-31
type noopTracer struct

Methods

StartSpan
Method

Parameters

name string
func (noopTracer) StartSpan(ctx context.Context, name string) (context.Context, Span)
{
	return ctx, noopSpan{}
}
F
function

StartSpan

StartSpan starts a span from the given tracer, falling back to Noop.

Parameters

tracer
name
string
pkg/tracing/tracer.go:41-46
func StartSpan(ctx context.Context, tracer Tracer, name string) (context.Context, Span)

{
	if tracer == nil {
		tracer = Noop
	}
	return tracer.StartSpan(ctx, name)
}