The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

OpenTelemetry::SDK::InstrumentationScope - A logical unit of instrumented code

SYNOPSIS

use OpenTelemetry::SDK::InstrumentationScope;

my $scope = OpenTelemetry::SDK::InstrumentationScope->new(
    name    => 'my_scope',  # mandatory
    version => '1.2.3',     # optional
);

my $tracer = OpenTelemetry->tracer_provider->tracer($scope);

DESCRIPTION

The instrumentation scope represents a logical unit of application code that can be instrumented to emit telemetry data. The decision of what constitutes as this logical boundary is ultimately up to application authors, but in the context of instrumentation libraries, the library will often be the scope.

The main use of a class representing the instrumentation scope is to request a tracer or meter from the appropriate providers.

METHODS

This class implements the OpenTelemetry::Attributes role. Please consult that module's documentation for details on the behaviours it provides.

new

$scope = OpenTelemetry::SDK::InstrumentationScope->new(
    name    => $name,
    version => $version // '',
);

Create a new instrumentation scope, with a name and an optional version string. The empty string will be used if no version is provided.

Creating a scope without a name will set the name of the scope to the empty string and raise a warning.

name

$name = $scope->name;

Retrieves the name of the scope as a string. This might be empty f none was provided when the scope was constructed.

version

$version = $scope->version;

Retrieves the version of the scope as a string. This might be empty if none was provided when the scope was constructed.

to_string

$string = $scope->to_string;

Generates a string with the name and possibly the version of the scope. This string is suitable to be used as an identifier for the scope. Two scopes that generate the same string will represent the same scope.

SEE ALSO

OpenTelemetry::Attributes
OpenTelemetry::Trace::TracerProvider
OpenTelemetry::SDK::Trace::TracerProvider
OpenTelemetry specification on InstrumentationScope

COPYRIGHT AND LICENSE

This software is copyright (c) 2023 by José Joaquín Atria.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.