Skip to content

Commit

Permalink
Misc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
danog committed May 29, 2024
1 parent 649b38c commit ae2e4a1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,11 @@ public function __construct(SettingsLogger $settings, string $prefix = '')
$this->colors[self::WARNING] = implode(';', [self::FOREGROUND['white'], self::SET['dim'], self::BACKGROUND['red']]);
$this->colors[self::ERROR] = implode(';', [self::FOREGROUND['white'], self::SET['bold'], self::BACKGROUND['red']]);
$this->colors[self::FATAL_ERROR] = implode(';', [self::FOREGROUND['red'], self::SET['bold'], self::BACKGROUND['light_gray']]);
$this->newline = PHP_EOL;
$newline = PHP_EOL;
if ($this->mode === self::ECHO_LOGGER) {
$stdout = getStdout();
if (PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg') {
$this->newline = '<br>'.$this->newline;
$newline = '<br>'.$newline;
}
} elseif ($this->mode === self::FILE_LOGGER) {
$stdout = new WritableResourceStream(fopen($this->optional, 'a'));
Expand Down Expand Up @@ -309,6 +309,7 @@ static function () use ($maxSize, $optional, $stdout): void {
$stdout = getStderr();
}
}
$this->newline = $newline;

if (isset($stdout)) {
$pipe = new Pipe(PHP_INT_MAX);
Expand Down
10 changes: 6 additions & 4 deletions src/MTProto/MTProtoOutgoingMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,12 @@ public function reply($result): void
$this->connection->inFlightGauge?->dec([
'method' => $this->constructor,
]);
$this->connection->requestLatencies?->observe(
hrtime(true) - $this->sent,
['method' => $this->constructor]
);
if (!\is_callable($result)) {
$this->connection->requestLatencies?->observe(
hrtime(true) - $this->sent,
['method' => $this->constructor]
);
}
}

$this->serializedBody = null;
Expand Down
2 changes: 1 addition & 1 deletion src/MTProtoSession/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public function createSession(): void
$this->requestLatencies = $this->API->getPromHistogram(
"MadelineProto",
"request_latencies",
"Request latency in nanoseconds by method",
"Successful request latency in nanoseconds by method",
$labels,
[
5_000_000,
Expand Down

0 comments on commit ae2e4a1

Please sign in to comment.