stop calling spans scopes
This commit is contained in:
@@ -339,15 +339,15 @@ class PluginHost {
|
||||
*/
|
||||
function chain_hooks_callback(string $hook, Closure $callback, &...$args): void {
|
||||
$method = strtolower((string)$hook);
|
||||
$scope = OpenTelemetry\API\Trace\Span::getCurrent();
|
||||
$scope->addEvent("chain_hooks_callback: $hook");
|
||||
$span = OpenTelemetry\API\Trace\Span::getCurrent();
|
||||
$span->addEvent("chain_hooks_callback: $hook");
|
||||
|
||||
foreach ($this->get_hooks((string)$hook) as $plugin) {
|
||||
//Debug::log("invoking: " . get_class($plugin) . "->$hook()", Debug::$LOG_VERBOSE);
|
||||
|
||||
//$p_scope = Tracer::start("$hook - " . get_class($plugin));
|
||||
//$p_span = Tracer::start("$hook - " . get_class($plugin));
|
||||
|
||||
$scope->addEvent("$hook - " . get_class($plugin));
|
||||
$span->addEvent("$hook - " . get_class($plugin));
|
||||
|
||||
try {
|
||||
if ($callback($plugin->$method(...$args), $plugin))
|
||||
@@ -358,10 +358,10 @@ class PluginHost {
|
||||
user_error($err, E_USER_WARNING);
|
||||
}
|
||||
|
||||
//$p_scope->end();
|
||||
//$p_span->end();
|
||||
}
|
||||
|
||||
//$scope->end();
|
||||
//$span->end();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -427,6 +427,8 @@ class PluginHost {
|
||||
* @param PluginHost::KIND_* $kind
|
||||
*/
|
||||
function load_all(int $kind, int $owner_uid = null, bool $skip_init = false): void {
|
||||
$span = Tracer::start(__METHOD__);
|
||||
$span->setAttribute('func.args', json_encode(func_get_args()));
|
||||
|
||||
$plugins = [...(glob("plugins/*") ?: []), ...(glob("plugins.local/*") ?: [])];
|
||||
$plugins = array_filter($plugins, "is_dir");
|
||||
@@ -435,13 +437,16 @@ class PluginHost {
|
||||
asort($plugins);
|
||||
|
||||
$this->load(join(",", $plugins), (int)$kind, $owner_uid, $skip_init);
|
||||
|
||||
$span->end();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PluginHost::KIND_* $kind
|
||||
*/
|
||||
function load(string $classlist, int $kind, int $owner_uid = null, bool $skip_init = false): void {
|
||||
$scope = Tracer::start(__METHOD__);
|
||||
$span = Tracer::start(__METHOD__);
|
||||
$span->setAttribute('func.args', json_encode(func_get_args()));
|
||||
|
||||
$plugins = explode(",", $classlist);
|
||||
|
||||
@@ -451,7 +456,7 @@ class PluginHost {
|
||||
$class = trim($class);
|
||||
$class_file = strtolower(basename(clean($class)));
|
||||
|
||||
$scope->addEvent("$class_file: load");
|
||||
$span->addEvent("$class_file: load");
|
||||
|
||||
// try system plugin directory first
|
||||
$file = dirname(__DIR__) . "/plugins/$class_file/init.php";
|
||||
@@ -478,7 +483,7 @@ class PluginHost {
|
||||
|
||||
$_SESSION["safe_mode"] = 1;
|
||||
|
||||
$scope->setAttribute('error', 'plugin is blacklisted');
|
||||
$span->setAttribute('error', 'plugin is blacklisted');
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -490,7 +495,7 @@ class PluginHost {
|
||||
} catch (Error $err) {
|
||||
user_error($err, E_USER_WARNING);
|
||||
|
||||
$scope->setAttribute('error', $err);
|
||||
$span->setAttribute('error', $err);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -501,7 +506,7 @@ class PluginHost {
|
||||
if ($plugin_api < self::API_VERSION) {
|
||||
user_error("Plugin $class is not compatible with current API version (need: " . self::API_VERSION . ", got: $plugin_api)", E_USER_WARNING);
|
||||
|
||||
$scope->setAttribute('error', 'plugin is not compatible with API version');
|
||||
$span->setAttribute('error', 'plugin is not compatible with API version');
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -510,7 +515,7 @@ class PluginHost {
|
||||
_bind_textdomain_codeset($class, "UTF-8");
|
||||
}
|
||||
|
||||
$scope->addEvent("$class_file: initialize");
|
||||
$span->addEvent("$class_file: initialize");
|
||||
|
||||
try {
|
||||
switch ($kind) {
|
||||
@@ -541,7 +546,7 @@ class PluginHost {
|
||||
}
|
||||
|
||||
$this->load_data();
|
||||
$scope->end();
|
||||
$span->end();
|
||||
}
|
||||
|
||||
function is_system(Plugin $plugin): bool {
|
||||
@@ -634,8 +639,8 @@ class PluginHost {
|
||||
}
|
||||
|
||||
private function load_data(): void {
|
||||
$scope = OpenTelemetry\API\Trace\Span::getCurrent();
|
||||
$scope->addEvent('load plugin data');
|
||||
$span = OpenTelemetry\API\Trace\Span::getCurrent();
|
||||
$span->addEvent('load plugin data');
|
||||
|
||||
if ($this->owner_uid && !$this->data_loaded && Config::get_schema_version() > 100) {
|
||||
$sth = $this->pdo->prepare("SELECT name, content FROM ttrss_plugin_storage
|
||||
@@ -643,7 +648,7 @@ class PluginHost {
|
||||
$sth->execute([$this->owner_uid]);
|
||||
|
||||
while ($line = $sth->fetch()) {
|
||||
$scope->addEvent($line["name"] . ': unserialize');
|
||||
$span->addEvent($line["name"] . ': unserialize');
|
||||
|
||||
$this->storage[$line["name"]] = unserialize($line["content"]);
|
||||
}
|
||||
@@ -654,8 +659,8 @@ class PluginHost {
|
||||
|
||||
private function save_data(string $plugin): void {
|
||||
if ($this->owner_uid) {
|
||||
$scope = OpenTelemetry\API\Trace\Span::getCurrent();
|
||||
$scope->addEvent(__METHOD__ . ": $plugin");
|
||||
$span = OpenTelemetry\API\Trace\Span::getCurrent();
|
||||
$span->addEvent(__METHOD__ . ": $plugin");
|
||||
|
||||
if (!$this->pdo_data)
|
||||
$this->pdo_data = Db::instance()->pdo_connect();
|
||||
|
||||
Reference in New Issue
Block a user