Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve php zero-code #4763

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions content/en/docs/zero-code/php.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,13 @@ $demo = new DemoClass();
$demo->run();
```

Here, we provide `pre` and `post` functions, which are executed before and after
`DemoClass::run`. The `pre` function starts and activates a span, and the `post`
function ends it. If an exception was thrown by `DemoClass::run()`, the `post`
function will record it, without affecting exception propagation.
In the example above we define `DemoClass`, then register `pre` and `post` hook
functions on its `run` method. The hook functions will run before and after each
execution of the `DemoClass::run()` method. The `pre` function starts and
activates a span, and the `post` function ends it.

If an exception was thrown by `DemoClass::run()`, the `post` function will
record it, without affecting exception propagation.

## Installation

Expand Down Expand Up @@ -213,13 +216,13 @@ OpenTelemetry\API\Globals::registerInitializer(function (Configurator $configura
$tracer = Globals::tracerProvider()->getTracer('example');
//or, via CachedInstrumentation which uses `Globals` internally
$instrumentation = new CachedInstrumentation('example');
$tracerProvider = $instrumentation->tracer();
$tracer = $instrumentation->tracer();
```

## Supported libraries and frameworks

Automatic Instrumentation comes with a number of instrumentation libraries for
commonly used PHP libraries. For the full list, see
Automatic Instrumentation is available for a number of instrumentation libraries
for commonly used PHP libraries. For the full list, see
[instrumentation libraries on packagist](https://packagist.org/search/?query=open-telemetry&tags=instrumentation).

## Next steps
Expand Down