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

[opentelemetry-php-contrib] Add Twig instrumentation

Open cmelius opened this issue 3 weeks ago • 8 comments

in my company we needed a deeper look at how it used twig templates and where it's wasting time. It is a website running on CraftCMS / PHP 8.4.

I could not really find good traces with the standard instrumentations so I built my own https://github.com/cmelius/opentelemetry-auto-twig

I am not really sure if this is needed here, if everything was done right. I coded it fast. There may be things missing, but it's working for me. Just wanted to drop it here in case somebody could use it.

cmelius avatar Dec 02 '25 13:12 cmelius

@cmelius if you'd like to contribute to the registry, please do! We'd be happy to list it.

cartermp avatar Dec 02 '25 14:12 cartermp

@cartermp ok, cool. I would like to. But did you look at the code? I don't want to submit something that does not meet the projects requirements.

cmelius avatar Dec 02 '25 14:12 cmelius

nevermind, I just contributed ... let's see ;-)

https://github.com/open-telemetry/opentelemetry.io/pull/8563

cmelius avatar Dec 02 '25 15:12 cmelius

Hi @cmelius, thanks for adding this to the registry.

We're already following-up on open-telemetry/opentelemetry.io#8563, but I think we could also keep this issue open and transfer it to the open-telemetry/opentelemetry-php repo — let me explain why:

You've previously asked whether we'd had a chance to look at the code, but detailed implementation reviews and language-specific feedback aren't something we typically do in the opentelemetry.io repository.

Community-maintained instrumentations for OpenTelemetry PHP can also be published under the open-telemetry/opentelemetry-php-contrib repo. If that's something you'd be open to in the future, we can transfer this issue there. I'm sure the @open-telemetry/php-approvers and @open-telemetry/php-maintainers would not only guide you on how to publish your instrumentation in that repo, but also provide a proper review of the PHP code.


That said, and independently of my role here in the opentelemetry.io repository, PHP is a language I've worked with before and it definitely caught my attention. I'll take a look at the code when I have some free time, and you can expect me to interact with it in the future, either in your repo or in the opentelemetry-php-contrib if you decide to publish it there.

vitorvasc avatar Dec 03 '25 10:12 vitorvasc

Hey @vitorvasc sure, If you think it would make sense to transfer it to the open-telemetry/opentelemetry-php repo, go ahead. I got what I needed from my instrumentation and just wanted to give back to the community. Maybe it can help others. I think it's a good idea to transfer it as I may not have the time to maintain the repo in the future.

cmelius avatar Dec 03 '25 11:12 cmelius

Hi @cmelius and welcome to opentelemetry-php. I've done a quick scan of your code, and it looks pretty sensible. Would you like to submit it as a PR against https://github.com/open-telemetry/opentelemetry-php-contrib so that it can be more thoroughly reviewed? (just a couple of nits from me, but it looks good enough for a 0.1 release). thanks!

brettmc avatar Dec 04 '25 10:12 brettmc

Hi @brettmc and thanks. Yes, I think that's a good idea. Will try to find time. This is where I look on how to do it, right?

cmelius avatar Dec 04 '25 15:12 cmelius

ok, I opened a PR here: https://github.com/open-telemetry/opentelemetry-php-contrib/pull/486

let's see what happens.

cmelius avatar Dec 12 '25 12:12 cmelius