Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for the CLI SAPI #422

Merged
merged 13 commits into from
May 9, 2019
Merged

Add support for the CLI SAPI #422

merged 13 commits into from
May 9, 2019

Conversation

SammyK
Copy link
Contributor

@SammyK SammyK commented Apr 30, 2019

Description

This PR adds support for tracing custom PHP CLI scripts and Laravel Artisan. This feature is disabled by default. To enable, set the env var DD_TRACE_CLI_ENABLED=true.

This PR adds support for the CLI SAPI by removing the PHP_SAPI and getenv('APP_ENV') checks.

Readiness checklist

@SammyK SammyK added 🏆 enhancement A new feature or improvement 🎉 new-integration A new integration feature-request labels Apr 30, 2019
@SammyK SammyK added this to the 0.21.0 milestone Apr 30, 2019
Copy link
Contributor

@pawelchcki pawelchcki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like we still should make this optional otherwise people will start getting weird traces from Artisan or composer commands. WDYT ?

^ Other than that the change looks good :)

@SammyK
Copy link
Contributor Author

SammyK commented May 1, 2019

otherwise people will start getting weird traces from Artisan

I'm not sure what kind of weird traces you're referring to. The traces from the CLI look similar to the ones from other SAPI's. :)

or composer commands

Very good point! Yeah, we should certainly make sure the tracer doesn't get run during a Composer command. I'll look into this. :)

@pawelchcki
Copy link
Contributor

pawelchcki commented May 1, 2019

otherwise people will start getting weird traces from Artisan

I'm not sure what kind of weird traces you're referring to. The traces from the CLI look similar to the ones from other SAPI's. :)

By weird I meant unexpected traces of things like:

php artisan optimize
php artisan config:cache
php artisan route:cache

I have a strong suspicion that for CLI sapi the tracing needs to be opt in, since I'm not sure in other traces we do handle things like cron job run scripts etc by default.

Its also probably more of a product quesiton than engineering one though :)

@SammyK
Copy link
Contributor Author

SammyK commented May 1, 2019

Very good point. Certainly "disabled by default" would make sense here. Although keeping the on-boarding experience in mind, I would err on the side of keeping things enabled by default so that people don't run into problems with seeing their first traces in the UI. And then having an option to disable tracing from the CLI. Something like DD_TRACE_CLI_ENABLED which defaults to true.

Since, as you stated, this impacts product, maybe we could have @priyanshi-gupta or @palazzem weigh in here? :)

@SammyK SammyK modified the milestones: 0.21.0, 0.22.0 May 1, 2019
@SammyK SammyK force-pushed the sammyk/cli-sapi branch 2 times, most recently from fc90e86 to 6519226 Compare May 1, 2019 21:13
@SammyK
Copy link
Contributor Author

SammyK commented May 1, 2019

I'm going to mark this as a WIP for now since there's quite a few open questions. The CLI traces are fairly basic and nondescript at the moment.

Screen Shot 2019-05-01 at 2 16 00 PM

And running a Composer command generates two traces for some reason. Ultimately we'll need to disable tracing when running a Composer command.

Also - I'm curious as to what extra metadata we should add to the root span. Perhaps the script name? I'm open to ideas! :)

@SammyK SammyK removed the request for review from labbati May 1, 2019 21:22
Copy link
Member

@labbati labbati left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work on this! Thanks @SammyK!

WRT ON/OFF by default I would go with OFF by default and activate it through env DD_TRACE_CLI_ENABLED=true. Not only because of composer, but users run some php scripts almost for sure and this may lead to unexpected behaviors.

@SammyK SammyK modified the milestones: 0.22.0, 0.23.0 May 6, 2019
@SammyK
Copy link
Contributor Author

SammyK commented May 6, 2019

I'm moving this to 0.23.0 milestone to allow us time get this right without blocking the release of PHP 7.3 support. :)

@SammyK SammyK mentioned this pull request May 7, 2019
2 tasks
@SammyK SammyK mentioned this pull request May 8, 2019
2 tasks
Copy link
Member

@labbati labbati left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 love it! LGTM 😄

@SammyK SammyK dismissed pawelchcki’s stale review May 9, 2019 13:56

Suggestions have been implemented :)

@SammyK SammyK merged commit 9cfcdd0 into master May 9, 2019
@SammyK SammyK deleted the sammyk/cli-sapi branch May 9, 2019 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏆 enhancement A new feature or improvement feature-request 🎉 new-integration A new integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants