This repository has been archived by the owner on Jan 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make sure auto start runs only once. Prevent tideways.load_library=1 …
…and composer auto start to interfere.
- Loading branch information
Showing
2 changed files
with
38 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,22 @@ | ||
<?php | ||
|
||
/** Check for auto starting the Profiler in Web and CLI (via Env Variable) */ | ||
if (ini_get("tideways.auto_start") || isset($_SERVER['TIDEWAYS_AUTO_START'])) { | ||
if (php_sapi_name() !== "cli") { | ||
/** | ||
* In Web context we auto start with the framework transaction name | ||
* configured in INI or ENV variable. | ||
*/ | ||
if (ini_get("tideways.transaction_function")) { | ||
\Tideways\Profiler::detectFrameworkTransaction(ini_get("tideways.transaction_function")); | ||
} else if (isset($_SERVER['TIDEWAYS_TRANSACTION_FUNCTION'])) { | ||
\Tideways\Profiler::detectFrameworkTransaction($_SERVER['TIDEWAYS_TRANSACTION_FUNCTION']); | ||
if (ini_get("tideways.auto_start") || isset($_SERVER["TIDEWAYS_AUTO_START"])) { | ||
if (\Tideways\Profiler::isStarted() === false) { | ||
if (php_sapi_name() !== "cli") { | ||
/** | ||
* In Web context we auto start with the framework transaction name | ||
* configured in INI or ENV variable. | ||
*/ | ||
if (ini_get("tideways.transaction_function")) { | ||
\Tideways\Profiler::detectFrameworkTransaction(ini_get("tideways.transaction_function")); | ||
} else if (isset($_SERVER['TIDEWAYS_TRANSACTION_FUNCTION'])) { | ||
\Tideways\Profiler::detectFrameworkTransaction($_SERVER["TIDEWAYS_TRANSACTION_FUNCTION"]); | ||
} | ||
\Tideways\Profiler::start(); | ||
} else if (php_sapi_name() === "cli" && !empty($_SERVER["TIDEWAYS_SESSION"]) && isset($_SERVER['argv'])) { | ||
\Tideways\Profiler::start(); | ||
\Tideways\Profiler::setTransactionName("cli:" . basename($_SERVER['argv'][0])); | ||
} | ||
\Tideways\Profiler::start(); | ||
} else if (php_sapi_name() === "cli" && !empty($_SERVER['TIDEWAYS_SESSION'])) { | ||
\Tideways\Profiler::start(); | ||
\Tideways\Profiler::setTransactionName("cli:" . basename($argv[0])); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
$_SERVER['TIDEWAYS_AUTO_START'] = 1; | ||
$_SERVER['TIDEWAYS_APIKEY'] = $argv[1]; | ||
|
||
require_once __DIR__. '/../vendor/autoload.php'; | ||
|
||
function bar() { | ||
} | ||
|
||
function foo() { | ||
for ($i = 0; $i < 10; $i++) { | ||
bar(); | ||
} | ||
} | ||
|
||
foo(); | ||
if (\Tideways\Profiler::isStarted()) { | ||
echo "Profiler started\n"; | ||
} else { | ||
echo "Profiler *NOT* started\n"; | ||
} |