MySQL 9.1.0
Source Code Documentation
server_telemetry_logs_client_bits.h
Go to the documentation of this file.
1/* Copyright (c) 2024, Oracle and/or its affiliates.
2
3This program is free software; you can redistribute it and/or modify
4it under the terms of the GNU General Public License, version 2.0,
5as published by the Free Software Foundation.
6
7This program is designed to work with certain software (including
8but not limited to OpenSSL) that is licensed under separate terms,
9as designated in a particular file or component or in included license
10documentation. The authors of MySQL hereby grant you an additional
11permission to link the program and your derivative works with the
12separately licensed software that they have either included with
13the program or referenced in the documentation.
14
15This program is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18GNU General Public License, version 2.0, for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef SERVER_TELEMETRY_LOGS_CLIENTS_BITS_H
25#define SERVER_TELEMETRY_LOGS_CLIENTS_BITS_H
26
27#include <time.h> // time_t
28#include <cstddef> // size_t
29#include <cstdint> // uint64_t
30
32
33/** Opaque. */
34struct PSI_logger;
35
36/**
37 Log levels as supported by opentelemetry-cpp (+ "none"), see:
38 api/include/opentelemetry/logs/severity.h
39 Some OTEL documentation pages also mention "fatal" level,
40 but there is no support for it in the opentelemetry-cpp yet.
41 Note that enum integer values may not match those of OTEL.
42*/
44
45typedef unsigned int PSI_logger_key;
46
47constexpr size_t MAX_LOGGER_NAME_LEN = 63;
48constexpr size_t MAX_LOG_ATTRIBUTES = 64;
49
50/**
51 Defines a logger from the side of instrumented code (log API client).
52 Logger must be registered under a unique name before use,
53 then you can use it to create and emit log records
54 (i.e. instrument your code to generate OTEL logs).
55 Logger can be enabled/disabled via P_S.setup_loggers table.
56*/
58 const char *m_logger_name;
59 const char *m_description;
60 /** Instrument flags. */
61 unsigned int m_flags;
63};
64
65/**
66 Register telemetry logger client.
67
68 @param info array of logger definitions
69 @param count number of loggers in an array
70 @param category common category name for set of loggers
71*/
73 size_t count,
74 const char *category);
75
76/**
77 Unregister telemetry logger client.
78
79 @param info array of logger definitions
80 @param count array size
81*/
83 PSI_logger_info_v1 *info, size_t count);
84
85/**
86 Check if the logger/log_level combination is currently enabled.
87
88 @param key registered logger key
89 @param level log level to be checked
90 @retval logger pointer, NULL on failure
91*/
92typedef PSI_logger *(*check_enabled_telemetry_logger_client_v1_t)(
94
95/**
96 Emit telemetry log record.
97
98 @param logger logger object
99 @param level log level
100 @param message message string to be logged
101 @param timestamp log timestamp
102 @param attr_array list of log record attributes (NULL for no attributes)
103 @param attr_count size of attributes array (0 for no attributes)
104*/
106 PSI_logger *logger, OTELLogLevel level, const char *message,
107 time_t timestamp, const log_attribute_t *attr_array, size_t attr_count);
108
109/**
110 @def PSI_LOGGER_CLIENT_VERSION_1
111 Performance Schema Logger Client Interface number for version 1.
112 This version is supported.
113*/
114#define PSI_LOGGER_CLIENT_VERSION_1 1
115
116/**
117 @def PSI_CURRENT_LOGGER_CLIENT_VERSION
118 Performance Schema Logger Client Interface number for the most recent version.
119 The most current version is @c PSI_METRIC_VERSION_1
120*/
121#define PSI_CURRENT_LOGGER_CLIENT_VERSION 1
122
123#endif /* SERVER_TELEMETRY_LOGS_BITS_H */
static int count
Definition: myisam_ftdump.cc:45
constexpr value_type timestamp
Definition: classic_protocol_constants.h:278
static const char * category
Definition: sha2_password.cc:170
static Logger logger
The "top-level" logger used when no connection context is given.
Definition: test_trace_plugin.cc:296
required string key
Definition: replication_asynchronous_connection_failover.proto:60
constexpr size_t MAX_LOG_ATTRIBUTES
Definition: server_telemetry_logs_client_bits.h:48
OTELLogLevel
Log levels as supported by opentelemetry-cpp (+ "none"), see: api/include/opentelemetry/logs/severity...
Definition: server_telemetry_logs_client_bits.h:43
@ TLOG_NONE
Definition: server_telemetry_logs_client_bits.h:43
@ TLOG_DEBUG
Definition: server_telemetry_logs_client_bits.h:43
@ TLOG_WARN
Definition: server_telemetry_logs_client_bits.h:43
@ TLOG_ERROR
Definition: server_telemetry_logs_client_bits.h:43
@ TLOG_INFO
Definition: server_telemetry_logs_client_bits.h:43
constexpr size_t MAX_LOGGER_NAME_LEN
Definition: server_telemetry_logs_client_bits.h:47
void(* unregister_telemetry_logger_client_v1_t)(PSI_logger_info_v1 *info, size_t count)
Unregister telemetry logger client.
Definition: server_telemetry_logs_client_bits.h:82
void(* register_telemetry_logger_client_v1_t)(PSI_logger_info_v1 *info, size_t count, const char *category)
Register telemetry logger client.
Definition: server_telemetry_logs_client_bits.h:72
unsigned int PSI_logger_key
Definition: server_telemetry_logs_client_bits.h:45
void(* log_emit_telemetry_logger_client_v1_t)(PSI_logger *logger, OTELLogLevel level, const char *message, time_t timestamp, const log_attribute_t *attr_array, size_t attr_count)
Emit telemetry log record.
Definition: server_telemetry_logs_client_bits.h:105
Defines a logger from the side of instrumented code (log API client).
Definition: server_telemetry_logs_client_bits.h:57
PSI_logger_key * m_key
Definition: server_telemetry_logs_client_bits.h:62
const char * m_logger_name
Definition: server_telemetry_logs_client_bits.h:58
unsigned int m_flags
Instrument flags.
Definition: server_telemetry_logs_client_bits.h:61
const char * m_description
Definition: server_telemetry_logs_client_bits.h:59
Definition: server_telemetry_attribute_bits.h:57
Include file for Sun RPC to compile out of the box.