Documentation
¶
Overview ¶
Package tracing integrates observability back-ends with the Fluxor engine to provide distributed tracing information. All instrumentation is kept in a separate package so that applications which do not require tracing can exclude it from their build.
Index ¶
- func EndSpan(sp *Span, err error)
- func Init(serviceName, serviceVersion, outputFile string) error
- func InitWithExporter(serviceName, serviceVersion string, exporter sdktrace.SpanExporter) error
- func WithSpan(ctx context.Context, sp *Span) context.Context
- func WithTrace(ctx context.Context, _ *Trace) context.Context
- type Span
- type Trace
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Init ¶
Init configures OpenTelemetry with the stdout exporter. If outputFile is an empty string the exporter uses os.Stdout; otherwise the traces are written to the specified file. The function is safe to call multiple times – the first successful initialisation wins. Init configures OpenTelemetry with the stdout exporter backed by either os.Stdout or the specified file. If outputFile is an empty string traces are written to os.Stdout. The function is safe to call multiple times – the first successful initialisation wins.
func InitWithExporter ¶
func InitWithExporter(serviceName, serviceVersion string, exporter sdktrace.SpanExporter) error
InitWithExporter configures OpenTelemetry using the supplied SpanExporter. This allows callers to integrate with any exporter supported by the OpenTelemetry SDK (e.g. OTLP, Jaeger, Zipkin). The function is safe to call multiple times – the first successful initialisation wins.
Types ¶
type Span ¶
type Span struct {
// contains filtered or unexported fields
}
Span wraps go.opentelemetry.io/otel/trace.Span so that the callers do not need to import the upstream package directly.
func SpanFromContext ¶
SpanFromContext retrieves the *Span wrapper from the supplied context when present.
func StartSpan ¶
StartSpan starts a new child span using OpenTelemetry. The string "kind" is mapped onto the appropriate trace.SpanKind value; when the mapping cannot be determined SpanKindInternal is used as a sensible default.
func (*Span) OnDone ¶
func (s *Span) OnDone()
OnDone is kept for backward compatibility; in the OpenTelemetry world span.End() is used instead so this function simply calls End.
func (*Span) SetStatus ¶
SetStatus records an error status on the span. If err is nil an OK status is recorded instead.
func (*Span) SetStatusFromHTTPCode ¶
SetStatusFromHTTPCode sets the span’s status based on an HTTP response code.
type Trace ¶
type Trace struct{}
Trace is kept only so that the public API of the package remains the same. It no longer contains any fields because OpenTelemetry manages traces internally. The value can be used as a marker by callers that still expect it.