hello,when i was Initializing the client and setting the instrumentation key ,i got the error like this,
my background is put magento2's log to Azure application insights,magento2 is a framework made by php,so I found this github project.Does anyone konw what i should to fix it out?
I'm new to php, i'm a python and java programmer,so if i made some Low-level mistakes, please tell me ,thank you so much!
[2019-10-23 03:03:42] main.ERROR: Client error: POST https://dc.services.visualstudio.com/v2/track resulted in a 400 Invalid instrumentation key response:
{"itemsReceived":1,"itemsAccepted":0,"errors":[{"index":0,"statusCode":400,"message":"Invalid instrumentation key"}]}
and my php code is like this:
<?php
use ApplicationInsights\Telemetry_Client;
$telemetryClient = new \ApplicationInsights\Telemetry_Client();
$context = $telemetryClient->getContext();
// Optionalmy
//$context->getSessionContext()->setId(session_id());
//$context->getUserContext()->setId('YOUR USER ID');
//$context->getApplicationContext()->setVer('YOUR VERSION');
//$context->getLocationContext()->setIp('YOUR IP');
// Start tracking
$telemetryClient->trackEvent('name of your event');
$telemetryClient->flush();
code Integrated into the magento2 is like this,
<?php
namespace Max\HelloWorld\Controller\Index;
use ApplicationInsights\Telemetry_Client;
use Magento\Framework\App\Action\Context;
use Magento\Framework\Logger\Handler\Debug;
use Magento\Framework\View\Result\PageFactory;
use Magento\Framework\Webapi\Exception;
use Monolog\Logger;
class Test extends \Magento\Framework\App\Action\Action
{
protected $_pageFactory;
public function __construct(
Context $context,
PageFactory $pageFactory
)
{
$this->_pageFactory = $pageFactory;
return parent::__construct($context);
}
public function execute()
{
echo "Hello World";
exit;
}
public function postLogger()
{
echo "Start";
$telemetryClient = new Telemetry_Client();
$context = $telemetryClient->getContext();
$context->setInstrumentationKey('myInstrumentationKey');
$telemetryClient->trackEvent("Zhou-loggerInfo", Logger::DEBUG);
//$telemetryClient->flush();
echo "End";
}
hello,when i was Initializing the client and setting the instrumentation key ,i got the error like this, my background is put magento2's log to Azure application insights,magento2 is a framework made by php,so I found this github project.Does anyone konw what i should to fix it out? I'm new to php, i'm a python and java programmer,so if i made some Low-level mistakes, please tell me ,thank you so much!
and my php code is like this:
use ApplicationInsights\Telemetry_Client;
$telemetryClient = new \ApplicationInsights\Telemetry_Client(); $context = $telemetryClient->getContext();
// Necessary $context->setInstrumentationKey('MYInstrumentationKey');
// Optionalmy //$context->getSessionContext()->setId(session_id()); //$context->getUserContext()->setId('YOUR USER ID'); //$context->getApplicationContext()->setVer('YOUR VERSION'); //$context->getLocationContext()->setIp('YOUR IP');
// Start tracking $telemetryClient->trackEvent('name of your event'); $telemetryClient->flush();
code Integrated into the magento2 is like this,
namespace Max\HelloWorld\Controller\Index;
use ApplicationInsights\Telemetry_Client; use Magento\Framework\App\Action\Context; use Magento\Framework\Logger\Handler\Debug; use Magento\Framework\View\Result\PageFactory; use Magento\Framework\Webapi\Exception; use Monolog\Logger;
class Test extends \Magento\Framework\App\Action\Action { protected $_pageFactory;