sentry-php icon indicating copy to clipboard operation
sentry-php copied to clipboard

Automatic instrumentation

Open agildehaus opened this issue 4 years ago • 8 comments

Many other APM services offer automatic instrumentation for PHP via an installable extension (a .so file). For those of us running complicated frameworkless PHP applications, who don't want to add instrumentation to our code, this seems to be the way to go.

Does Sentry have any plans related to such an offering?

agildehaus avatar Oct 20 '21 05:10 agildehaus

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

github-actions[bot] avatar Jan 12 '22 21:01 github-actions[bot]

This is a good question that went unnoticed 😞 As an OSS contributor to this project I don't have the answer. @mitsuhiko maybe you have some details that you want/can share with us on this?

ste93cry avatar Jan 12 '22 22:01 ste93cry

hi @agildehaus

would you mind providing some of the examples of other APM services which provide this form of auto-instrumentation? I can use this to try and trigger a conversation internally.

smeubank avatar Feb 07 '22 14:02 smeubank

@smeubank

  • NewRelic: https://docs.newrelic.com/docs/apm/agents/php-agent/installation/php-agent-installation-overview/
  • DataDog: https://docs.datadoghq.com/integrations/php/#overview

It often requires an extension, so it's pretty specialized.

Jean85 avatar Feb 07 '22 15:02 Jean85

In addition,

  • AppDynamics: https://docs.appdynamics.com/20.x/en/application-monitoring/install-app-server-agents/php-agent/install-the-php-agent
  • SolarWinds: https://documentation.solarwinds.com/en/success_center/appoptics/content/kb/apm_tracing/php.htm
  • Elastic APM: https://www.elastic.co/guide/en/apm/agent/php/current/index.html
  • Atatus: https://docs.atatus.com/docs/application-monitoring/php-agent/overview.html

agildehaus avatar Feb 10 '22 21:02 agildehaus

any news on this? having to start transactions and spans for every method call is far from ideal... was thinking of hacking something together with magic methods and monkey patching / class loading to do something like renaming all methods in a class to a __instrumented_ prefix type of convention and via __call magic methods take over the responsibility of the original method and delegate over to the renamed __instrumented_ prefixed counterpart.

Is there no "open instrumentation" framework that does this? I once heard and started using something like that for a node.js that did automatic instrumentation in many languages (they have PHP but don't support automatic instrumentation yet: https://github.com/open-telemetry/opentelemetry-php) - that was also neat because you could use a single API to instrument and then pump the data out to whatever provider you'd like using their "plugin" model.

Perhaps once they do support autoinstrumentation and since they support Newrelic, DataDog, Sentry amongst others, it would be an alternative if it doesn't get implemented by each provider individually on their SDKs.

robertoandrade avatar Aug 12 '22 22:08 robertoandrade

So the guys from Sqreen (now part of DataDog) published a pretty in-depth analytics on how they built theirs https://blog.sqreen.com/dynamic-instrumentation-agent-php/

And similar to opentelemetry.io like I mentioned earlier, seems like opencensus.io does something similar by implementing a PECL extension to do some level of automatic instrumentation (https://opencensus.io/api/php/using-the-extension/), you still need to tell which classes/methods/functions you want to instrument but it's a path in the right direction.

robertoandrade avatar Aug 12 '22 23:08 robertoandrade

Using an extension is definitely the way to go: monkey-patching code would make many users recoil and flee from such a tool, since it would mess with a lot of stuff.

OTOH, it requires a completely different skillset to be built, and it may interfere with other extensions doing the same.

Jean85 avatar Aug 22 '22 08:08 Jean85

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

github-actions[bot] avatar Sep 27 '22 00:09 github-actions[bot]

Any updates?

bondeg avatar Mar 23 '23 09:03 bondeg

You can try out Profiling for PHP https://docs.sentry.io/platforms/php/profiling/, which will give you lots of insights out of the box.

No further plans at this point.

cleptric avatar Mar 23 '23 10:03 cleptric