DataDog / dd-trace-php

Datadog PHP Clients
https://docs.datadoghq.com/tracing/setup/php
Other
503 stars 156 forks source link

[Feature] make it easier to hook in custom instrumentations for other framework #1079

Open tmotyl opened 4 years ago

tmotyl commented 4 years ago

Is your feature request related to a problem? Please describe. Right now in order to have a certain framework being supported by dd-tracer you either:

Lets take the second approach: We want to instrument datadog as soon as possible in the application (to trace the whole processing time). Ideally the instrumentation would happen in index.php However we don't want to modify the core files of the framework directly (e.g. index.php or other files using for bootstrapping application), but we want to use framework extensibility (plugins). However, when we write a plugin, then DD will not instrument application bootstraping process which happen before plugin mechanism is loaded.

To work around that one could write a composer plugin which would add instrumentation after autoloading happen, or hack the dd_wrap_autoloader.php file.

Both solutions have drawbacks.

Describe the solution you'd like I would like to provide a custom instrumentation file like https://github.com/DataDog/dd-trace-php/blob/master/src/DDTrace/Integrations/Symfony/SymfonyIntegration.php from OUTSIDE dd-tracer-php package/source code.

It would require to be able to register custom integration name and class e.g. through env variables. Then IntegrationsLoader would need to add the integration to the list of supported integrations $this->integrations. and iterate through them here: https://github.com/DataDog/dd-trace-php/blob/master/src/DDTrace/Integrations/IntegrationsLoader.php#L137

This way frameworks could write their own integrations smoothly, without digging into dd-tracer internals.

Additional context Related to: https://github.com/DataDog/dd-trace-php/issues/1072

labbati commented 4 years ago

Hey @tmotyl, I answered to the #1072 to most of the points. Let me know if you need any further info.

jcerrada commented 3 years ago

Hi @labbati! I read on #1072 that you were going to test something called method level tracing in Q1 2021. Any news on that? Thanks!

labbati commented 3 years ago

This is part of our profiling effort, and we are shipping our first version of profiling/method-level-tracing as private beta this week. Definitely close to a GA release. I cannot provide a precise ETA, but at this point is closer to weeks rather than months.