【问题标题】:Blackfire profiling not workingBlackfire 分析不起作用
【发布时间】:2016-03-04 00:22:26
【问题描述】:

所以我跟着these instructions 寻找我的流浪者盒子,一切似乎都很好,我的意思是它正在运行。它已经配置了它的服务器 ID 和服务器令牌。

然后我按照同一页面上的说明安装了 PHP Probe,并在完成后重新启动了 apache2。然后我做了composer require blackfire/php-sdk,最后在我的代码中我做了:

$probe = $blackfire->createProbe();

// some PHP code you want to profile

$blackfire->endProbe($probe);
dd('End here.'); // Laravels die and dump function.

据我所知,我做的一切都是正确的。然后,在我的控制台中我做了:

vagrant@scotchbox:/var/www$ php artisan fetch_eve_online_region_type_history_information


  [Blackfire\Exception\ApiException]                                                                                                      
  401:  while calling GET https://blackfire.io/api/v1/collab-tokens [context: NULL] [headers: array (                                     
    0 => 'Authorization: Basic xxxxxx=',                                                                                                       
    1 => 'X-Blackfire-User-Agent: Blackfire PHP SDK/1.0',                                                                                 
  )]

 // where xxxx is some kind of authentication token that looks different from what I gave as my server id and token.

呃 .... 好的,所以文档说明如果出现问题,请检查日志:

vagrant@scotchbox:/var/www$ cat /var/log/blackfire/agent.log
vagrant@scotchbox:/var/www$ 

日志中没有任何内容....

我做错了什么?

【问题讨论】:

  • 我已经看到你在 GitHub 上为此创建的问题,建议直接与他们联系。如果这里有一般问题或陷阱,您能否分享您为解决问题所做的工作?这将帮助其他有同样问题的人(比如我)。谢谢

标签: php blackfire


【解决方案1】:

不是真正的解决方案,而是一种解决方法,直到我们听到更多关于如何实际解决它的信息。

我直接在代码中手动添加了客户端凭据,它为我解决了这个问题:

    $config = new \Blackfire\ClientConfiguration();
    $config->setClientId('...your _client_ id...');
    $config->setClientToken('...your _client_ token...');

    $blackfire = new \Blackfire\Client($config);

我在错误中看到的字符串是Authorization: Basic Og==Og== 只是一个base64 编码的字符串:,它暗示用户名/密码(或在这种情况下是id/token?)自动查找失败并且授权是不可能的。这就是手动提供详细信息的原因。

【讨论】:

    【解决方案2】:

    有点晚了,但也许将来有人会需要它。 将 HOME 环境变量添加到 apache 的 vhost 文件中,以便 blackfire 找到 ~/.blackfire.ini 解决它。

    <VirtualHost hostname:80>
        ...
        SetEnv HOME /Users/me #i'm running macOS, on linux would be /home/me
        ...
    </VirtualHost>
    

    【讨论】:

    • 如果你的机器上有很多虚拟主机,你也可以将它添加到你的主 APACHE 配置中,这将一次性修复所有这些。
    【解决方案3】:

    考虑您的探针配置是正确的(server_id 和 server_tokens),您可以从浏览器配置文件,使用 PHP SDK(phpunit 与 blackfire 集成)您必须配置客户端:

    • apt-get install blackfire-agent
    • blackfire config 您将提示输入 BLACKFIRE_CLIENT_IDBLACKFIRE_CLIENT_TOKEN

      您也可以登录此api/v1/collab-tokens 来测试您的客户端凭据 username=>BLACKFIRE_CLIENT_ID , password=>BLACKFIRE_CLIENT_TOKEN

    客户端的配置文件位置:/root/.blackfire.ini

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-24
      • 2016-04-19
      • 2017-04-20
      • 1970-01-01
      相关资源
      最近更新 更多