MySQL 9.7.0
Source Code Documentation
tm_global.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2022, 2026, Oracle and/or its affiliates.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is designed to work with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have either included with
14 the program or referenced in the documentation.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License, version 2.0, for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24*/
25
26#ifndef TELEMETRY_GLOBAL_H_INCLUDED
27#define TELEMETRY_GLOBAL_H_INCLUDED
28
29#include <opentelemetry/metrics/meter.h>
30#include <opentelemetry/metrics/meter_provider.h>
31#include <opentelemetry/nostd/shared_ptr.h>
32#include <opentelemetry/sdk/logs/logger.h>
33#include <opentelemetry/sdk/logs/logger_provider.h>
34#include <opentelemetry/sdk/trace/tracer_provider.h>
35#include <opentelemetry/trace/tracer.h>
36#include <opentelemetry/trace/tracer_provider.h>
37
40
41#include <atomic>
42#include <chrono>
43
44#include "tm_mysql_metric.h"
45
46namespace telemetry {
47
51
55
56extern std::shared_ptr<opentelemetry::sdk::trace::TracerProvider>
58
59extern opentelemetry::nostd::shared_ptr<opentelemetry::trace::Tracer> g_tracer;
60
61extern opentelemetry::nostd::shared_ptr<
62 opentelemetry::sdk::logs::LoggerProvider>
64
65extern opentelemetry::nostd::shared_ptr<opentelemetry::logs::Logger> g_logger;
66
67extern std::atomic_int64_t g_session_count;
68
69extern std::atomic_bool g_shutting_down;
70extern std::atomic_int64_t g_sessions_closed;
71extern std::atomic_int64_t g_run_level;
72
73constexpr int RUN_LEVEL_BOOT = 0;
74constexpr int RUN_LEVEL_INSTALL = 1;
75constexpr int RUN_LEVEL_DETECT_RESOURCE = 2;
76constexpr int RUN_LEVEL_DECODE_SECRET = 3;
77constexpr int RUN_LEVEL_CONFIGURE = 4;
78constexpr int RUN_LEVEL_READY = 5;
79constexpr int RUN_LEVEL_FAILED = 6;
80constexpr int RUN_LEVEL_UNINSTALL = 7;
81
86
91
92// #define SINGLE_METER_PROVIDER
93
94#ifdef SINGLE_METER_PROVIDER
95
96/*
97 Not fully supported in opentelemetry-cpp,
98 when multiple export frequencies are defined.
99
100 See below.
101*/
102
103extern opentelemetry::nostd::shared_ptr<opentelemetry::metrics::MeterProvider>
104 g_meter_provider;
105#else
106
107/*
108 Work around while waiting for this fix:
109
110 Metrics SDK: allow metric readers to filter Meters during Collect()
111
112 https://github.com/open-telemetry/opentelemetry-specification/issues/3617
113*/
114
116#endif
117
118void to_timespec(const std::chrono::time_point<std::chrono::system_clock> &from,
119 struct timespec &to);
120
121} // namespace telemetry
122
123#endif /* TELEMETRY_GLOBAL_H_INCLUDED */
Definition: tm_mysql_metric.h:134
Definition: option_usage.cc:40
constexpr int RUN_LEVEL_DETECT_RESOURCE
Definition: tm_global.h:75
constexpr int RUN_LEVEL_BOOT
Definition: tm_global.h:73
mysql_mutex_t g_install_wait_lock
Definition: tm_global.cc:62
constexpr int RUN_LEVEL_UNINSTALL
Definition: tm_global.h:80
mysql_cond_t g_install_completed_cond
Definition: tm_global.cc:65
opentelemetry::nostd::shared_ptr< opentelemetry::logs::Logger > g_logger
Definition: tm_global.cc:48
MySQLMeterProviders g_all_meter_providers
Definition: tm_global.cc:71
int g_logs_network_namespace
Definition: tm_global.cc:37
constexpr int RUN_LEVEL_FAILED
Definition: tm_global.h:79
std::string sensitive_otel_exporter_otlp_traces_secret_headers
Definition: tm_global.cc:31
mysql_mutex_t g_install_completed_lock
Definition: tm_global.cc:63
mysql_mutex_t g_all_meters_mutex
Definition: tm_global.cc:59
std::atomic_int64_t g_run_level
mysql_cond_t g_session_notify_cond
Definition: tm_global.cc:58
mysql_mutex_t g_session_notify_mutex
Definition: tm_global.cc:57
std::atomic_int64_t g_session_count
mysql_cond_t g_install_wait_cond
Definition: tm_global.cc:64
std::shared_ptr< opentelemetry::sdk::trace::TracerProvider > g_tracer_provider
constexpr int RUN_LEVEL_DECODE_SECRET
Definition: tm_global.h:76
std::atomic_int64_t g_sessions_closed
int g_metrics_network_namespace
Definition: tm_global.cc:36
opentelemetry::nostd::shared_ptr< opentelemetry::sdk::logs::LoggerProvider > g_logger_provider
Definition: tm_global.cc:46
constexpr int RUN_LEVEL_READY
Definition: tm_global.h:78
std::atomic_bool g_shutting_down
constexpr int RUN_LEVEL_INSTALL
Definition: tm_global.h:74
std::string sensitive_otel_exporter_otlp_logs_secret_headers
Definition: tm_global.cc:33
opentelemetry::nostd::shared_ptr< opentelemetry::trace::Tracer > g_tracer
std::string sensitive_otel_exporter_otlp_metrics_secret_headers
Definition: tm_global.cc:32
int g_traces_network_namespace
Definition: tm_global.cc:35
constexpr int RUN_LEVEL_CONFIGURE
Definition: tm_global.h:77
void to_timespec(const std::chrono::time_point< std::chrono::system_clock > &from, struct timespec &to)
Definition: tm_global.cc:74
mysql_mutex_t g_option_usage_mutex
Definition: tm_global.cc:60
An instrumented cond structure.
Definition: mysql_cond_bits.h:50
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:50