Flow PHP

GenericEvent implements SpanEvent

Read onlyYes
FinalYes

Default implementation of SpanEvent.

GenericEvent provides a simple, immutable implementation for recording events within a span. Events are created with explicit timestamps.

Example usage:

$event = GenericEvent::create('user.login', $clock->now(), ['user.id' => '12345']);
echo $event->name(); // "user.login"
Tags
phpstan-import-type

TAttributeValueMap from Attributes

Interfaces

SpanEvent
Interface for events recorded within a span.

Methods

__construct()  : mixed
attributes()  : array<string, array<string|int, bool|float|int|string>|bool|float|int|string>
Get the event attributes.
attributesObject()  : Attributes
Get the event attributes as an Attributes object.
create()  : self
Create an event with an explicit timestamp.
droppedAttributeCount()  : int
Get the count of attributes that were dropped due to limits.
fromArray()  : self
Create a GenericEvent from a normalized array representation.
name()  : string
Get the event name.
normalize()  : array{name: string, timestamp: string, attributes: array, droppedAttributeCount: int}
Normalize the GenericEvent to an array representation for serialization.
timestamp()  : DateTimeImmutable
Get the event timestamp.

Methods

__construct()

public __construct(string $name, DateTimeImmutable $timestamp[, Attributes $attributesObject = new Attributes() ][, int $droppedAttributeCount = 0 ]) : mixed
Parameters
$name : string
$timestamp : DateTimeImmutable
$attributesObject : Attributes = new Attributes()
$droppedAttributeCount : int = 0

attributes()

Get the event attributes.

public attributes() : array<string, array<string|int, bool|float|int|string>|bool|float|int|string>
Return values
array<string, array<string|int, bool|float|int|string>|bool|float|int|string>

create()

Create an event with an explicit timestamp.

public static create(string $name, DateTimeImmutable $timestamp[, Attributes|TAttributeValueMap $attributes = [] ][, int $droppedAttributeCount = 0 ]) : self
Parameters
$name : string

Event name

$timestamp : DateTimeImmutable

Event timestamp

$attributes : Attributes|TAttributeValueMap = []

Event attributes

$droppedAttributeCount : int = 0

Number of attributes dropped due to limits

Return values
self

droppedAttributeCount()

Get the count of attributes that were dropped due to limits.

public droppedAttributeCount() : int
Return values
int

fromArray()

Create a GenericEvent from a normalized array representation.

public static fromArray(array{name: string, timestamp: string, attributes: array, droppedAttributeCount?: int} $data) : self
Parameters
$data : array{name: string, timestamp: string, attributes: array, droppedAttributeCount?: int}

Normalized event data

Return values
self

name()

Get the event name.

public name() : string
Return values
string

normalize()

Normalize the GenericEvent to an array representation for serialization.

public normalize() : array{name: string, timestamp: string, attributes: array, droppedAttributeCount: int}
Return values
array{name: string, timestamp: string, attributes: array, droppedAttributeCount: int}

timestamp()

Get the event timestamp.

public timestamp() : DateTimeImmutable
Return values
DateTimeImmutable

        
On this page

Search results