Documentation ¶
Overview ¶
Package traces provides a wrapper around OpenTelemetry to add standard fields to the span.
Index ¶
- func End(span trace.Span, status otelCodes.Code, err error)
- func EndError(span trace.Span, err error)deprecated
- func EndOK(span trace.Span)deprecated
- func GinTracingMiddleware() gin.HandlerFunc
- func Initialize(exporter sdktrace.SpanExporter, ...) (shutdown func(context.Context) error, err error)
- func NewHTTPExporter(ctx context.Context, url string, opts ...otlptracehttp.Option) (exporter sdktrace.SpanExporter, err error)
- func NewNoopExporter() sdktrace.SpanExporter
- func NewSpan(traceCtx context.Context, spanName string, kind trace.SpanKind, ...) (spanCtx context.Context, span trace.Span, err error)deprecated
- func Start(ctx context.Context, spanName string, kind trace.SpanKind, ...) (spanCtx context.Context, span trace.Span, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func End ¶ added in v1.1.0
End ends the span with the supplied status and error. This is merely a convenience function that wraps the the trace.Span SetStatus and End functions of the span. in: span: The span. in: status: The status code. 0 is "unset", 1 is "error", and 2 is "ok". in: err: The error. Can be nil. If the status is "error", the error the error is used as the description for the status.
func GinTracingMiddleware ¶
func GinTracingMiddleware() gin.HandlerFunc
func Initialize ¶
func Initialize(exporter sdktrace.SpanExporter, ver, apiName, buildDate, commitHash, env string) (shutdown func(context.Context) error, err error)
Initialize initializes the tracing system.
func NewHTTPExporter ¶
func NewHTTPExporter(ctx context.Context, url string, opts ...otlptracehttp.Option) (exporter sdktrace.SpanExporter, err error)
NewHTTPExporter creates a new HTTP exporter.
func NewNoopExporter ¶
func NewNoopExporter() sdktrace.SpanExporter
func NewSpan
deprecated
func NewSpan(traceCtx context.Context, spanName string, kind trace.SpanKind, attributes ...attribute.KeyValue) (spanCtx context.Context, span trace.Span, err error)
NewSpan starts a new span that is a child of the existing span within the supplied context. in: ctx: The context. If nil, an error is returned. in: spanName: The name of the span. in: kind: The arg kind is used to set the span kind. The constant trace.SpanKind is defined here: https://pkg.go.dev/go.opentelemetry.io/otel/trace@v1.15. in: attributes: The attributes to add to the span. out: ctx: The context with the span added. out: span: The span. out: err: The error if the context is nil.
Deprecated: Use traces.Start(context.Context, string, trace.SpanKind, ...attribute.KeyValue) instead. This function will be removed in v2.0.0.
func Start ¶ added in v1.1.0
func Start(ctx context.Context, spanName string, kind trace.SpanKind, attributes ...attribute.KeyValue) (spanCtx context.Context, span trace.Span, err error)
Start starts a new span that has no parent. This is merely a convenience function that wraps the Start function of the tracer. in: ctx: The context. If nil, an error is returned. in: spanName: The name of the span. in: kind: The arg kind is used to set the span kind. The constant trace.SpanKind is defined here: https://pkg.go.dev/go.opentelemetry.io/otel/trace@v1.15. in: attributes: The attributes to add to the span. out: ctx: The context with the span added. out: span: The span. out: err: The error if the context is nil.
Types ¶
This section is empty.