forked from open-telemetry/opentelemetry-php-instrumentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopentelemetry.c
87 lines (70 loc) · 2.01 KB
/
opentelemetry.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "ext/standard/info.h"
#include "php_opentelemetry.h"
#include "opentelemetry_arginfo.h"
#include "otel_observer.h"
#include "zend_closures.h"
ZEND_DECLARE_MODULE_GLOBALS(opentelemetry)
PHP_FUNCTION(hook) {
zend_string *class_name;
zend_string *function_name;
zval *pre = NULL;
zval *post = NULL;
ZEND_PARSE_PARAMETERS_START(2, 4)
Z_PARAM_STR_OR_NULL(class_name)
Z_PARAM_STR(function_name)
Z_PARAM_OPTIONAL
Z_PARAM_OBJECT_OF_CLASS_OR_NULL(pre, zend_ce_closure)
Z_PARAM_OBJECT_OF_CLASS_OR_NULL(post, zend_ce_closure)
ZEND_PARSE_PARAMETERS_END();
RETURN_BOOL(add_observer(class_name, function_name, pre, post));
}
PHP_RINIT_FUNCTION(opentelemetry) {
#if defined(ZTS) && defined(COMPILE_DL_OPENTELEMETRY)
ZEND_TSRMLS_CACHE_UPDATE();
#endif
observer_globals_init();
return SUCCESS;
}
PHP_RSHUTDOWN_FUNCTION(opentelemetry) {
observer_globals_cleanup();
return SUCCESS;
}
PHP_MINIT_FUNCTION(opentelemetry) {
opentelemetry_observer_init(INIT_FUNC_ARGS_PASSTHRU);
return SUCCESS;
}
PHP_MINFO_FUNCTION(opentelemetry) {
php_info_print_table_start();
php_info_print_table_header(2, "opentelemetry support", "enabled");
php_info_print_table_row(2, "extension version", PHP_OPENTELEMETRY_VERSION);
php_info_print_table_end();
}
PHP_GINIT_FUNCTION(opentelemetry) {
ZEND_SECURE_ZERO(opentelemetry_globals, sizeof(*opentelemetry_globals));
}
zend_module_entry opentelemetry_module_entry = {
STANDARD_MODULE_HEADER,
"opentelemetry",
ext_functions,
PHP_MINIT(opentelemetry),
NULL,
PHP_RINIT(opentelemetry),
PHP_RSHUTDOWN(opentelemetry),
PHP_MINFO(opentelemetry),
PHP_OPENTELEMETRY_VERSION,
PHP_MODULE_GLOBALS(opentelemetry),
PHP_GINIT(opentelemetry),
NULL,
NULL,
STANDARD_MODULE_PROPERTIES_EX,
};
#ifdef COMPILE_DL_OPENTELEMETRY
#ifdef ZTS
ZEND_TSRMLS_CACHE_DEFINE()
#endif
ZEND_GET_MODULE(opentelemetry)
#endif