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

blackfire.yaml not taken into account profiling through custom code #54

Open
thomasdiluccio opened this issue Mar 12, 2021 · 2 comments

Comments

@thomasdiluccio
Copy link
Contributor

thomasdiluccio commented Mar 12, 2021

I have to redefine the custom metrics specified within the .blackfire.yaml whenever I need to use custom code for that.
But, I don't need to provide any authentification. I would expect some kind of "all or nothing" behaviour, requiring me to redefine everything, or nothing.

use Blackfire\Client;
use Blackfire\Probe;
use Blackfire\Profile;
use Blackfire\Profile\Configuration;
use Blackfire\Profile\Metric;

// ...

$this->blackfireClient = new Client();
$this->config = new Configuration();

$this->config->defineMetric((new Metric(
    'my_metric',
    ['=App\\FooBundle\\Entity\\Repository\\BarRepository::findStuff']
)));
@lolautruche
Copy link
Contributor

Hi @thomasdiluccio

Can you please provide more context?
Does this happen only when you define a metric with Blackfire\Profile\Metric?

@lolautruche
Copy link
Contributor

OK I am able to reproduce it.
When a metric is being defined programmatically, the .blackfire.yaml is ignored.

require __DIR__.'/vendor/autoload.php';

$blackfireClient = new \Blackfire\Client();
$config = new \Blackfire\Profile\Configuration();
$config->setTitle('Test SDK issue');
$config->setMetadata('issue', 'https://github.com/blackfireio/php-sdk/issues/53');
$config->setMetadata('skip_timeline', 'true');
$config->defineMetric((new \Blackfire\Profile\Metric(
    'my_metric',
    ['=foo']
)));
$probe = $blackfireClient->createProbe($config);

function foo()
{
    sleep(2);
    echo "Hello world!\n";
}

foo();

echo $blackfireClient->endProbe($probe)->getUrl()."\n";

@iamluc Is this an expected behavior?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants