MySQL 8.4.2
Source Code Documentation
server_telemetry_traces_bits.h
Go to the documentation of this file.
1/* Copyright (c) 2022, 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_TRACES_BITS_H
25#define SERVER_TELEMETRY_TRACES_BITS_H
26
27#include <cstddef> // size_t
28#include <cstdint> // uint64_t
29
30/** Telemetry tracing scope (span types) flags */
31#define TRACE_STATEMENTS 0x0001
32
33/*
34 Telemetry tracing scope flags are used as both in and out values
35 for the "flags" parameter in m_tel_stmt_start, m_tel_stmt_notify_qa callbacks.
36 Input can be either TRACE_STATEMENTS or 0, depending if the PS instruments
37 required for telemetry were already enabled in PS configuration or not.
38 Output can be either TRACE_STATEMENTS or 0, depending if the telemetry
39 component wants to trace this statement or not. Input value can be used by the
40 component to decide if it wants to force tracing of the statement, regardless
41 of the PS configuration of the required instruments.
42*/
43
44/** Telemetry tracing scope (span types) masks */
45#define TRACE_NOTHING 0x0000
46#define TRACE_EVERYTHING 0xFFFF
47
48/** Opaque. */
49struct telemetry_session_t;
50
51/** Opaque. */
52struct telemetry_locker_t;
53
54typedef telemetry_session_t *(*tel_session_create_v1_t)();
55
56typedef void (*tel_session_destroy_v1_t)(telemetry_session_t *session);
57
58typedef telemetry_locker_t *(*tel_stmt_start_v1_t)(telemetry_session_t *session,
59 uint64_t *flags);
60typedef telemetry_locker_t *(*tel_stmt_notify_qa_v1_t)(
61 telemetry_locker_t *locker, bool with_query_attributes, uint64_t *flags);
62
64 /** Performance schema event name. */
65 const char *m_event_name;
66 /** Locked time. */
67 unsigned long long m_lock_time;
68 /** SQL text. */
69 const char *m_sql_text;
71 /** DIGEST text. */
72 const char *m_digest_text;
73 /** Current schema. */
74 const char *m_current_schema;
76 /** Object type. */
77 const char *m_object_type;
79 /** Object schema. */
80 const char *m_object_schema;
82 /** Object name. */
83 const char *m_object_name;
85 /** MYSQL_ERRNO. */
87 /** SQLSTATE. */
88 const char *m_sqlstate;
89 /** Error message text. */
90 const char *m_message_text;
91 /** Number or errors. */
92 unsigned long m_error_count;
93 /** Number of warnings. */
94 unsigned long m_warning_count;
95 /** Rows affected. */
96 unsigned long long m_rows_affected;
97 /** Rows sent. */
98 unsigned long long m_rows_sent;
99 /** Rows examined. */
100 unsigned long long m_rows_examined;
101 /** Metric, temporary tables created on disk. */
103 /** Metric, temporary tables created. */
104 unsigned long m_created_tmp_tables;
105 /** Metric, number of select full join. */
106 unsigned long m_select_full_join;
107 /** Metric, number of select full range join. */
109 /** Metric, number of select range. */
110 unsigned long m_select_range;
111 /** Metric, number of select range check. */
112 unsigned long m_select_range_check;
113 /** Metric, number of select scan. */
114 unsigned long m_select_scan;
115 /** Metric, number of sort merge passes. */
116 unsigned long m_sort_merge_passes;
117 /** Metric, number of sort merge. */
118 unsigned long m_sort_range;
119 /** Metric, number of sort rows. */
120 unsigned long m_sort_rows;
121 /** Metric, number of sort scans. */
122 unsigned long m_sort_scan;
123 /** Metric, no index used flag. */
124 unsigned char m_no_index_used;
125 /** Metric, no good index used flag. */
126 unsigned char m_no_good_index_used;
130};
131
132typedef void (*tel_stmt_abort_v1_t)(telemetry_locker_t *locker);
133
134typedef void (*tel_stmt_end_v1_t)(telemetry_locker_t *locker,
135 telemetry_stmt_data_v1_t *stmt_data);
136
144};
145
146class THD;
147
148/**
149 Register set of telemetry notification callbacks.
150
151 @param telemetry pointer to struct of functions to be registered.
152 @retval FALSE: success
153 @retval TRUE: failure
154*/
155typedef bool (*register_telemetry_v1_t)(telemetry_v1_t *telemetry);
156
157/**
158 Abort the current statement and session.
159 @param thd session pointer.
160*/
161typedef void (*abort_telemetry_v1_t)(THD *thd);
162
163/**
164 Unregister set of telemetry notification callbacks.
165
166 @param telemetry pointer to struct of functions to be unregistered.
167 @retval FALSE: success
168 @retval TRUE: failure
169*/
170typedef bool (*unregister_telemetry_v1_t)(telemetry_v1_t *telemetry);
171
174
175#endif /* SERVER_TELEMETRY_TRACES_BITS_H */
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
static int flags[50]
Definition: hp_test1.cc:40
telemetry_v1_t telemetry_t
Definition: server_telemetry_traces_bits.h:173
telemetry_stmt_data_v1_t telemetry_stmt_data_t
Definition: server_telemetry_traces_bits.h:172
void(* abort_telemetry_v1_t)(THD *thd)
Abort the current statement and session.
Definition: server_telemetry_traces_bits.h:161
bool(* register_telemetry_v1_t)(telemetry_v1_t *telemetry)
Register set of telemetry notification callbacks.
Definition: server_telemetry_traces_bits.h:155
void(* tel_stmt_end_v1_t)(telemetry_locker_t *locker, telemetry_stmt_data_v1_t *stmt_data)
Definition: server_telemetry_traces_bits.h:134
telemetry_locker_t *(* tel_stmt_start_v1_t)(telemetry_session_t *session, uint64_t *flags)
Definition: server_telemetry_traces_bits.h:58
void(* tel_stmt_abort_v1_t)(telemetry_locker_t *locker)
Definition: server_telemetry_traces_bits.h:132
bool(* unregister_telemetry_v1_t)(telemetry_v1_t *telemetry)
Unregister set of telemetry notification callbacks.
Definition: server_telemetry_traces_bits.h:170
void(* tel_session_destroy_v1_t)(telemetry_session_t *session)
Definition: server_telemetry_traces_bits.h:56
telemetry_locker_t *(* tel_stmt_notify_qa_v1_t)(telemetry_locker_t *locker, bool with_query_attributes, uint64_t *flags)
Definition: server_telemetry_traces_bits.h:60
telemetry_session_t *(* tel_session_create_v1_t)()
Definition: server_telemetry_traces_bits.h:54
Definition: server_telemetry_traces_bits.h:63
const char * m_message_text
Error message text.
Definition: server_telemetry_traces_bits.h:90
unsigned long m_sort_rows
Metric, number of sort rows.
Definition: server_telemetry_traces_bits.h:120
const char * m_object_type
Object type.
Definition: server_telemetry_traces_bits.h:77
unsigned long m_select_range
Metric, number of select range.
Definition: server_telemetry_traces_bits.h:110
size_t m_object_type_length
Definition: server_telemetry_traces_bits.h:78
unsigned long long m_rows_affected
Rows affected.
Definition: server_telemetry_traces_bits.h:96
unsigned long m_created_tmp_disk_tables
Metric, temporary tables created on disk.
Definition: server_telemetry_traces_bits.h:102
const char * m_event_name
Performance schema event name.
Definition: server_telemetry_traces_bits.h:65
size_t m_object_schema_length
Definition: server_telemetry_traces_bits.h:81
const char * m_object_name
Object name.
Definition: server_telemetry_traces_bits.h:83
unsigned long m_select_scan
Metric, number of select scan.
Definition: server_telemetry_traces_bits.h:114
const char * m_sql_text
SQL text.
Definition: server_telemetry_traces_bits.h:69
int m_sql_errno
MYSQL_ERRNO.
Definition: server_telemetry_traces_bits.h:86
size_t m_cpu_time
Definition: server_telemetry_traces_bits.h:129
size_t m_max_controlled_memory
Definition: server_telemetry_traces_bits.h:127
const char * m_sqlstate
SQLSTATE.
Definition: server_telemetry_traces_bits.h:88
unsigned long m_sort_scan
Metric, number of sort scans.
Definition: server_telemetry_traces_bits.h:122
unsigned long m_error_count
Number or errors.
Definition: server_telemetry_traces_bits.h:92
unsigned long m_select_range_check
Metric, number of select range check.
Definition: server_telemetry_traces_bits.h:112
unsigned char m_no_good_index_used
Metric, no good index used flag.
Definition: server_telemetry_traces_bits.h:126
size_t m_max_total_memory
Definition: server_telemetry_traces_bits.h:128
size_t m_current_schema_length
Definition: server_telemetry_traces_bits.h:75
const char * m_object_schema
Object schema.
Definition: server_telemetry_traces_bits.h:80
unsigned long m_created_tmp_tables
Metric, temporary tables created.
Definition: server_telemetry_traces_bits.h:104
unsigned long long m_rows_sent
Rows sent.
Definition: server_telemetry_traces_bits.h:98
unsigned long m_sort_range
Metric, number of sort merge.
Definition: server_telemetry_traces_bits.h:118
size_t m_object_name_length
Definition: server_telemetry_traces_bits.h:84
const char * m_digest_text
DIGEST text.
Definition: server_telemetry_traces_bits.h:72
unsigned long m_select_full_range_join
Metric, number of select full range join.
Definition: server_telemetry_traces_bits.h:108
unsigned long m_select_full_join
Metric, number of select full join.
Definition: server_telemetry_traces_bits.h:106
size_t m_sql_text_length
Definition: server_telemetry_traces_bits.h:70
unsigned long long m_rows_examined
Rows examined.
Definition: server_telemetry_traces_bits.h:100
const char * m_current_schema
Current schema.
Definition: server_telemetry_traces_bits.h:74
unsigned long m_sort_merge_passes
Metric, number of sort merge passes.
Definition: server_telemetry_traces_bits.h:116
unsigned long m_warning_count
Number of warnings.
Definition: server_telemetry_traces_bits.h:94
unsigned long long m_lock_time
Locked time.
Definition: server_telemetry_traces_bits.h:67
unsigned char m_no_index_used
Metric, no index used flag.
Definition: server_telemetry_traces_bits.h:124
Definition: server_telemetry_traces_bits.h:137
tel_stmt_end_v1_t m_tel_stmt_end
Definition: server_telemetry_traces_bits.h:143
tel_session_destroy_v1_t m_tel_session_destroy
Definition: server_telemetry_traces_bits.h:139
tel_stmt_start_v1_t m_tel_stmt_start
Definition: server_telemetry_traces_bits.h:140
tel_session_create_v1_t m_tel_session_create
Definition: server_telemetry_traces_bits.h:138
tel_stmt_notify_qa_v1_t m_tel_stmt_notify_qa
Definition: server_telemetry_traces_bits.h:141
tel_stmt_abort_v1_t m_tel_stmt_abort
Definition: server_telemetry_traces_bits.h:142