MySQL 9.1.0
Source Code Documentation
Service Introduction

This service is named pfs_metrics_v1 and it exposes the following methods:

  • register_meters : register a batch of meters (metric groups), each with its own metric set
  • unregister_meters : unregister a batch of meters
  • register_change_notification : metric component to register a callback function to be notified of the changes related to meter status
  • unregister_change_notification : unregister change notification callback
  • send_change_notification : helper to trigger exact change notification (if callback registered)

Metric sources are grouped into metric groups (meters) to follow the Open Telemetry model.

Register/unregister methods accept an array of PSI_meter_info_v1 structures, each describing a single meter using fields:

  • name
  • description
  • meter export frequency (in seconds)
  • meter key (equals to 0 if meter instrument failed to register)
  • an array (with size) of metrics belonging to this meter

Metrics array consists of PSI_metric_info_v1 structures, describing a metric using fields:

  • name
  • unit (optional, string like "s", "ms", "By")
  • Open Telemetry metric type
  • numeric type (integer or floating point measurement value)
  • metric key (equals to 0 if metric instrument failed to register)
  • measurement callback method (function to be called when requesting metric measurements)
  • measurement callback context pointer (custom data pointer, passed back to measurement callback)

The following Open Telemetry metric types are supported:

  • Asynchronous Counter (monotonic, sum aggregation)
  • Asynchronous UpDown Counter (non-monotonic, sum aggregation)
  • Asynchronous Gauge Counter (non-monotonic, non-aggregated)

Metric sources can be registered by:

  • MySQL server (metrics registered on server startup, unregistered on shutdown)
  • plugin or component (metrics registered on install, unregistered on uninstall)

Meter/metric definition arrays must exist for as long as the matching meters/metrics are being registered, the internal code keeps pointers to this registration data.

Measurement callback method accepts a function pointer parameter (delivery callback) and uses it to report one or more measurement values for a given metric (with optional key/value attributes attached to each).

Block Diagram

Following diagram shows the block diagram of PFS services functionality, exposed via mysql-server component. Interface usage here is done from the point of view of an entity that exposes metric sources.

The next diagram shows the functionality used from the point of view of the component that will export the metric measurements, and installs its notification callback to track changes in available metrics.