summaryrefslogtreecommitdiff
path: root/classes/tracer.php
diff options
context:
space:
mode:
Diffstat (limited to 'classes/tracer.php')
-rw-r--r--classes/tracer.php62
1 files changed, 41 insertions, 21 deletions
diff --git a/classes/tracer.php b/classes/tracer.php
index fde99927d..1326f4344 100644
--- a/classes/tracer.php
+++ b/classes/tracer.php
@@ -3,39 +3,59 @@ use OpenTracing\GlobalTracer;
use OpenTracing\Scope;
class Tracer {
+ /** @var Tracer $instance */
private static $instance;
public function __construct() {
- $config = new \Jaeger\Config(
- [
- 'sampler' => [
- 'type' => \Jaeger\SAMPLER_TYPE_CONST,
- 'param' => true,
- ],
- 'logging' => true,
- "local_agent" => [
- "reporting_host" => "172.17.172.39",
- "reporting_port" => 6832
+ $jaeger_host = Config::get(Config::JAEGER_REPORTING_HOST);
+
+ if ($jaeger_host) {
+ $config = new \Jaeger\Config(
+ [
+ 'sampler' => [
+ 'type' => \Jaeger\SAMPLER_TYPE_CONST,
+ 'param' => true,
+ ],
+ 'logging' => true,
+ "local_agent" => [
+ "reporting_host" => $jaeger_host,
+ "reporting_port" => 6832
+ ],
+ 'dispatch_mode' => \Jaeger\Config::JAEGER_OVER_BINARY_UDP,
],
- 'dispatch_mode' => \Jaeger\Config::JAEGER_OVER_BINARY_UDP,
- ],
- 'tt-rss'
- );
+ 'tt-rss'
+ );
- $config->initializeTracer();
+ $config->initializeTracer();
- register_shutdown_function(function() {
- $tracer = GlobalTracer::get();
- $tracer->flush();
- });
+ register_shutdown_function(function() {
+ $tracer = GlobalTracer::get();
+ $tracer->flush();
+ });
+ }
}
- private function _start(string $name, array $options = []) {
+ /**
+ * @param string $name
+ * @param array<mixed> $options
+ * @param array<string> $args
+ * @return Scope
+ */
+ private function _start(string $name, array $options = [], array $args = []): Scope {
$tracer = GlobalTracer::get();
+
+ $options['tags']['args'] = json_encode($args);
+
return $tracer->startActiveSpan($name, $options);
}
- public static function start(string $name, array $options = []) : Scope {
+ /**
+ * @param string $name
+ * @param array<string> $options
+ * @param array<string> $args
+ * @return Scope
+ */
+ public static function start(string $name, array $options = [], array $args = []) : Scope {
return self::get_instance()->_start($name, $options);
}