Documentation ¶
Index ¶
- Constants
- Variables
- func BuildBuiltinMetricsMessage(m *Measurements, qs *EventQueueStats, rcs map[string]*RateCounts, ...) []byte
- func BuildMessage(m *Measurements, serverless bool) []byte
- func BuildServerlessMessage(span HTTPSpanMessage, rcs map[string]*RateCounts, rate int, source int) []byte
- func GetTransactionFromPath(path string) string
- type BaseSpanMessage
- type EventQueueStats
- func (s *EventQueueStats) CopyAndReset() *EventQueueStats
- func (s *EventQueueStats) NumFailedAdd(n int64)
- func (s *EventQueueStats) NumOverflowedAdd(n int64)
- func (s *EventQueueStats) NumSentAdd(n int64)
- func (s *EventQueueStats) SetQueueLargest(count int64)
- func (s *EventQueueStats) TotalEventsAdd(n int64)
- type HTTPSpanMessage
- type Measurement
- type Measurements
- func (m *Measurements) Cap() int32
- func (m *Measurements) Clone() *Measurements
- func (m *Measurements) CopyAndReset(flushInterval int32) *Measurements
- func (m *Measurements) Increment(name string, opts MetricOptions) error
- func (m *Measurements) SetCap(cap int32)
- func (m *Measurements) Summary(name string, value float64, opts MetricOptions) error
- type MetricOptions
- type RateCounts
- func (c *RateCounts) FlushRateCounts() *RateCounts
- func (c *RateCounts) Limited() int64
- func (c *RateCounts) LimitedInc()
- func (c *RateCounts) Requested() int64
- func (c *RateCounts) RequestedInc()
- func (c *RateCounts) Sampled() int64
- func (c *RateCounts) SampledInc()
- func (c *RateCounts) Through() int64
- func (c *RateCounts) ThroughInc()
- func (c *RateCounts) Traced() int64
- func (c *RateCounts) TracedInc()
- type SpanMessage
- type TransMap
Constants ¶
const ( CustomTransactionNamePrefix = "custom" OtherTransactionName = "other" MetricIDSeparator = "&" TagsKVSeparator = ":" OtherMetricIDPrefix = OtherTransactionName + MetricIDSeparator )
Special transaction names
const ( RequestCount = "RequestCount" TraceCount = "TraceCount" TokenBucketExhaustionCount = "TokenBucketExhaustionCount" SampleCount = "SampleCount" ThroughTraceCount = "ThroughTraceCount" TriggeredTraceCount = "TriggeredTraceCount" )
Request counters definition
const ( RCRegular = "ReqCounterRegular" RCRelaxedTriggerTrace = "ReqCounterRelaxedTriggerTrace" RCStrictTriggerTrace = "ReqCounterStrictTriggerTrace" )
Request counters collection categories
const (
// MaxTagsCount is the maximum number of tags allowed
MaxTagsCount = 50
)
Variables ¶
var ( // ErrExceedsMetricsCountLimit indicates there are too many distinct metrics. ErrExceedsMetricsCountLimit = errors.New("exceeds metrics count limit per flush interval") // ErrExceedsTagsCountLimit indicates there are too many tags ErrExceedsTagsCountLimit = errors.New("exceeds tags count limit") // ErrMetricsWithNonPositiveCount indicates the count is negative or zero ErrMetricsWithNonPositiveCount = errors.New("metrics with non-positive count") )
Functions ¶
func BuildBuiltinMetricsMessage ¶
func BuildBuiltinMetricsMessage(m *Measurements, qs *EventQueueStats, rcs map[string]*RateCounts, runtimeMetrics bool) []byte
BuildBuiltinMetricsMessage generates a metrics message in BSON format with all the currently available values metricsFlushInterval current metrics flush interval
return metrics message in BSON format
func BuildMessage ¶
func BuildMessage(m *Measurements, serverless bool) []byte
BuildMessage creates and encodes the custom metrics message.
func BuildServerlessMessage ¶
func BuildServerlessMessage(span HTTPSpanMessage, rcs map[string]*RateCounts, rate int, source int) []byte
func GetTransactionFromPath ¶
GetTransactionFromPath performs fingerprinting on a given escaped path to extract the transaction name We can get the path so there is no need to parse the full URL. e.g. Escaped Path path: /45638654564654/appoptics-apm-go/blob/metrics becomes /45638654564654/appoptics-apm-go
Types ¶
type BaseSpanMessage ¶
type BaseSpanMessage struct { Duration time.Duration // duration of the span (nanoseconds) HasError bool // boolean flag whether this transaction contains an error or not }
BaseSpanMessage is the base span message with properties found in all types of span messages
type EventQueueStats ¶
type EventQueueStats struct {
// contains filtered or unexported fields
}
EventQueueStats is the counters of the event queue stats All the fields are supposed to be accessed through atomic operations
func (*EventQueueStats) CopyAndReset ¶
func (s *EventQueueStats) CopyAndReset() *EventQueueStats
CopyAndReset returns a copy of its current values and reset itself.
func (*EventQueueStats) NumFailedAdd ¶
func (s *EventQueueStats) NumFailedAdd(n int64)
func (*EventQueueStats) NumOverflowedAdd ¶
func (s *EventQueueStats) NumOverflowedAdd(n int64)
func (*EventQueueStats) NumSentAdd ¶
func (s *EventQueueStats) NumSentAdd(n int64)
func (*EventQueueStats) SetQueueLargest ¶
func (s *EventQueueStats) SetQueueLargest(count int64)
func (*EventQueueStats) TotalEventsAdd ¶
func (s *EventQueueStats) TotalEventsAdd(n int64)
type HTTPSpanMessage ¶
type HTTPSpanMessage struct { BaseSpanMessage Transaction string // transaction name (e.g. controller.action) Path string // the url path which will be processed and used as transaction (if Transaction is empty) Status int // HTTP status code (e.g. 200, 500, ...) Host string // HTTP-Host Method string // HTTP method (e.g. GET, POST, ...) }
HTTPSpanMessage is used for inbound metrics
func (*HTTPSpanMessage) Process ¶
func (s *HTTPSpanMessage) Process(m *Measurements)
Process processes an HttpSpanMessage
type Measurement ¶
type Measurement struct { Name string // the name of the measurement (e.g. TransactionResponseTime) Tags map[string]string // map of KVs. It may be nil Count int // count of this measurement Sum float64 // sum for this measurement ReportSum bool // include the sum in the report? }
Measurement is a single measurement for reporting
type Measurements ¶
type Measurements struct { IsCustom bool FlushInterval int32 sync.Mutex // protect access to this collection // contains filtered or unexported fields }
Measurements are a collection of mutex-protected measurements
func NewMeasurements ¶
func NewMeasurements(isCustom bool, flushInterval int32, maxCount int32) *Measurements
func (*Measurements) Cap ¶
func (m *Measurements) Cap() int32
Cap returns the maximum number of distinct metrics allowed.
func (*Measurements) Clone ¶
func (m *Measurements) Clone() *Measurements
Clone returns a shallow copy
func (*Measurements) CopyAndReset ¶
func (m *Measurements) CopyAndReset(flushInterval int32) *Measurements
CopyAndReset resets the custom metrics and return a copy of the old one.
func (*Measurements) Increment ¶
func (m *Measurements) Increment(name string, opts MetricOptions) error
Increment submits the incremental measurement to the reporter.
func (*Measurements) SetCap ¶
func (m *Measurements) SetCap(cap int32)
SetCap sets the maximum number of distinct metrics allowed.
func (*Measurements) Summary ¶
func (m *Measurements) Summary(name string, value float64, opts MetricOptions) error
Summary submits the summary measurement to the reporter.
type MetricOptions ¶
MetricOptions is a struct for the optional parameters of a measurement.
type RateCounts ¶
type RateCounts struct {
// contains filtered or unexported fields
}
RateCounts is the rate counts reported by trace sampler
func (*RateCounts) FlushRateCounts ¶
func (c *RateCounts) FlushRateCounts() *RateCounts
FlushRateCounts reset the counters and returns the current value
func (*RateCounts) Limited ¶
func (c *RateCounts) Limited() int64
func (*RateCounts) LimitedInc ¶
func (c *RateCounts) LimitedInc()
func (*RateCounts) Requested ¶
func (c *RateCounts) Requested() int64
func (*RateCounts) RequestedInc ¶
func (c *RateCounts) RequestedInc()
func (*RateCounts) Sampled ¶
func (c *RateCounts) Sampled() int64
func (*RateCounts) SampledInc ¶
func (c *RateCounts) SampledInc()
func (*RateCounts) Through ¶
func (c *RateCounts) Through() int64
func (*RateCounts) ThroughInc ¶
func (c *RateCounts) ThroughInc()
func (*RateCounts) Traced ¶
func (c *RateCounts) Traced() int64
func (*RateCounts) TracedInc ¶
func (c *RateCounts) TracedInc()
type SpanMessage ¶
type SpanMessage interface {
Process(m *Measurements)
}
SpanMessage defines a span message
type TransMap ¶
type TransMap struct {
// contains filtered or unexported fields
}
TransMap records the received transaction names in a metrics report cycle. It will refuse new transaction names if reaching the capacity.
func NewTransMap ¶
NewTransMap initializes a new TransMap struct
func (*TransMap) IsWithinLimit ¶
IsWithinLimit checks if the transaction name is stored in the TransMap. It will store this new transaction name and return true if not stored before and the map isn't full, or return false otherwise.
func (*TransMap) Overflow ¶
Overflow returns true is the transaction map is overflow (reached its limit) or false if otherwise.