getsentry / sentry-php

The official PHP SDK for Sentry (sentry.io)
https://sentry.io
MIT License
1.83k stars 450 forks source link

Automatic instrumentation #1252

Closed agildehaus closed 1 year ago

agildehaus commented 2 years ago

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?

github-actions[bot] commented 2 years ago

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 🥀

ste93cry commented 2 years ago

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?

smeubank commented 2 years ago

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.

Jean85 commented 2 years ago

@smeubank

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

agildehaus commented 2 years ago

In addition,

robertoandrade commented 2 years ago

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 commented 2 years ago

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.

Jean85 commented 2 years ago

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.

github-actions[bot] commented 1 year ago

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 🥀

bondeg commented 1 year ago

Any updates?

cleptric commented 1 year ago

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.