otil

package
v0.0.0-...-9febfc8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 22, 2025 License: BSD-3-Clause Imports: 12 Imported by: 0

README

Shared OpenTelemetry helpers

This package contains helpers to make using OpenTelemetry easier.

OTel + utils = otil

See the Go package documentation for more info.

Documentation

Overview

Package otil contains OpenTelemetry utilities.

These utilities are for convenience and do not have to be used. The OpenTelemetry API is canonical, and this package interoperates with it.

To add instrumentation to a function:

func MyFunc(ctx context.Context) (err error) {
	ctx, span := otil.FuncSpan(ctx)
	defer func() { otil.EndSpan(span, err) }()
	// rest of function
}

Index

Constants

This section is empty.

Variables

View Source
var ValuesKey = attribute.Key("org.chromium.code.values")

ValuesKey represents a slice of string values to attach to a span or event. This can be the arguments to a function or values relevant to an event.

Functions

func AddHTTP

func AddHTTP(c *http.Client)

AddHTTP adds tracing and context propagation integration to an HTTP client. The context provides the parent span for any child request spans.

func AddValues

func AddValues(span trace.Span, v ...interface{})

AddValues adds a "values" attribute to a span.

func EndSpan

func EndSpan(span trace.Span, err error)

EndSpan ends a span and provides some convenience for handling errors.

func FuncSpan

FuncSpan creates a span for the calling function. This function adds metadata (function name, filename, etc) to the span by inspecting the call stack.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL