MySQL 9.1.0
Source Code Documentation
server_logs_component.cc File Reference
#include "server_logs_component.h"
#include <mysql/psi/mysql_telemetry_logs_client.h>
#include <chrono>
#include <map>
#include "mysqld_error.h"
#include "server_logs_helpers.h"

Functions

 REQUIRES_SERVICE_PLACEHOLDER (log_builtins)
 
 REQUIRES_SERVICE_PLACEHOLDER (log_builtins_string)
 
 REQUIRES_SERVICE_PLACEHOLDER_AS (udf_registration, udf_registration_srv)
 
 REQUIRES_SERVICE_PLACEHOLDER (mysql_server_telemetry_logs_client)
 
static int register_loggers ()
 
static void unregister_loggers ()
 
static bool log_service_init ()
 logger services initialization method for Component used when loading the Component. More...
 
static bool log_service_deinit ()
 logger services de-initialization method for Component used when unloading the Component. More...
 
static long long test_emit_log (UDF_INIT *init, UDF_ARGS *args, unsigned char *null_value, unsigned char *error)
 Implements test_emit_log UDF. More...
 
static long long test_emit_log_with_attributes (UDF_INIT *init, UDF_ARGS *args, unsigned char *null_value, unsigned char *error)
 Implements test_emit_log_with_attributes UDF. More...
 
static long long test_log_registration (UDF_INIT *init, UDF_ARGS *args, unsigned char *null_value, unsigned char *error)
 Register/unregister loggers multiple times leaving "holes" in array of logger instruments, so we can test if performance_schema.setup_loggers table correctly handles such case. More...
 
static long long test_log_wrappers (UDF_INIT *init, UDF_ARGS *args, unsigned char *null_value, unsigned char *error)
 Test C++ wrappers around telemetry logging API. More...
 
static long long test_invalid_operations (UDF_INIT *init, UDF_ARGS *args, unsigned char *null_value, unsigned char *error)
 Test error handling by triggering some invalid API calls. More...
 
static long long test_error_log (UDF_INIT *init, UDF_ARGS *args, unsigned char *null_value, unsigned char *error)
 Test that MySQL error log entries are also emitted as telemetry logs. More...
 
static void unregister_udf ()
 
static bool register_udf ()
 
mysql_service_status_t test_server_telemetry_logs_component_init ()
 Initialize the test_server_telemetry_logs component at server start or component installation: More...
 
mysql_service_status_t test_server_telemetry_logs_component_deinit ()
 Terminate the test_server_telemetry_logs_component at server shutdown or component deinstallation: More...
 
 END_COMPONENT_PROVIDES ()
 
 REQUIRES_SERVICE (log_builtins)
 
 REQUIRES_SERVICE (log_builtins_string)
 
 REQUIRES_SERVICE (mysql_server_telemetry_logs_client)
 
 REQUIRES_SERVICE_AS (udf_registration, udf_registration_srv)
 
 END_COMPONENT_REQUIRES ()
 
 METADATA ("mysql.author", "Oracle Corporation")
 
 METADATA ("mysql.license", "GPL")
 
 METADATA ("test_property", "1")
 
 END_COMPONENT_METADATA ()
 

Variables

static FileLogger g_log ("test_server_telemetry_logs_component.log")
 
PSI_logger_key test1_logger_key = 0
 
PSI_logger_key test2_logger_key = 0
 
PSI_logger_key test3_logger_key = 0
 
PSI_logger_key test4_logger_key = 0
 
PSI_logger_info_v1 g_loggers []
 
PSI_logger_info_v1 g_loggers1 []
 
const mysql_service_log_builtins_tlog_bi
 accessor built-ins More...
 
const mysql_service_log_builtins_string_tlog_bs
 string built-ins More...
 
mysql_component_t mysql_component_test_server_telemetry_logs_client
 

Function Documentation

◆ END_COMPONENT_METADATA()

END_COMPONENT_METADATA ( )

◆ END_COMPONENT_PROVIDES()

END_COMPONENT_PROVIDES ( )

◆ END_COMPONENT_REQUIRES()

END_COMPONENT_REQUIRES ( )

◆ log_service_deinit()

static bool log_service_deinit ( )
static

logger services de-initialization method for Component used when unloading the Component.

Returns
Status of performed operation
Return values
falsesuccess
truefailure

◆ log_service_init()

static bool log_service_init ( )
static

logger services initialization method for Component used when loading the Component.

Returns
Status of performed operation
Return values
falsesuccess
truefailure

◆ METADATA() [1/3]

METADATA ( "mysql.author"  ,
"Oracle Corporation"   
)

◆ METADATA() [2/3]

METADATA ( "mysql.license"  ,
"GPL"   
)

◆ METADATA() [3/3]

METADATA ( "test_property"  ,
"1"   
)

◆ register_loggers()

static int register_loggers ( )
static

◆ register_udf()

static bool register_udf ( )
static

◆ REQUIRES_SERVICE() [1/3]

REQUIRES_SERVICE ( log_builtins  )

◆ REQUIRES_SERVICE() [2/3]

REQUIRES_SERVICE ( log_builtins_string  )

◆ REQUIRES_SERVICE() [3/3]

REQUIRES_SERVICE ( mysql_server_telemetry_logs_client  )

◆ REQUIRES_SERVICE_AS()

REQUIRES_SERVICE_AS ( udf_registration  ,
udf_registration_srv   
)

◆ REQUIRES_SERVICE_PLACEHOLDER() [1/3]

REQUIRES_SERVICE_PLACEHOLDER ( log_builtins  )

◆ REQUIRES_SERVICE_PLACEHOLDER() [2/3]

REQUIRES_SERVICE_PLACEHOLDER ( log_builtins_string  )

◆ REQUIRES_SERVICE_PLACEHOLDER() [3/3]

REQUIRES_SERVICE_PLACEHOLDER ( mysql_server_telemetry_logs_client  )

◆ REQUIRES_SERVICE_PLACEHOLDER_AS()

REQUIRES_SERVICE_PLACEHOLDER_AS ( udf_registration  ,
udf_registration_srv   
)

◆ test_emit_log()

static long long test_emit_log ( UDF_INIT init,
UDF_ARGS args,
unsigned char *  null_value,
unsigned char *  error 
)
static

Implements test_emit_log UDF.

This function generates and emits a single test log record.

Parameters
initUnused.
argsUnused.
null_valueUnused.
errorUnused.
Return values
0This function always returns 0.

◆ test_emit_log_with_attributes()

static long long test_emit_log_with_attributes ( UDF_INIT init,
UDF_ARGS args,
unsigned char *  null_value,
unsigned char *  error 
)
static

Implements test_emit_log_with_attributes UDF.

This function generates and emits a single test log record with some test attributes.

Parameters
initUnused.
argsUnused.
null_valueUnused.
errorUnused.
Return values
0This function always returns 0.

◆ test_error_log()

static long long test_error_log ( UDF_INIT init,
UDF_ARGS args,
unsigned char *  null_value,
unsigned char *  error 
)
static

Test that MySQL error log entries are also emitted as telemetry logs.

Parameters
initUnused.
argsUnused.
null_valueUnused.
errorUnused.
Return values
0This function always returns 0.

◆ test_invalid_operations()

static long long test_invalid_operations ( UDF_INIT init,
UDF_ARGS args,
unsigned char *  null_value,
unsigned char *  error 
)
static

Test error handling by triggering some invalid API calls.

The call of this function also increases code coverage.

Parameters
initUnused.
argsUnused.
null_valueUnused.
errorUnused.
Return values
0This function always returns 0.

◆ test_log_registration()

static long long test_log_registration ( UDF_INIT init,
UDF_ARGS args,
unsigned char *  null_value,
unsigned char *  error 
)
static

Register/unregister loggers multiple times leaving "holes" in array of logger instruments, so we can test if performance_schema.setup_loggers table correctly handles such case.

Parameters
initUnused.
argsUnused.
null_valueUnused.
errorUnused.
Return values
0This function always returns 0.

◆ test_log_wrappers()

static long long test_log_wrappers ( UDF_INIT init,
UDF_ARGS args,
unsigned char *  null_value,
unsigned char *  error 
)
static

Test C++ wrappers around telemetry logging API.

Parameters
initUnused.
argsUnused.
null_valueUnused.
errorUnused.
Return values
0This function always returns 0.

◆ test_server_telemetry_logs_component_deinit()

mysql_service_status_t test_server_telemetry_logs_component_deinit ( )

Terminate the test_server_telemetry_logs_component at server shutdown or component deinstallation:

  • Unregister telemetry logs loggers
  • Unregister UDFs
  • Deinitialize log service
Return values
0success
non-zerofailure

◆ test_server_telemetry_logs_component_init()

mysql_service_status_t test_server_telemetry_logs_component_init ( )

Initialize the test_server_telemetry_logs component at server start or component installation:

  • Initialize log service
  • Register telemetry logs loggers
  • Register UDFs
Return values
0success
non-zerofailure

◆ unregister_loggers()

static void unregister_loggers ( )
static

◆ unregister_udf()

static void unregister_udf ( )
static

Variable Documentation

◆ g_log

FileLogger g_log("test_server_telemetry_logs_component.log") ( "test_server_telemetry_logs_component.log"  )
static

◆ g_loggers

PSI_logger_info_v1 g_loggers[]
Initial value:
= {
{"test1", "Test logger #1", 0, &test1_logger_key},
{"test2", "Test logger #2", 0, &test2_logger_key}}
PSI_logger_key test1_logger_key
Definition: server_logs_component.cc:52
PSI_logger_key test2_logger_key
Definition: server_logs_component.cc:53

◆ g_loggers1

PSI_logger_info_v1 g_loggers1[]
Initial value:
= {
{"test3", "Test logger #3", 0, &test3_logger_key},
{"test4", "Test logger #4", 0, &test4_logger_key}}
PSI_logger_key test4_logger_key
Definition: server_logs_component.cc:55
PSI_logger_key test3_logger_key
Definition: server_logs_component.cc:54

◆ log_bi

accessor built-ins

accessor built-ins

◆ log_bs

string built-ins

◆ mysql_component_test_server_telemetry_logs_client

mysql_component_t mysql_component_test_server_telemetry_logs_client
Initial value:
= { "mysql:test_server_telemetry_logs_client" , __test_server_telemetry_logs_client_provides, __test_server_telemetry_logs_client_requires, __test_server_telemetry_logs_client_metadata,
mysql_service_status_t test_server_telemetry_logs_component_deinit()
Terminate the test_server_telemetry_logs_component at server shutdown or component deinstallation:
Definition: server_logs_component.cc:483
mysql_service_status_t test_server_telemetry_logs_component_init()
Initialize the test_server_telemetry_logs component at server start or component installation:
Definition: server_logs_component.cc:444

◆ test1_logger_key

PSI_logger_key test1_logger_key = 0

◆ test2_logger_key

PSI_logger_key test2_logger_key = 0

◆ test3_logger_key

PSI_logger_key test3_logger_key = 0

◆ test4_logger_key

PSI_logger_key test4_logger_key = 0