Comments (4)
The extension predates the JIT compiler, and it doesn't really receive future development anymore. In addition, its overriding of zend_execute_ex
does cost a bit of performance (~20%).
I used to use this extension in the past (even contributed fixes to it), but mostly leave it disabled these days to benefit from better default performance. Instead, I manually trace performance-critical sections using Tracer::inSpan
in the PHP library (i.e. without the native extension); it should get you the insights you need, without the performance penalty.
from opencensus-php.
@MrMage Thanks for sharing the performance information !! It is very useful for me when I instrument.
Do you have any recommendation when we want to capture traces with third party libraries (such as DB) ?
If I used Tracer::inSpan
, I would want to trace more specifically to figure out if the latency comes from my implementation or not.
from opencensus-php.
I trace e.g. all Laravael controller route handlers and all DB queries automatically. From there, I know which routes are slow, and can add more instrumentation to those routes as needed.
Here's the code I use:
app/Http/Controllers/Controller.php
<?php
declare(strict_types=1);
namespace App\Http\Controllers;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
use OpenCensus\Trace\Tracer;
class Controller extends BaseController
{
use DispatchesJobs,
ValidatesRequests,
AuthorizesRequests;
public function callAction($method, $parameters)
{
return Tracer::inSpan(
[
'name' => static::class . '::' . $method,
],
fn () => parent::callAction($method, $parameters)
);
}
}
app/Database/PostgresConnection.php
<?php
declare(strict_types=1);
namespace App\Database;
use Illuminate\Contracts\Debug\ExceptionHandler;
use Illuminate\Database\Grammar;
use OpenCensus\Trace\Span;
use OpenCensus\Trace\Tracer;
class PostgresConnection extends \Illuminate\Database\PostgresConnection
{
/* other methods */
protected function run($query, $bindings, \Closure $callback)
{
// Trace any database queries. Alternatively, this could also be implemented by listening to
// `\Illuminate\Database\Events\QueryExecuted` events; see e.g. `\Spatie\LaravelIgnition\Recorders\QueryRecorder`.
$args = \func_get_args();
return Tracer::inSpan(
[
'name' => 'DatabaseConnection::run',
'attributes' => [
'query' => $query,
],
'kind' => Span::KIND_CLIENT,
],
// Can't use `\func_get_args()` directly here because the arguments to `fn ()` are empty.
fn () => parent::run(...$args)
);
}
}
from opencensus-php.
@MrMage Thanks. These samples are really helpful for me to understand how to instrument the code.
And I really appreciate your kind response.
from opencensus-php.
Related Issues (20)
- Serialization error for Traces between PHP and Go daemon
- Segfault in thread-safe PHP with `parallel` module
- `make test` fails in PHP 7.4
- Version bump HOT 1
- Build error on Mac from Pecl
- Update dependencies to allow Ramsey/Uuid version 4 HOT 4
- Addressing tracing in processes that fork. HOT 1
- Memory bloat with PDO instrumentation HOT 2
- Clerical mistake in Documentation
- php7.4 compatible code release branch HOT 1
- Permission denied when calling sem_* functions on batch mode HOT 1
- PHP 8 compatibility? HOT 12
- Please tag v0.6.0 HOT 4
- Laravel:load() Error HOT 1
- PHP 8.1.0alpha1 - 1 failed test HOT 5
- PHP 7.0 - ton of segfaults in test suite HOT 3
- Version clarification HOT 1
- 0.3.0 can't be build on Windows HOT 1
- Segfaulting without tracing enabled. HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opencensus-php.