swo

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 21 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// MaxTagsCount is the maximum number of tags allowed.
	MaxTagsCount = metrics.MaxTagsCount
)

Variables

View Source
var (
	// ErrExceedsTagsCountLimit indicates the count of tags exceeds the limit
	ErrExceedsTagsCountLimit = metrics.ErrExceedsTagsCountLimit
	// ErrExceedsMetricsCountLimit indicates there are too many distinct measurements in a flush cycle.
	ErrExceedsMetricsCountLimit = metrics.ErrExceedsMetricsCountLimit
	// ErrMetricsWithNonPositiveCount indicates the count is negative or zero
	ErrMetricsWithNonPositiveCount = metrics.ErrMetricsWithNonPositiveCount
)

The measurements submission errors

Functions

func Closed

func Closed() bool

Closed denotes if the agent is closed (by either calling Shutdown explicitly or being triggered from some internal error).

func GetLogLevel

func GetLogLevel() string

GetLogLevel returns the current logging level of the library

func IncrementMetric

func IncrementMetric(name string, opts MetricOptions) error

IncrementMetric submits a incremental measurement to the reporter. The measurements will be collected in the background and reported periodically.

func SetLogLevel

func SetLogLevel(level string) error

SetLogLevel changes the logging level of the library Valid logging levels: DEBUG, INFO, WARN, ERROR

func SetLogOutput

func SetLogOutput(w io.Writer)

SetLogOutput sets the output destination for the internal logger.

func SetServiceKey

func SetServiceKey(key string) error

SetServiceKey sets the service key of the agent

func SetTransactionName

func SetTransactionName(ctx context.Context, name string) error

SetTransactionName sets the transaction name of the current entry span. If set multiple times, the last is used. Returns nil on success; Error if the provided name is blank, or we are unable to set the transaction name.

func Shutdown

func Shutdown(ctx context.Context) error

Shutdown flush the metrics and stops the agent. The call will block until the agent flushes and is successfully shutdown or the context is canceled. It returns nil for successful shutdown and or error when the context is canceled or the agent has already been closed before.

This function should be called only once.

func Start

func Start(resourceAttrs ...attribute.KeyValue) (func(), error)

Start bootstraps otel requirements and starts the agent. The given `resourceAttrs` are added to the otel `resource.Resource` that is supplied to the otel `TracerProvider`

func SummaryMetric

func SummaryMetric(name string, value float64, opts MetricOptions) error

SummaryMetric submits a summary type measurement to the reporter. The measurements will be collected in the background and reported periodically.

func WaitForReady

func WaitForReady(ctx context.Context) bool

WaitForReady checks if the agent is ready. It returns true is the agent is ready, or false if it is not.

A call to this method will block until the agent is ready or the context is canceled, or the agent is already closed. The agent is considered ready if there is a valid default setting for sampling.

Types

type LoggableTraceContext

type LoggableTraceContext struct {
	TraceID     trace.TraceID    `json:"trace_id,omitempty"`
	SpanID      trace.SpanID     `json:"span_id,omitempty"`
	TraceFlags  trace.TraceFlags `json:"trace_flags,omitempty"`
	ServiceName string           `json:"service_name,omitempty"`
}

func LoggableTrace

func LoggableTrace(ctx context.Context) LoggableTraceContext

LoggableTrace returns a LoggableTraceContext from a given context.Context and the configured service name

func LoggableTraceFromSpanContext

func LoggableTraceFromSpanContext(ctx trace.SpanContext) LoggableTraceContext

LoggableTraceFromSpanContext returns a LoggableTraceContext from a given SpanContext and the configured service name

func (LoggableTraceContext) IsValid

func (l LoggableTraceContext) IsValid() bool

IsValid returns true if both TraceID and SpanID are valid

func (LoggableTraceContext) String

func (l LoggableTraceContext) String() string

String returns a string representation that is usable in a log Example: trace_id=d4261c67357f99f39958b14f99da7e6c span_id=1280450002ba77b3 trace_flags=01 resource.service.name=my-service

type MetricOptions

type MetricOptions = metrics.MetricOptions

MetricOptions is a struct for the optional parameters of a measurement.

Jump to

Keyboard shortcuts

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