[#BloombergLP-balm]
= xref:BloombergLP.adoc[BloombergLP]::balm
:relfileprefix: ../
:mrdocs:

Package namespace for metrics components&period;

== Types

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/balm/BdlmMetricsAdapter.adoc[`BdlmMetricsAdapter`] 
| This class implements a pure abstract interface for clients and suppliers of metrics adapters&period; The implementation registers callbacks with a provided `balm&colon;&colon;MetricsManager` to enable monitoring of statistics collection objects&period;
| xref:BloombergLP/balm/Category.adoc[`Category`] 
| This class provides a mechanism for representing a category&period; A category is an identifier used to group related metrics&period; A `Category` object contains the address of a null&hyphen;terminated string, `name`, holding the name of the category and a boolean value, `enabled`, indicating whether the category is currently enabled&period;
| xref:BloombergLP/balm/CategoryHolder.adoc[`CategoryHolder`] 
| This class, informally referred to as a &quot;category holder&quot; (or simply &quot;holder&quot;), holds a category, an enabled value, and a pointer to a &quot;next&quot; holder&period; Both the category and next pointer may be null&period; The intended use is as follows&colon; (1) instances of this class are (only) declared in contexts where collecting a metric occurs&semi; (2) if the enabled value is true, the category contains the address of a valid, enabled, category&semi; (3) if the next pointer is non&hyphen;null, then the holder pointed to holds the same category and threshold&period; Instances of this class must be _statically_ initializable&period; Hence, the data members are `public`, and no constructors or destructor are defined&period;
| xref:BloombergLP/balm/Collector.adoc[`Collector`] 
| This class provides a mechanism for collecting and aggregating the value of a metric over a period of time&period; The collector contains a `MetricRecord` object that holds the identity of the metric being collected, the number of times an event occurred, and the total, minimum, and maximum aggregates of the associated measurement value&period; The default value for the count is 0, the default value for the total is 0&period;0, the default minimum value is `MetricRecord&colon;&colon;k&lowbar;DEFAULT&lowbar;MIN`, and the default maximum value is `MetricRecord&colon;&colon;k&lowbar;DEFAULT&lowbar;MAX`&period;
| xref:BloombergLP/balm/CollectorRepository.adoc[`CollectorRepository`] 
| This class defines a fully thread&hyphen;safe repository mechanism for `Collector` and `IntegerCollector` objects&period; Collectors are identified in the repository by a `MetricId` object and also grouped together according to the category of the metric&period; This repository supports operations to create, find, and collect metric records from the collectors in the repository&period;
| xref:BloombergLP/balm/CollectorRepository_MetricCollectors.adoc[`CollectorRepository&lowbar;MetricCollectors`] 
| Private implementation type holding collectors for a single metric id&period;
| xref:BloombergLP/balm/ConfigurationUtil.adoc[`ConfigurationUtil`] 
| This `struct` provides utilities for configuring metrics&period;
| xref:BloombergLP/balm/DefaultMetricsManager.adoc[`DefaultMetricsManager`] 
| This struct provides a namespace for static functions that create, access, and destroy the default instance of the `MetricsManager`&period; The expected usage is that the default instance will be created during the initialization of an application (while the task has a single thread) and that it will be destroyed just prior to termination (when there is similarly a single thread)&period;
| xref:BloombergLP/balm/DefaultMetricsManagerScopedGuard.adoc[`DefaultMetricsManagerScopedGuard`] 
| This class implements a scoped guard that, on construction, creates the default instance of the metrics manager, and, on destruction, destroys that instance&period; Note that the behavior is undefined if the default instance of the metrics manager is created before creating this guard, or if the default instance is externally destroyed before destroying this guard&period;
| xref:BloombergLP/balm/IntegerCollector.adoc[`IntegerCollector`] 
| This class provides a mechanism for collecting and aggregating the value of an integer metric over a period of time&period; The collector contains a `MetricId` object identifying the metric being collected, the number of times an event occurred, and the total, minimum, and maximum aggregates of the associated measurement value&period; The default value for the count is 0, the default value for the total is 0, the default value for the minimum is `k&lowbar;DEFAULT&lowbar;MIN`, and the default value for the maximum is `k&lowbar;DEFAULT&lowbar;MAX`&period;
| xref:BloombergLP/balm/IntegerMetric.adoc[`IntegerMetric`] 
| This class provides an in&hyphen;core value semantic type for recording and aggregating the values of an integer metric&period; The value of a `IntegerMetric` object is characterized by the `IntegerCollector` object it uses to collect metric&hyphen;event values&period; Each instance of this class establishes (at construction) an association to an `IntegerCollector` object to which the metric delegates&period; A `IntegerMetric` value is constant after construction (i&period;e&period;, it does not support assignment or provide manipulators that modify its collector value), so that synchronization primitives are not required to protect its data members&period; Note that if a collector or metrics manager is not supplied at construction, and if the default metrics manager has not been instantiated, then the metric will be inactive (i&period;e&period;, `isActive()` is `false`) and the manipulator methods of the integer metric object will have no effect&period;
| xref:BloombergLP/balm/IntegerMetric_MacroImp.adoc[`IntegerMetric&lowbar;MacroImp`] 
| This structure provides a namespace for functions used to implement the macros defined by this component&period;
| xref:BloombergLP/balm/Metric.adoc[`Metric`] 
| This class provides an in&hyphen;core value semantic type for recording and aggregating the values of a metric&period; The value of a `Metric` object is characterized by the `Collector` object it uses to collect metric&hyphen;event values&period; Each instance of this class establishes (at construction) an association to a `Collector` object to which the metric delegates&period; A `Metric` value is constant after construction (i&period;e&period;, it does not support assignment or provide manipulators that modify its collector value) so that synchronization primitives are not required to protect its data members&period; Note that if a collector or metrics manager is not supplied at construction, and if the default metrics manager has not been instantiated, then the metric will be inactive (i&period;e&period;, `isActive() &equals;&equals; false`) and the manipulator methods of the metric object will have no effect&period;
| xref:BloombergLP/balm/MetricDescription.adoc[`MetricDescription`] 
| This class provides a mechanism for describing a metric&period; A `MetricDescription` holds the category to which the metric belongs, and a null&hyphen;terminated string containing the name of the metric&period;
| xref:BloombergLP/balm/MetricFormat.adoc[`MetricFormat`] 
| This class provides a value&hyphen;semantic description for the formatting of a metric&period; For each published aggregate type of a metric (e&period;g&period;, count, total, min, max, etc&period;), a `MetricFormat` contains a `MetricFormatSpec` object describing how to format values of that aggregate, or null if no formatting information is supplied&period; `Metricformat` provides the `setFormatSpec` method to set the format spec for a publication type, and the `formatSpec` method to retrieve the format spec for a publication type (or 0 if no format spec has been provided for the indicated publication type)&period; Note that the types of published aggregates explicitly provided by the `balm` package are defined in the `PublicationType` enumeration&period;
| xref:BloombergLP/balm/MetricFormatSpec.adoc[`MetricFormatSpec`] 
| This class provides a value&hyphen;semantic representation of the formatting specification for a metric aggregate value&period; The `scale()` is a multiplier used to scale the numeric value&period; The `format()` is a `printf`&hyphen;style format string suitable for formatting a single floating&hyphen;point value&period;
| xref:BloombergLP/balm/MetricId.adoc[`MetricId`] 
| This class defines an in&hyphen;core value&hyphen;semantic type used to identify a metric&period; A `MetricId` object&apos;s value is the _address_ of a non&hyphen;modifiable `MetricDescription` object&period; In addition, a `MetricDescription` object provides auxiliary methods, `category`, `categoryName`, and `name`, that enable access to the properties of the held `MetricDescription`&period; Two `MetricId` objects have the same value if the values of their respective `MetricDescription` object _addresses_ are the same&period;
| xref:BloombergLP/balm/MetricRecord.adoc[`MetricRecord`] 
| Each instance of this class represents the aggregated value of a metric&period; A metric record contains a `MetricId` object (identifying the metric), the number of times the measured event has occurred as well as the minimum, maximum, and total of the measured value&period; The default `metricId` is the invalid id value, the default `count` is 0, the defined `k&lowbar;DEFAULT&lowbar;MIN` constant (the representation for positive default `total` is 0&period;0, the default `min` is the infinity), and the default `max` is the defined `k&lowbar;DEFAULT&lowbar;MAX` constant (the representation for negative infinity)&period;
| xref:BloombergLP/balm/MetricRegistry.adoc[`MetricRegistry`] 
| The class defines a thread&hyphen;aware mechanism for registering metrics and metric categories&period; A metric is uniquely identified by its name and category, and the metric registry provides a mapping from those identifying properties to a `balm&colon;&colon;MetricId`&period; A `balm&colon;&colon;MetricRegistry` object also provides a mapping from a category name to the address of a non&hyphen;modifiable `balm&colon;&colon;Category` object&period;
| xref:BloombergLP/balm/MetricSample.adoc[`MetricSample`] 
| This class provides an _in&hyphen;core_ value&hyphen;semantic representation of a sample of metric values&period; The class contains a collection of addresses to (external) `MetricRecord` objects holding the values for their respective metrics (aggregated over some period of time)&period; The metric records contained by a sample are broken into a series of groups, which are represented by `MetricSampleGroup` objects&period; Each group contains a sequence of records and an elapsed time value, indicating the period of time over which those records were taken&period; This class also provides a timestamp value, used to indicate when the sample was collected&period; The class provides a method, `appendGroups`, that appends a group of metric records to the sample&period; Arrays supplied using `appendGroups` must be valid for the productive lifetime of the `MetricSample` object or until they are removed by calling `removeAllRecords`&period;
| xref:BloombergLP/balm/MetricSampleGroup.adoc[`MetricSampleGroup`] 
| This class provides an _in&hyphen;core_ value&hyphen;semantic representation of a group of metric record values&period; This class contains the address of an array of (externally managed) `MetricRecord` objects, the number of records in that array, and an elapsed time value (used to indicate the time span over which the metric values were aggregated)&period;
| xref:BloombergLP/balm/Metric_MacroImp.adoc[`Metric&lowbar;MacroImp`] 
| This structure provides a namespace for functions used to implement the macros defined by this component&period;
| xref:BloombergLP/balm/MetricsManager.adoc[`MetricsManager`] 
| This class implements a manager for the recording and publishing of metrics&period; Metrics managed by a `MetricsManager` are grouped into categories identified by a string&period; The metrics manager allows clients to register a `Publisher` object using the `addGeneralPublisher` and `addSpecificPublisher` operations&period; Metrics can be recorded in one of two ways&colon; Clients can (1) implement their own metric collection facilities and register a callback using this metric manager&apos;s `registerMetricsCallback` method&semi; or (2) use the `Collector` objects available from the `CollectorRepository` owned by this metrics manager&period;
| xref:BloombergLP/balm/MetricsManager_CallbackRegistry.adoc[`MetricsManager&lowbar;CallbackRegistry`] 
| defined in implementation
| xref:BloombergLP/balm/MetricsManager_PublicationHelper.adoc[`MetricsManager&lowbar;PublicationHelper`] 
| defined in implementation
| xref:BloombergLP/balm/MetricsManager_PublisherRegistry.adoc[`MetricsManager&lowbar;PublisherRegistry`] 
| Private implementation type for the publisher registry&period;
| xref:BloombergLP/balm/Metrics_Helper.adoc[`Metrics&lowbar;Helper`] 
| This `struct` provides a namespace for a suite of functions used in the implementation of the macros defined in this component&period;
| xref:BloombergLP/balm/PublicationScheduler.adoc[`PublicationScheduler`] 
| This class defines a mechanism for scheduling the periodic publication of metrics&period; Each publication scheduler object is supplied the address of a `MetricsManager` and a `bdlmt&colon;&colon;TimerEventScheduler` at construction&period; The metrics manager is used to publish metrics, while the timer&hyphen;event scheduler provides the underlying scheduling mechanism&period; Metrics are scheduled for publication using the `scheduleCategory` and `setDefaultSchedule` methods&period; The `scheduleCategory` method schedules an individual category to be publisher periodically at the provided interval, whereas `setDefaultSchedule` schedules the periodic publication of any category not given an individual schedule&period; The publication scheduler will create a recurring timer for each unique time interval supplied, and will group together categories that share a common time interval into a single call to `MetricsManager&colon;&colon;publish`&period; Note that it is left unspecified whether publication events that occur on a common multiple of _different_ intervals will be grouped into a single invocation of `MetricsManager&colon;&colon;publish`&period;
| xref:BloombergLP/balm/PublicationScheduler_ClockData.adoc[`PublicationScheduler&lowbar;ClockData`] 
| Private implementation type for clock data used by the scheduler&period;
| xref:BloombergLP/balm/PublicationScheduler_Proctor.adoc[`PublicationScheduler&lowbar;Proctor`] 
| defined in implementation
| xref:BloombergLP/balm/PublicationType.adoc[`PublicationType`] 
| This class defines an enumeration of aggregation type that can be used to describe the published output of a metric&period; Concrete `Publisher` implementations may use this these types to configure their output&period;
| xref:BloombergLP/balm/Publisher.adoc[`Publisher`] 
| This protocol class provides a `publish` method to publish collected sample of recorded metric values&period; The precise meaning of publish is left to derived classes to specify&period;
| xref:BloombergLP/balm/StopwatchScopedGuard.adoc[`StopwatchScopedGuard`] 
| This class provides a mechanism for recording, to a metric, the elapsed time from the construction of an instance of the guard until that instance goes out of scope (and is destroyed)&period; The constructor of this class takes an optional argument indicating the time units in which to report the elapsed time&semi; by default a guard will report time in seconds&period; The supplied time units determine the scale of the double value reported by this guard, but does _not_ affect the precision of the elapsed time measurement&period; Each instance of this class delegates to a `Collector` for the metric&period; This `Collector` is initialized on construction based on the constructor arguments&period; If this scoped guard is not initialized with an active metric, or if the supplied metric becomes inactive before the scoped guard is destroyed, then `isActive()` will return `false` and no metric values will be recorded&period; Note that if the metric supplied at construction is not active when the scoped guard is constructed, the scoped guard will not become active or record metric values regardless of the future state of that supplied metric&period;
| xref:BloombergLP/balm/StreamPublisher.adoc[`StreamPublisher`] 
| This class provides an implementation of the `Publisher` protocol&period; This stream publisher publishes recorded metric values to an output stream specified at construction&period;
|===


== Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/balm/operator_lshift-09.adoc[`operator&lt;&lt;`] 
| Stream insertion operators
| xref:BloombergLP/balm/operator_eq-03.adoc[`operator&equals;&equals;`] 
| Equality operators
| xref:BloombergLP/balm/operator_not_eq-00.adoc[`operator!&equals;`] 
| Inequality operators
| xref:BloombergLP/balm/operator_lt.adoc[`operator&lt;`] 
| Return `true` if the specified `lhs` metric id is less than (ordered before) the specified `rhs` metric id, and return `false` otherwise&apos;&period; The `lhs` is considered less if the (unsigned) _address_ of the contained `MetricDescription` object is numerically less than the `rhs` description&period; Note that this function does _not_ provide any form of alphabetic ordering, and is logically equivalent to the expression `lhs&period;description() &lt; rhs&period;description()`&period;
|===



[.small]#Created with https://www.mrdocs.com[MrDocs]#
