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