OpenTelemetry PHP

PsrTransport
in package
implements TransportInterface uses LogsToLoggerTrait

FinalYes
Tags
template
implements

Table of Contents

Interfaces

TransportInterface

Constants

DEFAULT_MAX_RESPONSE_BODY_SIZE  : mixed = 4 * 1024 * 1024
Default limit for the response body, also after decompression.
MAX_REPORTED_BODY_ERRORS  : mixed = 16
Distinct reasons a response body was ignored, which have been logged as a warning already.

Properties

$client  : ClientInterface
$clock  : ClockInterface
$closed  : bool
$compression  : array<string|int, mixed>
$contentType  : string
$endpoint  : string
$headers  : array<string|int, mixed>
$logger  : LoggerInterface
$maxResponseBodySize  : int
$maxRetries  : int
$reportedBodyErrors  : array<string, true>
$requestFactory  : RequestFactoryInterface
$retryDelay  : int
$streamFactory  : StreamFactoryInterface
$timeout  : float

Methods

__construct()  : mixed
contentType()  : string
forceFlush()  : bool
send()  : FutureInterface
Only the waits between attempts are bounded by the timeout. An attempt runs until the client's own timeout, since PSR-18 has no per-request timeout. `$cancellation` isn't checked yet.
shutdown()  : bool
logDebug()  : void
logError()  : void
logger()  : LoggerInterface
logInfo()  : void
logNotice()  : void
logWarning()  : void
checkBodySize()  : void
Checks the body of a response that is not going to be used, such as an error. An unreadable body is ignored, so that the status of the response stays the reason for the failure.
doLog()  : void
Logging is best effort: a failing logger must not break the code that is being observed.
logIgnoredBody()  : void
A server that always answers in an encoding that can't be decoded would fill the log with a warning for every export, so only the first one for each reason is a warning, the rest are debug messages.
parseContentEncoding()  : array<int, string>
readBody()  : string

Constants

MAX_REPORTED_BODY_ERRORS

Distinct reasons a response body was ignored, which have been logged as a warning already.

private mixed MAX_REPORTED_BODY_ERRORS = 16

Properties

$compression read-only

private array<string|int, mixed> $compression

$headers read-only

private array<string|int, mixed> $headers

$logger read-only

private LoggerInterface $logger = new ConfiguredLogger()

$maxResponseBodySize read-only

private int $maxResponseBodySize = self::DEFAULT_MAX_RESPONSE_BODY_SIZE

$reportedBodyErrors

private array<string, true> $reportedBodyErrors = []

$requestFactory read-only

private RequestFactoryInterface $requestFactory

$streamFactory read-only

private StreamFactoryInterface $streamFactory

Methods

__construct()

public __construct(ClientInterface $client, RequestFactoryInterface $requestFactory, StreamFactoryInterface $streamFactory, string $endpoint, CONTENT_TYPE $contentType, array<string|int, mixed> $headers, array<string|int, mixed> $compression, int $retryDelay, int $maxRetries[, int $maxResponseBodySize = self::DEFAULT_MAX_RESPONSE_BODY_SIZE ][, LoggerInterface $logger = new ConfiguredLogger() ][, float $timeout = 0.0 ][, ClockInterface|null $clock = null ]) : mixed
Parameters
$client : ClientInterface
$requestFactory : RequestFactoryInterface
$streamFactory : StreamFactoryInterface
$endpoint : string
$contentType : CONTENT_TYPE
$headers : array<string|int, mixed>
$compression : array<string|int, mixed>
$retryDelay : int
$maxRetries : int
$maxResponseBodySize : int = self::DEFAULT_MAX_RESPONSE_BODY_SIZE
$logger : LoggerInterface = new ConfiguredLogger()
$timeout : float = 0.0
$clock : ClockInterface|null = null

contentType()

public contentType() : string
Attributes
#[Override]
Return values
string

send()

Only the waits between attempts are bounded by the timeout. An attempt runs until the client's own timeout, since PSR-18 has no per-request timeout. `$cancellation` isn't checked yet.

public send(string $payload[, CancellationInterface|null $cancellation = null ]) : FutureInterface
Parameters
$payload : string
$cancellation : CancellationInterface|null = null
Tags
see
https://github.com/open-telemetry/opentelemetry-specification/blob/v1.63.0/specification/protocol/exporter.md#retry
psalm-suppress

ArgumentTypeCoercion

Attributes
#[Override]
Return values
FutureInterface

logDebug()

protected logDebug(string $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
$message : string
$context : array<string|int, mixed> = []

logError()

protected logError(string $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
$message : string
$context : array<string|int, mixed> = []

logger()

protected logger() : LoggerInterface
Attributes
#[Override]
Return values
LoggerInterface

logInfo()

protected logInfo(string $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
$message : string
$context : array<string|int, mixed> = []

logNotice()

protected logNotice(string $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
$message : string
$context : array<string|int, mixed> = []

logWarning()

protected logWarning(string $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
$message : string
$context : array<string|int, mixed> = []

checkBodySize()

Checks the body of a response that is not going to be used, such as an error. An unreadable body is ignored, so that the status of the response stays the reason for the failure.

private checkBodySize(ResponseInterface $response) : void
Parameters
$response : ResponseInterface
Tags
throws
ResponseBodyTooLargeException

if the body exceeds the limit, after logging a warning

doLog()

Logging is best effort: a failing logger must not break the code that is being observed.

private doLog(string $level, string $message, array<string|int, mixed> $context) : void
Parameters
$level : string
$message : string
$context : array<string|int, mixed>

logIgnoredBody()

A server that always answers in an encoding that can't be decoded would fill the log with a warning for every export, so only the first one for each reason is a warning, the rest are debug messages.

private logIgnoredBody(RuntimeException $e, ResponseInterface $response) : void
Parameters
$e : RuntimeException
$response : ResponseInterface

parseContentEncoding()

private static parseContentEncoding(ResponseInterface $response) : array<int, string>
Parameters
$response : ResponseInterface
Return values
array<int, string>

readBody()

private readBody(ResponseInterface $response) : string
Parameters
$response : ResponseInterface
Tags
throws
ResponseBodyTooLargeException

if the body exceeds the limit, after logging a warning

RuntimeException

if the body can't be read or decoded

Return values
string
On this page

Search results