interface PerformanceTracerInterface (View source)

Interface for tracing performance and execution flow in the Content Repository.

Methods

void
openSpan(string $name, array $params = [])

Creates a named span that traces the execution until the corresponding {self::closeSpan()} is called. {self::openSpan()} and {self::closeSpan()} always need to be called in pairs.

void
closeSpan()

Close a span, opened by {self::openSpan()} before.

void
mark(string $name, array $params = [])

Creates a point-in-time marker AFTER an operation completes, within the current span.

Details

void openSpan(string $name, array $params = [])

Creates a named span that traces the execution until the corresponding {self::closeSpan()} is called. {self::openSpan()} and {self::closeSpan()} always need to be called in pairs.

A span represents a unit of work with a defined beginning and end. Any mark() calls made during the closure execution are automatically associated with this span. Spans can be nested, allowing for hierarchical performance analysis.

Suggested pattern:

 $this->performanceTracer?->openSpan('foo');
 try {
     // doFoo -> your code here
     $this->performanceTracer?->mark('doFoo')
     // doBar -> your code here
     $this->performanceTracer?->mark('doBar')
 } finally {
     $this->performanceTracer?->closeSpan();
 }

Parameters

string $name

A descriptive name for this span (e.g., "contentRepository::handle")

array $params

attributes to attach to the span (e.g., ['c' => 'CreateNode'])

Return Value

void

void closeSpan()

Close a span, opened by {self::openSpan()} before.

Return Value

void

void mark(string $name, array $params = [])

Creates a point-in-time marker AFTER an operation completes, within the current span.

Markers measure the elapsed time from the previous mark (or span start) up to and including the operation just completed. Place mark() calls immediately AFTER the operation you want to measure.

Parameters

string $name

A descriptive name identifying the operation that just completed

array $params

attributes to attach to the span (e.g., ['c' => 'CreateNode'])

Return Value

void