Skip to content

Commit 9977933

Browse files
committed
fix(crasht): metadata correctness
1 parent 616c6cb commit 9977933

2 files changed

Lines changed: 14 additions & 22 deletions

File tree

ext/signals.c

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,24 @@ const ddog_CharSlice PHP_OPCACHE_ENABLE = DDOG_CHARSLICE_C("php.opcache.enable")
183183
// Fetches certain opcache tags and adds them with the pattern of php.opcache.*.
184184
static void dd_crasht_add_opcache_inis(ddog_Vec_Tag *tags) {
185185
#if PHP_VERSION_ID >= 80000
186-
// We'll push php.opcache.enabled:0 whenever we detect we're disabled.
187-
188186
bool loaded = zend_get_extension("Zend OPcache");
189187
if (UNEXPECTED(!loaded)) {
190188
goto opcache_disabled;
191189
}
192190

191+
// The CLI SAPI has an additional configuration for being enabled. This is
192+
// INI_SYSTEM so we can check it here.
193+
bool is_cli_sapi = strcmp("cli", sapi_module.name) == 0;
194+
if (is_cli_sapi) {
195+
ddog_CharSlice tag = DDOG_CHARSLICE_C("php.opcache.enable_cli");
196+
zend_string *value = dd_crasht_find_ini_by_tag(tag);
197+
if (EXPECTED(value)) {
198+
bool is_enabled = zend_ini_parse_bool(value);
199+
ddog_CharSlice val = is_enabled ? ONE : ZERO;
200+
dd_crasht_push_tag(tags, tag, val);
201+
}
202+
}
203+
193204
// opcache.jit_buffer_size is INI_SYSTEM, so we can check it now. If it's
194205
// zero, then JIT won't operate.
195206
{
@@ -209,25 +220,6 @@ static void dd_crasht_add_opcache_inis(ddog_Vec_Tag *tags) {
209220
? dd_zend_string_to_CharSlice(value)
210221
: ZERO;
211222
dd_crasht_push_tag(tags, tag, val);
212-
if (UNEXPECTED(!is_positive)) {
213-
goto opcache_disabled;
214-
}
215-
}
216-
}
217-
218-
// The CLI SAPI has an additional configuration for being enabled. This is
219-
// INI_SYSTEM so we can check it here.
220-
bool is_cli_sapi = strcmp("cli", sapi_module.name) == 0;
221-
if (is_cli_sapi) {
222-
ddog_CharSlice tag = DDOG_CHARSLICE_C("php.opcache.enable_cli");
223-
zend_string *value = dd_crasht_find_ini_by_tag(tag);
224-
if (EXPECTED(value)) {
225-
bool is_enabled = zend_ini_parse_bool(value);
226-
ddog_CharSlice val = is_enabled ? ONE : ZERO;
227-
dd_crasht_push_tag(tags, tag, val);
228-
if (UNEXPECTED(!is_enabled)) {
229-
goto opcache_disabled;
230-
}
231223
}
232224
}
233225

tests/ext/crashtracker_jit_tags.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ $rr->waitForRequest(function ($request) {
7474
"library_version": "%s",
7575
"family": "php",
7676
"tags": [
77-
"php.opcache.jit_buffer_size:32M",
7877
"php.opcache.enable_cli:1",
78+
"php.opcache.jit_buffer_size:32M",
7979
"php.opcache.enable:1",
8080
"php.opcache.jit:tracing",
8181
%A

0 commit comments

Comments
 (0)