OpenTelemetry PHP

PsrTransport
in package
implements TransportInterface uses LogsMessagesTrait

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
$closed  : bool
$compression  : array<string|int, mixed>
$contentType  : string
$endpoint  : string
$headers  : array<string|int, mixed>
$maxResponseBodySize  : int
$maxRetries  : int
$reportedBodyErrors  : array<string, true>
$requestFactory  : RequestFactoryInterface
$retryDelay  : int
$streamFactory  : StreamFactoryInterface

Methods

__construct()  : mixed
contentType()  : string
forceFlush()  : bool
send()  : FutureInterface
shutdown()  : bool
logDebug()  : void
logError()  : void
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 log writer (for example an error handler that throws on `trigger_error`) 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
shouldLog()  : bool

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

$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 ]) : 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

contentType()

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

logDebug()

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

logError()

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

logInfo()

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

logNotice()

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

logWarning()

protected static 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 log writer (for example an error handler that throws on `trigger_error`) must not break the code that is being observed.

private static 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

shouldLog()

private static shouldLog(string $level) : bool
Parameters
$level : string
Return values
bool
On this page

Search results