SpanBuilder
in package
Table of Contents
Properties
- $attributes : array<string|int, mixed>
- $name : string
- $parentContext : Context|null
- $shouldActivate : bool
- $spanKind : int|null
- $startTime : float|null
- $tags : array<string|int, mixed>
- $telemetry : OpenTelemetryManager
Methods
- __construct() : mixed
- asClient() : self
- asConsumer() : self
- asInternal() : self
- asProducer() : self
- asServer() : self
- Convenience methods for common span kinds
- attribute() : self
- Add single attribute
- attributes() : self
- Add multiple attributes
- cache() : self
- create() : self
- Static factory methods for common use cases
- database() : self
- external() : self
- forCache() : self
- Cache-specific builder methods
- forDatabase() : self
- Database-specific builder methods
- forExternalService() : self
- External service call builder methods
- forHttpRequest() : self
- HTTP-specific builder methods
- forHttpResponse() : self
- forQueue() : self
- Queue-specific builder methods
- http() : self
- job() : self
- kind() : self
- Set span kind
- start() : SpanInterface
- Start the span and return it
- startAt() : self
- Set start time
- tag() : self
- Add tag (convenience method for string attributes)
- tags() : self
- Add multiple tags
- trace() : mixed
- Start span and execute callback with automatic cleanup
- withoutActivation() : self
- Control span activation
- withParent() : self
- Set parent context
- extractSqlOperation() : string
- getResponseContentLength() : int|null
- Helper methods
- getStatusClass() : string
- setResponseStatus() : void
Properties
$attributes
private
array<string|int, mixed>
$attributes
= []
$name
private
string
$name
$parentContext
private
Context|null
$parentContext
= null
$shouldActivate
private
bool
$shouldActivate
= true
$spanKind
private
int|null
$spanKind
= null
$startTime
private
float|null
$startTime
= null
$tags
private
array<string|int, mixed>
$tags
= []
$telemetry
private
OpenTelemetryManager
$telemetry
Methods
__construct()
public
__construct(OpenTelemetryManager $telemetry, string $name) : mixed
Parameters
- $telemetry : OpenTelemetryManager
- $name : string
asClient()
public
asClient() : self
Return values
selfasConsumer()
public
asConsumer() : self
Return values
selfasInternal()
public
asInternal() : self
Return values
selfasProducer()
public
asProducer() : self
Return values
selfasServer()
Convenience methods for common span kinds
public
asServer() : self
Return values
selfattribute()
Add single attribute
public
attribute(string $key, mixed $value) : self
Parameters
- $key : string
- $value : mixed
Return values
selfattributes()
Add multiple attributes
public
attributes(array<string|int, mixed> $attributes) : self
Parameters
- $attributes : array<string|int, mixed>
Return values
selfcache()
public
static cache(string $name) : self
Parameters
- $name : string
Return values
selfcreate()
Static factory methods for common use cases
public
static create(string $name) : self
Parameters
- $name : string
Return values
selfdatabase()
public
static database(string $name) : self
Parameters
- $name : string
Return values
selfexternal()
public
static external(string $name) : self
Parameters
- $name : string
Return values
selfforCache()
Cache-specific builder methods
public
forCache(string $operation, string $key[, string $system = 'redis' ]) : self
Parameters
- $operation : string
- $key : string
- $system : string = 'redis'
Return values
selfforDatabase()
Database-specific builder methods
public
forDatabase(string $query[, string $system = 'postgresql' ][, string $connection = 'default' ]) : self
Parameters
- $query : string
- $system : string = 'postgresql'
- $connection : string = 'default'
Return values
selfforExternalService()
External service call builder methods
public
forExternalService(string $service, string $operation) : self
Parameters
- $service : string
- $operation : string
Return values
selfforHttpRequest()
HTTP-specific builder methods
public
forHttpRequest(Request $request) : self
Parameters
- $request : Request
Return values
selfforHttpResponse()
public
forHttpResponse(Response $response) : self
Parameters
- $response : Response
Return values
selfforQueue()
Queue-specific builder methods
public
forQueue(string $jobClass[, string $queue = 'default' ]) : self
Parameters
- $jobClass : string
- $queue : string = 'default'
Return values
selfhttp()
public
static http(string $name) : self
Parameters
- $name : string
Return values
selfjob()
public
static job(string $name) : self
Parameters
- $name : string
Return values
selfkind()
Set span kind
public
kind(int $spanKind) : self
Parameters
- $spanKind : int
Return values
selfstart()
Start the span and return it
public
start() : SpanInterface
Return values
SpanInterfacestartAt()
Set start time
public
startAt(float $timestamp) : self
Parameters
- $timestamp : float
Return values
selftag()
Add tag (convenience method for string attributes)
public
tag(string $key, string $value) : self
Parameters
- $key : string
- $value : string
Return values
selftags()
Add multiple tags
public
tags(array<string|int, mixed> $tags) : self
Parameters
- $tags : array<string|int, mixed>
Return values
selftrace()
Start span and execute callback with automatic cleanup
public
trace(Closure $callback) : mixed
Parameters
- $callback : Closure
withoutActivation()
Control span activation
public
withoutActivation() : self
Return values
selfwithParent()
Set parent context
public
withParent(Context|null $parentContext) : self
Parameters
- $parentContext : Context|null
Return values
selfextractSqlOperation()
private
extractSqlOperation(string $query) : string
Parameters
- $query : string
Return values
stringgetResponseContentLength()
Helper methods
private
getResponseContentLength(Response $response) : int|null
Parameters
- $response : Response
Return values
int|nullgetStatusClass()
private
getStatusClass(int $statusCode) : string
Parameters
- $statusCode : int
Return values
stringsetResponseStatus()
private
setResponseStatus(SpanInterface $span, Response $response) : void
Parameters
- $span : SpanInterface
- $response : Response