class DaemonClient implements ExporterInterface, ExporterInterface

This class is a client to the OpenCensus PHP Daemon application.

It allows to quickly move both Tracing and Stats data handling out of band and provide metrics persistence outside of PHP request oriented runtime.

Traits

Varint encoding and decoding methods inspired by Go encoding/binary package.

Constants

DEFAULT_SOCKET_PATH

Default socket path to use. (Unix)

DEFAULT_NAMED_PIPE_PATH

Default named pipe to use. (Windows)

DEFAULT_MAX_SEND_TIME

Default send timeout in seconds as float.

PROT_VERSION

Protocol version this client supports.

START_OF_MSG

Start of message delimiter, allowing for recovery from truncated messages

MSG_PROC_INIT

MSG_PROC_SHUTDOWN

MSG_REQ_INIT

MSG_REQ_SHUTDOWN

MSG_TRACE_EXPORT

MSG_MEASURE_CREATE

MSG_VIEW_REPORTING_PERIOD

MSG_VIEW_REGISTER

MSG_VIEW_UNREGISTER

MSG_STATS_RECORD

MS_TYPE_INT

MS_TYPE_FLOAT

MS_TYPE_UNKNOWN

Methods

static int
encodeUnsigned(string $buf, int $x)

Varint encode as unsigned integer.

static int
encodeSigned(string $buf, int $x)

Varint encode as signed integer.

static int
decodeUnsigned(string $buf, int $x)

Varint decode an unsigned integer.

static int
decodeSigned(string $buf, int $x)

Varint decode a signed integer.

static DaemonClient
init(array $options = [])

Initialize our DaemonClient for Stats and/or Trace reporting to the OpenCensus PHP Daemon service.

static bool
createMeasure(Measure $measure)

Register a new Measure.

static bool
setReportingPeriod(float $interval)

Adjust the stats reporting period of the Daemom.

static bool
registerView(View ...$views)

Register views.

static bool
unregisterView(View ...$views)

Unregister views.

static bool
recordStats(TagContext $tagContext, array $attachments, Measurement ...$ms)

Record the provided Measurements, Attachments and Tags.

bool
export(array $spans)

Export the provided SpanData to a backend.

Details

in VarintTrait at line 33
static int encodeUnsigned(string $buf, int $x)

Varint encode as unsigned integer.

Parameters

string $buf bytestring to hold varint encoding of $x.
int $x the unsigned integer to varint encode.

Return Value

int number of bytes written to buf.

in VarintTrait at line 51
static int encodeSigned(string $buf, int $x)

Varint encode as signed integer.

Parameters

string $buf bytestring to hold varint encoding of $x.
int $x the signed integer to varint encode.

Return Value

int number of bytes written to buf.

in VarintTrait at line 67
static int decodeUnsigned(string $buf, int $x)

Varint decode an unsigned integer.

Parameters

string $buf bytestring holding varint encoding.
int $x integer to receive the decoded value.

Return Value

int number of bytes read from buf.

in VarintTrait at line 96
static int decodeSigned(string $buf, int $x)

Varint decode a signed integer.

Parameters

string $buf bytestring holding varint encoding.
int $x integer to receive the decoded value.

Return Value

int number of bytes read from buf.

at line 145
static DaemonClient init(array $options = [])

Initialize our DaemonClient for Stats and/or Trace reporting to the OpenCensus PHP Daemon service.

Parameters

array $options Configuration options.

@type string $socketPath Path of the Unix socket to communicate over.
@type float $maxSendTime The maximum send time for a message payload in seconds.

Return Value

DaemonClient Returns the DaemonClient object on successful initialization.

Exceptions

Exception Throws on the inability to communicate with the PHP Daemon.

at line 189
static bool createMeasure(Measure $measure)

Register a new Measure.

Parameters

Measure $measure The measure to register.

Return Value

bool Returns true on successful send operation.

at line 209
static bool setReportingPeriod(float $interval)

Adjust the stats reporting period of the Daemom.

Parameters

float $interval Reporting interval of the daemon in seconds.

Return Value

bool Returns true on successful send operation.

at line 218
static bool registerView(View ...$views)

Register views.

Parameters

View ...$views One or more Views to register.

Return Value

bool Returns true on successful send operation.

at line 250
static bool unregisterView(View ...$views)

Unregister views.

Parameters

View ...$views Views to unregister.

Return Value

bool Returns true on successful send operation.

at line 265
static bool recordStats(TagContext $tagContext, array $attachments, Measurement ...$ms)

Record the provided Measurements, Attachments and Tags.

Parameters

TagContext $tagContext TagContext to record with our Measurements.
array $attachments Key-value pairs to use for exemplar annotation.
Measurement ...$ms One or more measurements to record.

Return Value

bool Returns true on successful send operation.

at line 301
bool export(array $spans)

Export the provided SpanData to a backend.

Parameters

array $spans

Return Value

bool