uctrace

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeHTTPClient

func MakeHTTPClient() *http.Client

MakeHTTPClient creates an HTTP client that will record spans for outgoing HTTP requests.

func Wrap0

func Wrap0(ctx context.Context, t Tracer, spanName string, requireParentSpan bool, f func(context.Context) error) error

Wrap0 takes a function that returns 0 values + potentially an error, and wraps its execution in a span. This is useful for capturing any returned errors and recording them in the span, since you'd otherwise need to find all the potential error return paths in your function and ensure you're recording those. (If you want to trace a function that doesn't return an error, just call tracer.Start() directly.)

func Wrap1

func Wrap1[T1 any](ctx context.Context, t Tracer, spanName string, requireParentSpan bool, f func(context.Context) (T1, error)) (T1, error)

Wrap1 wraps a function execution in a span. See comments above.

func Wrap2

func Wrap2[T1 any, T2 any](ctx context.Context, t Tracer, spanName string, requireParentSpan bool, f func(context.Context) (T1, T2, error)) (T1, T2, error)

Wrap2 wraps a function execution in a span. See comments above.

func Wrap3

func Wrap3[T1 any, T2 any, T3 any](ctx context.Context, t Tracer, spanName string, requireParentSpan bool, f func(context.Context) (T1, T2, T3, error)) (T1, T2, T3, error)

Wrap3 wraps a function execution in a span. See comments above.

Types

type Attribute

type Attribute string

Attribute is an enum of UserClouds-specific properties that we want to attach to traces.

const (
	// AttributeCompanyID captures the UUID of the company owning a tenant
	AttributeCompanyID Attribute = "uc.company_id"
	// AttributeCompanyName captures the name of the company owning a tenant
	AttributeCompanyName Attribute = "uc.company_name"
	// AttributeTenantID captures the UUID of the tenant
	AttributeTenantID Attribute = "uc.tenant_id"
	// AttributeTenantName captures the name of the tenant
	AttributeTenantName Attribute = "uc.tenant_name"
	// AttributeTenantURL captures the URL of the tenant
	AttributeTenantURL Attribute = "uc.tenant_url"
	// AttributeHandlerName captures the name of the handler that is processing
	// the request
	AttributeHandlerName Attribute = "uc.handler_name"
	// AttributeSdkVersion captures the version of the UC SDK that sent the request
	AttributeSdkVersion Attribute = "uc.sdk_version"
	// AttributeUserFriendlyError captures the user-friendly error message in the event of a Friendlyf error
	AttributeUserFriendlyError Attribute = "uc.user_friendly_error"
)

type Span

type Span struct {
}

Span is the individual component of a trace.

func GetCurrentSpan

func GetCurrentSpan(ctx context.Context) Span

GetCurrentSpan returns the current Span from the given context.

func (Span) End

func (s Span) End()

End completes the Span.

func (Span) IsRecording

func (s Span) IsRecording() bool

IsRecording returns the recording state of the Span. It will return true if the Span is active and events can be recorded.

func (Span) RecordError

func (s Span) RecordError(err error)

RecordError sets the span status to "error" and records an error event capturing the error message.

func (Span) SetBoolAttribute

func (s Span) SetBoolAttribute(key Attribute, value bool)

SetBoolAttribute sets the given bool attribute on the span.

func (Span) SetBoolSliceAttribute

func (s Span) SetBoolSliceAttribute(key Attribute, value []bool)

SetBoolSliceAttribute sets the given bool slice attribute on the span.

func (Span) SetFloat64Attribute

func (s Span) SetFloat64Attribute(key Attribute, value float64)

SetFloat64Attribute sets the given float64 attribute on the span.

func (Span) SetFloat64SliceAttribute

func (s Span) SetFloat64SliceAttribute(key Attribute, value []float64)

SetFloat64SliceAttribute sets the given float64 slice attribute on the span.

func (Span) SetInt64Attribute

func (s Span) SetInt64Attribute(key Attribute, value int64)

SetInt64Attribute sets the given int64 attribute on the span.

func (Span) SetInt64SliceAttribute

func (s Span) SetInt64SliceAttribute(key Attribute, value []int64)

SetInt64SliceAttribute sets the given int64 slice attribute on the span.

func (Span) SetIntAttribute

func (s Span) SetIntAttribute(key Attribute, value int)

SetIntAttribute sets the given int attribute on the span.

func (Span) SetIntSliceAttribute

func (s Span) SetIntSliceAttribute(key Attribute, value []int)

SetIntSliceAttribute sets the given int slice attribute on the span.

func (Span) SetStringAttribute

func (s Span) SetStringAttribute(key Attribute, value string)

SetStringAttribute sets the given string attribute on the span.

func (Span) SetStringSliceAttribute

func (s Span) SetStringSliceAttribute(key Attribute, value []string)

SetStringSliceAttribute sets the given string slice attribute on the span.

type Tracer

type Tracer struct {
}

Tracer manages the creation of spans.

func NewTracer

func NewTracer(name string) Tracer

NewTracer creates a new Tracer with the given name.

func (Tracer) StartSpan

func (t Tracer) StartSpan(ctx context.Context, name string, requireParentSpan bool) (context.Context, Span)

StartSpan creates a new span with the given name. If requireParentSpan is true, it creates a no-op (non-recording) span if we are not already tracing.

Jump to

Keyboard shortcuts

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