Documentation
¶
Index ¶
- type Collector
- func (c *Collector) Allocated() int64
- func (c *Collector) Gets() int64
- func (c *Collector) Grows() int64
- func (c *Collector) HitRate() float64
- func (c *Collector) Hits() int64
- func (c *Collector) Misses() int64
- func (c *Collector) Puts() int64
- func (c *Collector) RecordGet()
- func (c *Collector) RecordGrow()
- func (c *Collector) RecordHit()
- func (c *Collector) RecordMiss()
- func (c *Collector) RecordPut()
- func (c *Collector) RecordShrink()
- func (c *Collector) RecordWaiterAdd()
- func (c *Collector) RecordWaiterDone()
- func (c *Collector) Recycled() int64
- func (c *Collector) Reset()
- func (c *Collector) Shrinks() int64
- func (c *Collector) Uptime() time.Duration
- func (c *Collector) Waiters() int32
- type PrometheusExporter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
purpose: keeps track of all the interesting numbers about how our pool is performing,
like how many times we got items, how many times we missed, and how full the pool is
params: none (this is a type definition) args: n/a returns: n/a raises: n/a
func NewCollector ¶
func NewCollector() *Collector
purpose: creates a brand new metrics collector ready to track pool statistics params: none args: initializes all counters to zero and records when we started returns: pointer to Collector - a fresh collector raises: none
func (*Collector) Allocated ¶
purpose: gets the total number of new allocations params: none args: reads the atomic counter returns: count int64 - total allocated raises: none
func (*Collector) Gets ¶
purpose: gets the total number of get operations params: none args: reads the atomic counter returns: count int64 - total gets raises: none
func (*Collector) Grows ¶
purpose: gets how many times the pool grew params: none args: reads the atomic counter returns: count int64 - total grows raises: none
func (*Collector) HitRate ¶
purpose: calculates what percentage of get requests found items in the pool params: none args: divides hits by total gets to get a percentage from 0 to 1 returns: hitRate float64 - the hit rate (1.0 means 100% hits) raises: none
func (*Collector) Hits ¶
purpose: gets the total number of hits (found in pool) params: none args: reads the atomic counter returns: count int64 - total hits raises: none
func (*Collector) Misses ¶
purpose: gets the total number of misses (empty pool) params: none args: reads the atomic counter returns: count int64 - total misses raises: none
func (*Collector) Puts ¶
purpose: gets the total number of put operations params: none args: reads the atomic counter returns: count int64 - total puts raises: none
func (*Collector) RecordGet ¶
func (c *Collector) RecordGet()
purpose: records that someone tried to get an item from the pool params: none args: increases our get counter by one returns: none raises: none
func (*Collector) RecordGrow ¶
func (c *Collector) RecordGrow()
purpose: records that the pool grew bigger to hold more items params: none args: increases our grow counter returns: none raises: none
func (*Collector) RecordHit ¶
func (c *Collector) RecordHit()
purpose: records that we successfully gave someone an item from the pool params: none args: increases our hit counter and recycled counter returns: none raises: none
func (*Collector) RecordMiss ¶
func (c *Collector) RecordMiss()
purpose: records that we couldn't give someone an item because the pool was empty params: none args: increases both our miss counter and our allocated counter returns: none raises: none
func (*Collector) RecordPut ¶
func (c *Collector) RecordPut()
purpose: records that someone returned an item to the pool params: none args: increases our put counter by one returns: none raises: none
func (*Collector) RecordShrink ¶
func (c *Collector) RecordShrink()
purpose: records that the pool shrank to use less memory params: none args: increases our shrink counter returns: none raises: none
func (*Collector) RecordWaiterAdd ¶
func (c *Collector) RecordWaiterAdd()
purpose: records that a goroutine is waiting for an item to become available params: none args: increases the waiter counter returns: none raises: none
func (*Collector) RecordWaiterDone ¶
func (c *Collector) RecordWaiterDone()
purpose: records that a goroutine stopped waiting params: none args: decreases the waiter counter returns: none raises: none
func (*Collector) Recycled ¶
purpose: gets the total number of recycled items params: none args: reads the atomic counter returns: count int64 - total recycled raises: none
func (*Collector) Reset ¶
func (c *Collector) Reset()
purpose: resets all counters back to zero, like starting fresh params: none args: sets each counter to zero returns: none raises: none
func (*Collector) Shrinks ¶
purpose: gets how many times the pool shrank params: none args: reads the atomic counter returns: count int64 - total shrinks raises: none
type PrometheusExporter ¶
type PrometheusExporter struct {
// contains filtered or unexported fields
}
purpose: helps export our metrics in prometheus format, which is a standard way to share
monitoring data that many tools can read and display
params: none (this is a type definition) args: n/a returns: n/a raises: n/a
func NewPrometheusExporter ¶
func NewPrometheusExporter(namespace string) *PrometheusExporter
purpose: creates a new prometheus exporter with a namespace to organize metrics params: namespace string - a prefix for all our metric names args: sets up an empty collection of collectors returns: pointer to PrometheusExporter - ready to export metrics raises: none
func (*PrometheusExporter) Export ¶
func (pe *PrometheusExporter) Export() string
purpose: generates the full prometheus metrics text that can be scraped by monitoring tools params: none args: loops through all collectors and formats their stats in prometheus format returns: metrics string - the complete metrics text raises: none
func (*PrometheusExporter) Register ¶
func (pe *PrometheusExporter) Register(name string, collector *Collector)
purpose: registers a collector so we can track its metrics params: name string - what to call this collector
collector *Collector - the collector to register
args: stores the collector in our map under the given name returns: none raises: none
func (*PrometheusExporter) Unregister ¶
func (pe *PrometheusExporter) Unregister(name string)
purpose: removes a collector from our tracking params: name string - which collector to forget args: deletes it from our map returns: none raises: none