N|Solid
Public Types | Public Member Functions | List of all members
node::nsolid::MetricsStream Class Reference

Class to retrieve a stream of some thread-specific metrics. More...

#include <nsolid.h>

Public Types

enum  Type : uint32_t {
  Type::kRawDns = 1 << 0, Type::kRawHttpClient = 1 << 1, Type::kRawHttpServer = 1 << 2, Type::kRawGcRegular = 1 << 3,
  Type::kRawGcForced = 1 << 4, Type::kRawGcFull = 1 << 5, Type::kRawGcMajor = 1 << 6, Type::kRawGc = 120
}
 types of metrics that can be collected using MetricsStream. More...
 
using metrics_stream_bucket = std::vector< std::tuple< Type, double > >
 
using metrics_stream_proxy_sig = void(*)(MetricsStream *, metrics_stream_bucket, void *)
 

Public Member Functions

 MetricsStream (uint64_t thread_id)
 Construct a new Metrics Stream object. More...
 
 ~MetricsStream ()
 Destroy the Metrics Stream object. More...
 
template<typename Cb , typename... Data>
int Start (uint32_t flags, uint64_t timeout, uint32_t max_items, Cb &&cb, Data &&... data)
 start collecting specific metrics. More...
 
int Stop ()
 stop collecting metrics. More...
 
uint64_t ThreadId ()
 returns the thread_id the metrics are being gathered from. More...
 

Detailed Description

Class to retrieve a stream of some thread-specific metrics.

For some specific metrics: dns request duration, http client transaction duration, http server transaction duration and garbage collection duration, it's useful to receive all the datapoints collected by the N|Solid runtime instead of (or in addition to) the derived metrics calculated by N|Solid such as: dns_count, dns_median, dns99_ptile, etc. The MetricsStrem provides that specific feature.

Member Enumeration Documentation

◆ Type

enum node::nsolid::MetricsStream::Type : uint32_t
strong

types of metrics that can be collected using MetricsStream.

They can be combined in a flags field to specify which metrics are to be collected.

Enumerator
kRawDns 

DNS request duration

kRawHttpClient 

HTTP client transaction duration

kRawHttpServer 

HTTP server transaction duration

kRawGcRegular 

Duration of a "regular" garbage collection

kRawGcForced 

Duration of a "forced" garbage collection

kRawGcFull 

Duration of a "full" garbage collection

kRawGcMajor 

Duration of a "major" garbage collection

kRawGc 

kRawGcRegular | kRawGcForced | kRawGcFull | kRawGcMajor

Constructor & Destructor Documentation

◆ MetricsStream()

node::nsolid::MetricsStream::MetricsStream ( uint64_t  thread_id)
explicit

Construct a new Metrics Stream object.

Parameters
thread_idthe id of the JS thread the metrics are going to be retrieved from.

◆ ~MetricsStream()

node::nsolid::MetricsStream::~MetricsStream ( )

Destroy the Metrics Stream object.

Member Function Documentation

◆ Start()

template<typename Cb , typename... Data>
int node::nsolid::MetricsStream::Start ( uint32_t  flags,
uint64_t  timeout,
uint32_t  max_items,
Cb &&  cb,
Data &&...  data 
)

start collecting specific metrics.

The metrics will be returned in bucket in a callback. This callback will be called periodically either when the bucket reaches the max_items size or timeout milliseconds have passed.

Parameters
flagsallows filtering which specific metrics are going to be retrieved.
timeoutmetrics gathering maximum period. If reached without filling the bucket, the callback is called.
max_itemsmetrics bucket maximum capacity. When it's reached the callback is called.
cbcallback function with the following signature: cb(MetricsStream*, metrics_stream_bucket, ...Data)
datavariable number of arguments to be propagated to the callback.
Returns
NSOLID_E_SUCCESS in case of success or a different NSOLID_E_ error value otherwise.

◆ Stop()

int node::nsolid::MetricsStream::Stop ( )

stop collecting metrics.

Returns
NSOLID_E_SUCCESS in case of success or a different NSOLID_E_ error value otherwise.

◆ ThreadId()

uint64_t node::nsolid::MetricsStream::ThreadId ( )

returns the thread_id the metrics are being gathered from.

Returns
uint64_t

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