Documentation ¶
Index ¶
- Constants
- Variables
- func Closed() bool
- func GetLogLevel() string
- func IncrementMetric(name string, opts MetricOptions) error
- func SetLogLevel(level string) error
- func SetLogOutput(w io.Writer)
- func SetServiceKey(key string) error
- func SetTransactionName(ctx context.Context, name string) error
- func Shutdown(ctx context.Context) error
- func Start(resourceAttrs ...attribute.KeyValue) (func(), error)
- func SummaryMetric(name string, value float64, opts MetricOptions) error
- func WaitForReady(ctx context.Context) bool
- type LoggableTraceContext
- type MetricOptions
Constants ¶
const ( // MaxTagsCount is the maximum number of tags allowed. MaxTagsCount = metrics.MaxTagsCount )
Variables ¶
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 ¶
SetLogLevel changes the logging level of the library Valid logging levels: DEBUG, INFO, WARN, ERROR
func SetLogOutput ¶
SetLogOutput sets the output destination for the internal logger.
func SetServiceKey ¶
SetServiceKey sets the service key of the agent
func SetTransactionName ¶
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 ¶
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 ¶
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 ¶
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.