Skip to content

Commit d900f8f

Browse files
authored
dont emit warnings by default (#156)
adds a new ini entry, opentelemetry.display_warnings, default=off, to control whether warnings are emitted.
1 parent 9f14e39 commit d900f8f

File tree

4 files changed

+7
-1
lines changed

4 files changed

+7
-1
lines changed

ext/opentelemetry.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ STD_PHP_INI_ENTRY_EX("opentelemetry.attr_hooks_enabled", "Off", PHP_INI_ALL,
9191
OnUpdateBool, attr_hooks_enabled,
9292
zend_opentelemetry_globals, opentelemetry_globals,
9393
zend_ini_boolean_displayer_cb)
94+
STD_PHP_INI_ENTRY_EX("opentelemetry.display_warnings", "Off", PHP_INI_ALL,
95+
OnUpdateBool, display_warnings, zend_opentelemetry_globals,
96+
opentelemetry_globals, zend_ini_boolean_displayer_cb)
9497
STD_PHP_INI_ENTRY("opentelemetry.attr_pre_handler_function",
9598
"OpenTelemetry\\API\\Instrumentation\\WithSpanHandler::pre",
9699
PHP_INI_ALL, OnUpdateString, pre_handler_function_fqn,

ext/otel_observer.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,8 @@ static otel_observer *resolve_observer(zend_execute_data *execute_data) {
975975
}
976976
bool has_withspan_attribute = func_has_withspan_attribute(execute_data);
977977

978-
if (OTEL_G(attr_hooks_enabled) == false && has_withspan_attribute) {
978+
if (OTEL_G(attr_hooks_enabled) == false && has_withspan_attribute &&
979+
OTEL_G(display_warnings) == true) {
979980
php_error_docref(NULL, E_CORE_WARNING,
980981
"OpenTelemetry: WithSpan attribute found but "
981982
"attribute hooks disabled");

ext/php_opentelemetry.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ ZEND_BEGIN_MODULE_GLOBALS(opentelemetry)
1414
int disabled; // module disabled? (eg due to conflicting extension loaded)
1515
int allow_stack_extension;
1616
int attr_hooks_enabled; // attribute hooking enabled?
17+
int display_warnings;
1718
char *pre_handler_function_fqn;
1819
char *post_handler_function_fqn;
1920
ZEND_END_MODULE_GLOBALS(opentelemetry)

ext/tests/with_span/disable.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Check if attribute hooks can be disabled by config
66
opentelemetry
77
--INI--
88
opentelemetry.attr_hooks_enabled = Off
9+
opentelemetry.display_warnings = On
910
--FILE--
1011
<?php
1112
namespace OpenTelemetry\API\Instrumentation;

0 commit comments

Comments
 (0)