Skip to main content
Pigweed's logo Pigweed
code_xml
  1. Home
  2. Reference
  3. C/C++
  4. Observability
  5. pw_metric
  6. pw::metric::Group Class Reference
pw::metric::Group Class Reference

Overview

A metric tree consisting of children groups and leaf metrics.

Size: 16 bytes / 128 bits on 32-bit platforms - next, name, metrics, children.

Inheritance diagram for pw::metric::Group:

Public Member Functions

constexpr Group (Token name)
 
constexpr Group (Token name, GroupList &groups)
 
constexpr Token name () const
 Returns this group's tokenized name.
 
 Group (Group const &)=delete
 
void operator= (const Group &)=delete
 
constexpr void Add (UntypedMetric &metric)
 
constexpr void Add (Group &group)
 
constexpr MetricList & metrics ()
 Returns the mutable list of metrics in this group.
 
constexpr GroupList & children ()
 Returns the mutable list of child groups in this group.
 
constexpr const MetricList & metrics () const
 Returns the list of metrics in this group.
 
constexpr const GroupList & children () const
 Returns the list of child groups in this group.
 
void Dump () const
 

Static Public Member Functions

static void Dump (const GroupList &groups, int indent_level=0)
 

Constructor & Destructor Documentation

◆ Group() [1/2]

constexpr pw::metric::Group::Group ( Token  name)
inlineconstexpr

Constructs an empty, unregistered metric group with the given tokenized name.

Parameters
[in]nameTokenized name of this metric group.

◆ Group() [2/2]

constexpr pw::metric::Group::Group ( Token  name,
GroupList &  groups 
)
inlineconstexpr

Constructs a metric group with the given tokenized name and registers it in groups.

Parameters
[in]nameTokenized name of this metric group.
[in,out]groupsParent or global group list to register with.
Precondition
groups must already be initialized, and any concurrent access to groups must be externally synchronized.

Member Function Documentation

◆ Add() [1/2]

constexpr void pw::metric::Group::Add ( Group &  group)
inlineconstexpr

Adds child group to this group's children list.

Parameters
[in,out]groupChild group to add to this group's children list.
Precondition
group must not already belong to a list, and concurrent mutations of this group must be externally synchronized.

◆ Add() [2/2]

constexpr void pw::metric::Group::Add ( UntypedMetric &  metric)
inlineconstexpr

Adds metric to this group's metrics list.

Parameters
[in,out]metricMetric to add to this group's metrics list.
Precondition
metric must not already belong to a list, and concurrent mutations of this group must be externally synchronized.

◆ Dump()

void pw::metric::Group::Dump ( ) const

Recursively dump a metrics group or groups to pw_log. Level determines the indentation indent_level up to a maximum of 4. Produces output like:

"$6doqFw==": {
"$05OCZw==": {
"$VpPfzg==": 1,
"$LGPMBQ==": 1.000000,
"$+iJvUg==": 5
},
"$9hPNxw==": 65,
"$oK7HmA==": 13,
"$FCM4qQ==": 0
}

Note the metric names are tokenized with base64. Decoding requires using the Pigweed detokenizer. With a detokenizing-enabled logger, you could get something like:

"i2c_1": {
"gyro": {
"num_sampleses": 1,
"init_time_us": 1.000000,
"initialized": 5,
}
"bus_errors": 65,
"transactions": 13,
"bytes_sent": 0,
}

The documentation for this class was generated from the following file: