Tracer: rework options to tags
This commit is contained in:
parent
6418157ccf
commit
d68c736e47
|
@ -304,11 +304,16 @@ class DiskCache implements Cache_Adapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function send(string $filename) {
|
public function send(string $filename) {
|
||||||
|
$scope = Tracer::start(__FUNCTION__, ['filename' => $filename]);
|
||||||
|
|
||||||
$filename = basename($filename);
|
$filename = basename($filename);
|
||||||
|
|
||||||
if (!$this->exists($filename)) {
|
if (!$this->exists($filename)) {
|
||||||
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
|
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
|
||||||
echo "File not found.";
|
echo "File not found.";
|
||||||
|
|
||||||
|
$scope->getSpan()->setTag('error', '404 not found');
|
||||||
|
$scope->close();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,6 +322,9 @@ class DiskCache implements Cache_Adapter {
|
||||||
|
|
||||||
if (($_SERVER['HTTP_IF_MODIFIED_SINCE'] ?? '') == $gmt_modified || ($_SERVER['HTTP_IF_NONE_MATCH'] ?? '') == $file_mtime) {
|
if (($_SERVER['HTTP_IF_MODIFIED_SINCE'] ?? '') == $gmt_modified || ($_SERVER['HTTP_IF_NONE_MATCH'] ?? '') == $file_mtime) {
|
||||||
header('HTTP/1.1 304 Not Modified');
|
header('HTTP/1.1 304 Not Modified');
|
||||||
|
|
||||||
|
$scope->getSpan()->setTag('error', '304 not modified');
|
||||||
|
$scope->close();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,6 +342,9 @@ class DiskCache implements Cache_Adapter {
|
||||||
header("Content-type: text/plain");
|
header("Content-type: text/plain");
|
||||||
|
|
||||||
print "Stored file has disallowed content type ($mimetype)";
|
print "Stored file has disallowed content type ($mimetype)";
|
||||||
|
|
||||||
|
$scope->getSpan()->setTag('error', '400 disallowed content type');
|
||||||
|
$scope->close();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,7 +366,13 @@ class DiskCache implements Cache_Adapter {
|
||||||
|
|
||||||
header_remove("Pragma");
|
header_remove("Pragma");
|
||||||
|
|
||||||
return $this->adapter->send($filename);
|
$scope->getSpan()->setTag('mimetype', $mimetype);
|
||||||
|
|
||||||
|
$rc = $this->adapter->send($filename);
|
||||||
|
|
||||||
|
$scope->close();
|
||||||
|
|
||||||
|
return $rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_full_path(string $filename): string {
|
public function get_full_path(string $filename): string {
|
||||||
|
|
|
@ -37,26 +37,26 @@ class Tracer {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param array<string>|array<string, array<string, mixed>> $options
|
* @param array<string>|array<string, array<string, mixed>> $tags
|
||||||
* @param array<string> $args
|
* @param array<string> $args
|
||||||
* @return Scope
|
* @return Scope
|
||||||
*/
|
*/
|
||||||
private function _start(string $name, array $options = [], array $args = []): Scope {
|
private function _start(string $name, array $tags = [], array $args = []): Scope {
|
||||||
$tracer = GlobalTracer::get();
|
$tracer = GlobalTracer::get();
|
||||||
|
|
||||||
$options['tags']['args'] = json_encode($args);
|
$tags['args'] = json_encode($args);
|
||||||
|
|
||||||
return $tracer->startActiveSpan($name, $options);
|
return $tracer->startActiveSpan($name, ['tags' => $tags]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param array<string>|array<string, array<string, mixed>> $options
|
* @param array<string>|array<string, array<string, mixed>> $tags
|
||||||
* @param array<string> $args
|
* @param array<string> $args
|
||||||
* @return Scope
|
* @return Scope
|
||||||
*/
|
*/
|
||||||
public static function start(string $name, array $options = [], array $args = []) : Scope {
|
public static function start(string $name, array $tags = [], array $args = []) : Scope {
|
||||||
return self::get_instance()->_start($name, $options, $args);
|
return self::get_instance()->_start($name, $tags, $args);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function get_instance() : Tracer {
|
public static function get_instance() : Tracer {
|
||||||
|
|
Loading…
Reference in New Issue