Download the PHP package open-telemetry/ext-opentelemetry without Composer

On this page you can find all versions of the php package open-telemetry/ext-opentelemetry. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package ext-opentelemetry

OpenTelemetry auto-instrumentation extension

Build and test

Current Project Status

For more information, please consult the documentation of the main OpenTelemetry PHP project.

Issues

Issues have been disabled for this repo in order to help maintain consistency between this repo and the main OpenTelemetry PHP project repo. If you have an issue you'd like to raise about this issue, please use the OpenTelemetry PHP Issue section. Please prefix the title of the issue with [opentelemetry-php-instrumentation].

Description

This is a PHP extension for OpenTelemetry, to enable auto-instrumentation. It is based on zend_observer and requires php8+

The extension allows:

In PHP 8.2+, internal/built-in PHP functions can also be observed.

Requirements

Installation

The extension can be installed in all of the usual ways:

pecl

php-extension-installer

If you are using the official PHP docker images then you can use php-extension-installer

From github:

Via pecl/pickle:

Windows

Pre-built windows binaries are available from the releases page

See https://wiki.php.net/internals/windows/stepbystepbuild_sdk_2#building_pecl_extensions_with_phpize for generic advice on building from source under Windows.

Verify that the extension is installed and enabled

Known issues

Conflicting extensions

The extension can be configured to not run if a conflicting extension is installed. The following extensions are known to not work when installed alongside OpenTelemetry:

If the conflicting extension is a regular PHP extension (i.e, not a zend_extension), you can control conflicts via the opentelemetry.conflicts ini setting.

If a conflicting extension is found, then the OpenTelemetry extension will disable itself:

Invalid pre/post hooks

Invalid argument types in pre and post callbacks can cause fatal errors. Runtime checking is performed on the hook functions to ensure they are compatible. If not, the hook will not be executed and an error will be generated.

This feature can be disabled by setting the opentelemetry.validate_hook_functions ini value to Off;

Increasing function argument count

By default, increasing the number of arguments provided to a function in the pre hook is allowed only if that does not require the stack frame of the function call to be extended in size. For internal functions, adding arguments not provided at the callsite always requires stack extension. For PHP functions, it is required only if the argument is not included in the function definition.

Extending stack frame automatically can be enabled by setting opentelemetry.allow_stack_extension ini value to On. This enables extending the stack frame by up to another 16 arguments.

Usage

The pre method starts and activates a span. The post method ends the span after the observed method has finished.

There are more examples in the tests directory

Static methods

Note that if hooking a static class method, the first parameter to pre and post callbacks is a string containing the method's class name.

Caveats

Modifying parameters, exceptions and return values of the observed function

Parameters

From a pre hook function, you may modify the parameters before they are received by the observed function. The arguments are passed in as a numerically-indexed array. The returned array from the pre hook is used to modify (not replace) the existing parameters:

gives output:

Return values

post hook methods can modify the observed function's return value:

gives output:

Important: the post method must provide a return type-hint, otherwise the return value will be ignored. The return type hint in the example above is : int.

Exceptions

post hook methods can modify an exception thrown from the observed function:

gives output:

Attribute-based hooking

By applying attributes to source code, the OpenTelemetry extension can add hooks at runtime.

Default pre and post hook methods are provided by the OpenTelemetry API: OpenTelemetry\API\Instrumentation\Handler::pre and ::post.

This feature is disabled by default, but can be enabled by setting opentelemetry.attr_hooks_enabled = On in php.ini

Restrictions

Attribute-based hooks can only be applied to a function/method that does not already have hooks applied. Only one hook can be applied to a function/method, including via interfaces.

Since the attributes are evaluated at runtime, the extension checks whether a hook already exists to decide whether it should apply a new runtime hook.

Configuration

This feature can be configured via .ini by modifying the following entries:

OpenTelemetry\API\Instrumentation\WithSpan attribute

This attribute is provided by the OpenTelemetry API can be applied to a function or class method.

You can also provide optional parameters to the attribute, which control:

OpenTelemetry\API\Instrumentation\SpanAttribute attribute

This attribute should be used in conjunction with WithSpan. It is applied to function/method parameters, and causes those parameters and values to be passed through to the pre hook function where they can be added as trace attributes. There is one optional parameter, which controls the attribute key. If not set, the parameter name is used.

Contributing

See https://github.com/open-telemetry/opentelemetry-php/blob/main/CONTRIBUTING.md

Maintainers

For more information about the maintainer role, see the community repository.

Approvers

For more information about the approver role, see the community repository.


All versions of ext-opentelemetry with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package open-telemetry/ext-opentelemetry contains the following files

Loading the files please wait ....