MySQL 26.10.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_run_level;
71
72constexpr int RUN_LEVEL_BOOT = 0;
73constexpr int RUN_LEVEL_INSTALL = 1;
74constexpr int RUN_LEVEL_DETECT_RESOURCE = 2;
75constexpr int RUN_LEVEL_DECODE_SECRET = 3;
76constexpr int RUN_LEVEL_CONFIGURE = 4;
77constexpr int RUN_LEVEL_READY = 5;
78constexpr int RUN_LEVEL_FAILED = 6;
79constexpr int RUN_LEVEL_UNINSTALL = 7;
80
83
88
89// #define SINGLE_METER_PROVIDER
90
91#ifdef SINGLE_METER_PROVIDER
92
93/*
94 Not fully supported in opentelemetry-cpp,
95 when multiple export frequencies are defined.
96
97 See below.
98*/
99
100extern opentelemetry::nostd::shared_ptr<opentelemetry::metrics::MeterProvider>
101 g_meter_provider;
102#else
103
104/*
105 Work around while waiting for this fix:
106
107 Metrics SDK: allow metric readers to filter Meters during Collect()
108
109 https://github.com/open-telemetry/opentelemetry-specification/issues/3617
110*/
111
113#endif
114
115} // namespace telemetry
116
117#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:74
constexpr int RUN_LEVEL_BOOT
Definition: tm_global.h:72
mysql_mutex_t g_install_wait_lock
Definition: tm_global.cc:59
constexpr int RUN_LEVEL_UNINSTALL
Definition: tm_global.h:79
mysql_cond_t g_install_completed_cond
Definition: tm_global.cc:62
opentelemetry::nostd::shared_ptr< opentelemetry::logs::Logger > g_logger
Definition: tm_global.cc:48
MySQLMeterProviders g_all_meter_providers
Definition: tm_global.cc:68
int g_logs_network_namespace
Definition: tm_global.cc:37
constexpr int RUN_LEVEL_FAILED
Definition: tm_global.h:78
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:60
mysql_mutex_t g_all_meters_mutex
Definition: tm_global.cc:56
std::atomic_int64_t g_run_level
std::atomic_int64_t g_session_count
mysql_cond_t g_install_wait_cond
Definition: tm_global.cc:61
std::shared_ptr< opentelemetry::sdk::trace::TracerProvider > g_tracer_provider
constexpr int RUN_LEVEL_DECODE_SECRET
Definition: tm_global.h:75
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:77
std::atomic_bool g_shutting_down
constexpr int RUN_LEVEL_INSTALL
Definition: tm_global.h:73
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:76
mysql_mutex_t g_option_usage_mutex
Definition: tm_global.cc:57
An instrumented cond structure.
Definition: mysql_cond_bits.h:50
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:50