MySQL 9.1.0
Source Code Documentation
mysql_metric.h
Go to the documentation of this file.
1/* Copyright (c) 2023, 2024, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef MYSQL_METRIC_H
25#define MYSQL_METRIC_H
26
27/**
28 @file include/mysql/psi/mysql_metric.h
29 Instrumentation helpers for metrics.
30*/
31
32#include "my_compiler.h"
33
34/* HAVE_PSI_*_INTERFACE */
35#include "my_psi_config.h" // IWYU pragma: keep
36
38
39#include "my_inttypes.h"
40
41#if defined(MYSQL_SERVER) || defined(PFS_DIRECT_CALL)
42/* PSI_METRIC_CALL() as direct call. */
43#include "pfs_metric_provider.h" // IWYU pragma: keep
44#endif
45
46#ifndef PSI_METRIC_CALL
47#define PSI_METRIC_CALL(M) psi_metric_service->M
48#endif
49
50/**
51 @defgroup psi_api_metric Metric Instrumentation (API)
52 @ingroup psi_api
53 @{
54*/
55
56/**
57 @def mysql_meter_register(P1, P2)
58 Registration of meters, each with its metrics.
59*/
60#define mysql_meter_register(P1, P2) inline_mysql_meter_register(P1, P2)
61
63 [[maybe_unused]],
64 size_t count [[maybe_unused]]) {
65#ifdef HAVE_PSI_METRICS_INTERFACE
66 PSI_METRIC_CALL(register_meters)(info, count);
67#endif /* HAVE_PSI_METRICS_INTERFACE */
68}
69
70/**
71 @def mysql_meter_unregister(P1, P2)
72 Meter unregistration.
73*/
74#define mysql_meter_unregister(P1, P2) inline_mysql_meter_unregister(P1, P2)
75
77 [[maybe_unused]],
78 size_t count
79 [[maybe_unused]]) {
80#ifdef HAVE_PSI_METRICS_INTERFACE
81 PSI_METRIC_CALL(unregister_meters)(info, count);
82#endif /* HAVE_PSI_METRICS_INTERFACE */
83}
84
85/**
86 @def mysql_meter_notify_register(P1)
87 Registration of meter change notification callback.
88*/
89#define mysql_meter_notify_register(P1) inline_mysql_meter_notify_register(P1)
90
92 meter_registration_changes_v1_t callback [[maybe_unused]]) {
93#ifdef HAVE_PSI_METRICS_INTERFACE
94 PSI_METRIC_CALL(register_change_notification)(callback);
95#endif /* HAVE_PSI_METRICS_INTERFACE */
96}
97
98/**
99 @def mysql_meter_notify_unregister(P1)
100 Unregistration of meter change notification callback.
101*/
102#define mysql_meter_notify_unregister(P1) \
103 inline_mysql_meter_notify_unregister(P1)
104
106 meter_registration_changes_v1_t callback [[maybe_unused]]) {
107#ifdef HAVE_PSI_METRICS_INTERFACE
108 PSI_METRIC_CALL(unregister_change_notification)(callback);
109#endif /* HAVE_PSI_METRICS_INTERFACE */
110}
111
112/**
113 @def mysql_meter_notify_send(P1, P2)
114 Send meter change notification through registered callback.
115*/
116#define mysql_meter_notify_send(P1, P2) inline_mysql_meter_notify_send(P1, P2)
117
118static inline void inline_mysql_meter_notify_send(const char *meter
119 [[maybe_unused]],
120 MeterNotifyType change
121 [[maybe_unused]]) {
122#ifdef HAVE_PSI_METRICS_INTERFACE
123 PSI_METRIC_CALL(send_change_notification)(meter, change);
124#endif /* HAVE_PSI_METRICS_INTERFACE */
125}
126
127/** @} (end of group psi_api_metric) */
128
129#endif
#define PSI_METRIC_CALL(M)
Definition: psi_metric.h:36
static void inline_mysql_meter_notify_send(const char *meter, MeterNotifyType change)
Definition: mysql_metric.h:118
static void inline_mysql_meter_unregister(PSI_meter_info_v1 *info, size_t count)
Definition: mysql_metric.h:76
static void inline_mysql_meter_notify_unregister(meter_registration_changes_v1_t callback)
Definition: mysql_metric.h:105
static void inline_mysql_meter_notify_register(meter_registration_changes_v1_t callback)
Definition: mysql_metric.h:91
static void inline_mysql_meter_register(PSI_meter_info_v1 *info, size_t count)
Definition: mysql_metric.h:62
Header for compiler-dependent features.
Some integer typedefs for easier portability.
Defines various enable/disable and HAVE_ macros related to the performance schema instrumentation sys...
static int count
Definition: myisam_ftdump.cc:45
static PSI_meter_info_v1 meter[]
Definition: plugin.cc:96
Performance schema instrumentation (declarations).
Performance schema instrumentation interface.
MeterNotifyType
Definition: psi_metric_bits.h:40
void(* meter_registration_changes_v1_t)(const char *meter, MeterNotifyType change)
Callback function to notify of changes within the set of registered meters.
Definition: psi_metric_bits.h:178
Define a meter source, storing char pointers requires the original strings to be valid for entire lif...
Definition: psi_metric_bits.h:143