OpenTelemetry PHP

TraceState
in package
implements TraceStateInterface uses LogsMessagesTrait

Table of Contents

Interfaces

TraceStateInterface
TraceState parses and stores the tracestate header as an immutable list of string key/value pairs. It provides the following operations following the rules described in the W3C Trace Context specification: - Get value for a given key - Add a new key/value pair - Update an existing value for a given key - Delete a key/value pair

Constants

LIST_MEMBER_KEY_VALUE_SPLITTER  = '='
LIST_MEMBERS_SEPARATOR  = ','
MAX_COMBINED_LENGTH  = 512
MAX_LIST_MEMBERS  = 32
INVALID_VALUE_COMMA_EQUAL_REGEX  = '/,|=/'
VALID_KEY  = '[a-z]' . self::VALID_KEY_CHAR_RANGE . '{0,255}'
VALID_KEY_CHAR_RANGE  = '[_0-9a-z-*\/]'
VALID_KEY_REGEX  = '/^(?:' . self::VALID_KEY . '|' . self::VALID_VENDOR_KEY . ')$/'
VALID_VALUE_BASE_REGEX  = '/^[ -~]{0,255}[!-~]$/'
VALID_VENDOR_KEY  = '[a-z0-9]' . self::VALID_KEY_CHAR_RANGE . '{0,240}@[a-z]' . self::VALID_KEY_CHAR_RANGE . '{0,13}'

Properties

$traceState  : array<string, string>

Methods

__construct()  : mixed
__toString()  : string
Returns a string representation of this TraceSate
get()  : string|null
Return the value of a given key from this TraceState if it exists
getListMemberCount()  : int
Get the list-member count in this TraceState
toString()  : string
Returns the concatenated string representation.
with()  : TraceStateInterface
Return a new TraceState object that inherits from this TraceState and contains the given key value pair.
without()  : TraceStateInterface
Return a new TraceState object that inherits from this TraceState without the given key value pair.
logDebug()  : void
logError()  : void
logInfo()  : void
logNotice()  : void
logWarning()  : void
doLog()  : void
parse()  : array<string|int, mixed>
shouldLog()  : bool
validateKey()  : bool
The Key is opaque string that is an identifier for a vendor. It can be up to 256 characters and MUST begin with a lowercase letter or a digit, and can only contain lowercase letters (a-z), digits (0-9), underscores (_), dashes (-), asterisks (*), and forward slashes (/). For multi-tenant vendor scenarios, an at sign (@) can be used to prefix the vendor name. Vendors SHOULD set the tenant ID at the beginning of the key.
validateMember()  : bool
validateValue()  : bool
The value is an opaque string containing up to 256 printable ASCII [RFC0020] characters (i.e., the range 0x20 to 0x7E) except comma (,) and (=). Note that this also excludes tabs, newlines, carriage returns, etc.

Constants

LIST_MEMBER_KEY_VALUE_SPLITTER

public mixed LIST_MEMBER_KEY_VALUE_SPLITTER = '='

LIST_MEMBERS_SEPARATOR

public mixed LIST_MEMBERS_SEPARATOR = ','

MAX_COMBINED_LENGTH

will be removed

public mixed MAX_COMBINED_LENGTH = 512

MAX_LIST_MEMBERS

public mixed MAX_LIST_MEMBERS = 32

INVALID_VALUE_COMMA_EQUAL_REGEX

private mixed INVALID_VALUE_COMMA_EQUAL_REGEX = '/,|=/'

VALID_KEY

private mixed VALID_KEY = '[a-z]' . self::VALID_KEY_CHAR_RANGE . '{0,255}'

VALID_KEY_CHAR_RANGE

private mixed VALID_KEY_CHAR_RANGE = '[_0-9a-z-*\/]'

VALID_KEY_REGEX

private mixed VALID_KEY_REGEX = '/^(?:' . self::VALID_KEY . '|' . self::VALID_VENDOR_KEY . ')$/'

VALID_VALUE_BASE_REGEX

private mixed VALID_VALUE_BASE_REGEX = '/^[ -~]{0,255}[!-~]$/'

VALID_VENDOR_KEY

private mixed VALID_VENDOR_KEY = '[a-z0-9]' . self::VALID_KEY_CHAR_RANGE . '{0,240}@[a-z]' . self::VALID_KEY_CHAR_RANGE . '{0,13}'

Properties

$traceState

private array<string, string> $traceState

Methods

__construct()

public __construct([string|null $rawTracestate = null ]) : mixed
Parameters
$rawTracestate : string|null = null

__toString()

Returns a string representation of this TraceSate

public __toString() : string
Return values
string

get()

Return the value of a given key from this TraceState if it exists

public get(string $key) : string|null
Parameters
$key : string
Return values
string|null

getListMemberCount()

Get the list-member count in this TraceState

public getListMemberCount() : int
Return values
int

toString()

Returns the concatenated string representation.

public toString([int|null $limit = null ]) : string
Parameters
$limit : int|null = null

maximum length of the returned representation

Return values
string

the string representation

with()

Return a new TraceState object that inherits from this TraceState and contains the given key value pair.

public with(string $key, string $value) : TraceStateInterface
Parameters
$key : string
$value : string
Return values
TraceStateInterface

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> = []

doLog()

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

parse()

private static parse(string $rawTracestate) : array<string|int, mixed>
Parameters
$rawTracestate : string
Return values
array<string|int, mixed>

shouldLog()

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

validateKey()

The Key is opaque string that is an identifier for a vendor. It can be up to 256 characters and MUST begin with a lowercase letter or a digit, and can only contain lowercase letters (a-z), digits (0-9), underscores (_), dashes (-), asterisks (*), and forward slashes (/). For multi-tenant vendor scenarios, an at sign (@) can be used to prefix the vendor name. Vendors SHOULD set the tenant ID at the beginning of the key.

private static validateKey(string $key) : bool
Parameters
$key : string
Tags
see
https://www.w3.org/TR/trace-context/#key
Return values
bool

validateMember()

private static validateMember(array<string|int, mixed> $traceState, string $key, string $value) : bool
Parameters
$traceState : array<string|int, mixed>
$key : string
$value : string
Return values
bool

validateValue()

The value is an opaque string containing up to 256 printable ASCII [RFC0020] characters (i.e., the range 0x20 to 0x7E) except comma (,) and (=). Note that this also excludes tabs, newlines, carriage returns, etc.

private static validateValue(string $key) : bool
Parameters
$key : string
Tags
see
https://www.w3.org/TR/trace-context/#value
Return values
bool

        
On this page

Search results