InstrumentationScope
Read onlyYes
FinalYes
Represents the instrumentation scope (library) producing telemetry.
InstrumentationScope identifies the library or application component that is generating telemetry data. This information is attached to all telemetry (spans, logs, metrics) for attribution and filtering.
Example usage:
$scope = new InstrumentationScope(
name: 'my-service',
version: '1.2.3',
schemaUrl: 'https://opentelemetry.io/schemas/1.21.0',
);
Tags
Properties
- $attributes : Attributes
- $name : string
- $schemaUrl : string|null
- $version : string
Methods
- __construct() : mixed
- fromArray() : self
- Create an InstrumentationScope from a normalized array representation.
-
normalize()
: array{name: string, version: string, schemaUrl: null|string, attributes: array
} - Normalize the scope to an array representation for serialization.
- withAttributes() : self
- Create a new scope with additional attributes merged with existing ones.
- withSchemaUrl() : self
- Create a new scope with a specific schema URL.
Properties
$attributes
public
Attributes
$attributes
= new Attributes()
$name
public
string
$name
$schemaUrl
public
string|null
$schemaUrl
= null
$version
public
string
$version
= 'unknown'
Methods
__construct()
public
__construct(string $name[, string $version = 'unknown' ][, null|string $schemaUrl = null ][, Attributes $attributes = new Attributes() ]) : mixed
Parameters
- $name : string
-
The name of the instrumentation scope (typically library or service name)
- $version : string = 'unknown'
-
The version of the instrumentation scope
- $schemaUrl : null|string = null
-
The schema URL for semantic conventions used by this scope
- $attributes : Attributes = new Attributes()
-
Additional scope attributes
fromArray()
Create an InstrumentationScope from a normalized array representation.
public
static fromArray(array{name: string, version?: string, schemaUrl?: null|string, attributes?: array} $data) : self
Parameters
-
$data
: array{name: string, version?: string, schemaUrl?: null|string, attributes?: array
}
Return values
selfnormalize()
Normalize the scope to an array representation for serialization.
public
normalize() : array{name: string, version: string, schemaUrl: null|string, attributes: array}
Return values
array{name: string, version: string, schemaUrl: null|string, attributes: arraywithAttributes()
Create a new scope with additional attributes merged with existing ones.
public
withAttributes(array<string, array<string|int, bool|float|int|string>|bool|float|int|string> $attributes) : self
Parameters
- $attributes : array<string, array<string|int, bool|float|int|string>|bool|float|int|string>
Return values
selfwithSchemaUrl()
Create a new scope with a specific schema URL.
public
withSchemaUrl(string $schemaUrl) : self
Parameters
- $schemaUrl : string