Documentation
¶
Index ¶
- Constants
- Variables
- func SetSpanStatus(span trace.Span, err error)
- func StartSpan(ctx context.Context, name string, o ...trace.SpanStartOption) (context.Context, trace.Span)
- func StartSpanWithRemoteParent(ctx context.Context, name string, parent trace.SpanContext, ...) (context.Context, trace.Span)
- type LogrusExporter
Constants ¶
const (
TracerName = "containerd-shim-runhcs-v1"
)
Variables ¶
var DefaultSampler = sdktrace.AlwaysSample()
var WithClientSpanKind = trace.WithSpanKind(trace.SpanKindClient)
var WithServerSpanKind = trace.WithSpanKind(trace.SpanKindServer)
Functions ¶
func SetSpanStatus ¶
SetSpanStatus sets the span's OpenTelemetry status based on `err`.
If `err` is non-nil the error is recorded on the span and the status is set to `codes.Error`.
If `err` is nil the span is left in its default (Unset) status. The exporter treats Unset the same as Ok for level selection (Info), so downstream log level does not change. Leaving the status Unset instead of calling SetStatus(Ok, "") avoids the OpenTelemetry spec's "Ok is terminal" rule, under which a subsequent SetStatus(Error, ...) would be silently dropped.
func StartSpan ¶
func StartSpan(ctx context.Context, name string, o ...trace.SpanStartOption) (context.Context, trace.Span)
StartSpan wraps otel.Start(), but, if the span is sampling, adds a log entry to the context that points to the newly created span.
func StartSpanWithRemoteParent ¶
func StartSpanWithRemoteParent(ctx context.Context, name string, parent trace.SpanContext, o ...trace.SpanStartOption) (context.Context, trace.Span)
StartSpanWithRemoteParent wraps "go.opentelemetry.io/otel/trace".ContextWithRemoteSpanContext
See StartSpan for more information.
Types ¶
type LogrusExporter ¶
type LogrusExporter struct{}
LogrusExporter is an OpenTelemetry `sdktrace.SpanExporter` that exports `trace.ReadOnlySpan` to logrus output.
func (*LogrusExporter) ExportSpans ¶
func (le *LogrusExporter) ExportSpans(ctx context.Context, spans []sdktrace.ReadOnlySpan) error
ExportSpans exports each `spans` based on the following rules:
1. All output will contain `s.Attributes`, `s.SpanKind`, `s.TraceID`, `s.SpanID`, and `s.ParentSpanID` for correlation
2. Any calls to .Annotate will not be supported.
3. The span itself will be written at `logrus.InfoLevel` unless `s.Status.Code != 0` in which case it will be written at `logrus.ErrorLevel` providing `s.Status.Message` as the error value.