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"

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.
fromArray()  : self
Create a GenericEvent from a normalized array representation.
name()  : string
Get the event name.
normalize()  : array{name: string, timestamp: string, attributes: array}
Normalize the GenericEvent to an array representation for serialization.
timestamp()  : DateTimeImmutable
Get the event timestamp.

Methods

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[, array<string, array<string|int, bool|DateTimeInterface|float|int|string|Throwable>|bool|DateTimeInterface|float|int|string|Throwable$attributes = [] ]) : self
Parameters
$name : string

Event name

$timestamp : DateTimeImmutable

Event timestamp

$attributes : array<string, array<string|int, bool|DateTimeInterface|float|int|string|Throwable>|bool|DateTimeInterface|float|int|string|Throwable> = []

Event attributes

Return values
self

fromArray()

Create a GenericEvent from a normalized array representation.

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

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}
Return values
array{name: string, timestamp: string, attributes: array}

timestamp()

Get the event timestamp.

public timestamp() : DateTimeImmutable
Return values
DateTimeImmutable

        
On this page

Search results