From fecf8af44d8c8304e17fb2929ac546398967be28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Be=C5=88o?= Date: Tue, 24 May 2016 17:17:43 +0200 Subject: [PATCH 1/2] Fixes of PHPDoc comments --- .../Channel/Telemetry_Channel.php | 2 +- ApplicationInsights/Telemetry_Client.php | 106 +++++++++--------- ApplicationInsights/Telemetry_Context.php | 36 +++--- 3 files changed, 72 insertions(+), 72 deletions(-) diff --git a/ApplicationInsights/Channel/Telemetry_Channel.php b/ApplicationInsights/Channel/Telemetry_Channel.php index 0464c93..75fc6bf 100644 --- a/ApplicationInsights/Channel/Telemetry_Channel.php +++ b/ApplicationInsights/Channel/Telemetry_Channel.php @@ -82,7 +82,7 @@ public function getSerializedQueue() /** * Writes the item into the sending queue for subsequent processing. * @param mixed $data The telemetry item to send. - * @param ApplicationInsights\Telemetry_Context $telemetryContext The context to use. + * @param \ApplicationInsights\Telemetry_Context $telemetryContext The context to use. */ public function addToQueue($data, \ApplicationInsights\Telemetry_Context $telemetryContext) { diff --git a/ApplicationInsights/Telemetry_Client.php b/ApplicationInsights/Telemetry_Client.php index 78efe43..445e149 100644 --- a/ApplicationInsights/Telemetry_Client.php +++ b/ApplicationInsights/Telemetry_Client.php @@ -2,55 +2,55 @@ namespace ApplicationInsights; /** - * Main object used for interacting with the Application Insights service. + * Main object used for interacting with the Application Insights service. */ class Telemetry_Client { /** * The telemetry context this client will use - * @var ApplicationInsights\Channel\Telemetry_Context + * @var \ApplicationInsights\Telemetry_Context */ private $_context; - + /** * The telemetry channel this client will use - * @var ApplicationInsights\Channel\Telemetry_Channel + * @var \ApplicationInsights\Channel\Telemetry_Channel */ private $_channel; - + /** * Initializes a new Telemetry_Client. - * @param ApplicationInsights\Telemetry_Context $context - * @param ApplicationInsights\Channel\Telemetry_Channel $channel + * @param \ApplicationInsights\Telemetry_Context $context + * @param \ApplicationInsights\Channel\Telemetry_Channel $channel */ public function __construct(Telemetry_Context $context = NULL, Channel\Telemetry_Channel $channel = NULL) { $this->_context = ($context == NULL) ? new Telemetry_Context() : $context; $this->_channel = ($channel == NULL) ? new Channel\Telemetry_Channel() : $channel; } - + /** - * Returns the Telemetry_Context this Telemetry_Client is using. - * @return ApplicationInsights\Telemetry_Context + * Returns the Telemetry_Context this Telemetry_Client is using. + * @return \ApplicationInsights\Telemetry_Context */ public function getContext() { return $this->_context; } - + /** - * Returns the Telemetry_Channel this Telemetry_Client is using. - * @return ApplicationInsights\Channel\Telemetry_Channel + * Returns the Telemetry_Channel this Telemetry_Client is using. + * @return \ApplicationInsights\Channel\Telemetry_Channel */ public function getChannel() { return $this->_channel; } - + /** * Sends an Page_View_Data to the Application Insights service. * @param string $name The friendly name of the page view. - * @param string $url The url of the page view. + * @param string $url The url of the page view. * @param int duration The duration in milliseconds of the page view. * @param array $properties An array of name to value pairs. Use the name as the index and any string as the value. * @param array $measurements An array of name to double pairs. Use the name as the index and any double as the value. @@ -69,10 +69,10 @@ public function trackPageView($name, $url, $duration = 0, $properties = NULL, $m { $data->setMeasurements($measurements); } - + $this->_channel->addToQueue($data, $this->_context); } - + /** * Sends an Metric_Data to the Application Insights service. * @param string $name Name of the metric. @@ -80,8 +80,8 @@ public function trackPageView($name, $url, $duration = 0, $properties = NULL, $m * @param \ApplicationInsights\Channel\Data_Point_Type::Value $type The type of value being sent. * @param int $count The number of samples. * @param double $min The minimum of the samples. - * @param double $max The maximum of the samples. - * @param double $stdDev The standard deviation of the samples. + * @param double $max The maximum of the samples. + * @param double $stdDev The standard deviation of the samples. * @param array $properties An array of name to value pairs. Use the name as the index and any string as the value. */ public function trackMetric($name, $value, $type = NULL, $count = NULL, $min = NULL, $max = NULL, $stdDev = NULL, $properties = NULL) @@ -94,20 +94,20 @@ public function trackMetric($name, $value, $type = NULL, $count = NULL, $min = N $dataPoiint->setMin($min); $dataPoiint->setMax($max); $dataPoiint->setStdDev($stdDev); - + $data = new Channel\Contracts\Metric_Data(); $data->setMetrics(array($dataPoiint)); if ($properties != NULL) { $data->setProperties($properties); } - + $this->_channel->addToQueue($data, $this->_context); } - + /** * Sends an Event_Data to the Application Insights service. - * @param string $name + * @param string $name * @param array $properties An array of name to value pairs. Use the name as the index and any string as the value. * @param array $measurements An array of name to double pairs. Use the name as the index and any double as the value. */ @@ -123,10 +123,10 @@ public function trackEvent($name, $properties = NULL, $measurements = NULL) { $data->setMeasurements($measurements); } - + $this->_channel->addToQueue($data, $this->_context); } - + /** * Sends an Message_Data to the Application Insights service. * @param string $message The trace message. @@ -136,21 +136,21 @@ public function trackMessage($message, $properties = NULL) { $data = new Channel\Contracts\Message_Data(); $data->setMessage($message); - + if ($properties != NULL) { $data->setProperties($properties); } - + $this->_channel->addToQueue($data, $this->_context); } - + /** * Sends a Request_Data to the Application Insights service. * @param string $name A friendly name of the request. * @param string $url The url of the request. * @param int $startTime The timestamp at which the request started. - * @param int $durationInMilliseconds The duration, in milliseconds, of the request. + * @param int $durationInMilliseconds The duration, in milliseconds, of the request. * @param int $httpResponseCode The response code of the request. * @param bool $isSuccessful Whether or not the request was successful. * @param array $properties An array of name to value pairs. Use the name as the index and any string as the value. @@ -163,12 +163,12 @@ public function trackRequest($name, $url, $startTime, $durationInMilliseconds = /** * Begin a Request_Data to the Application Insights service. This request is not sent until an @see endRequest call is made, passing this request. - * + * * @param string $name A friendly name of the request. * @param string $url The url of the request. * @param int $startTime The timestamp at which the request started. - * @return an initialized Request_Data, which can be sent by using @see endRequest - */ + * @return \ApplicationInsights\Channel\Contracts\Request_Data an initialized Request_Data, which can be sent by using @see endRequest + */ public function beginRequest($name, $url, $startTime ) { $data = new Channel\Contracts\Request_Data(); @@ -177,41 +177,41 @@ public function beginRequest($name, $url, $startTime ) $data->setName($name); $data->setUrl($url); $data->setStartTime(Channel\Contracts\Utils::returnISOStringForTime($startTime)); - + return $data; } - + /** * Sends a Request_Data created by @see beginRequest to the Application Insights service. - * @param int $durationInMilliseconds The duration, in milliseconds, of the request. + * @param int $durationInMilliseconds The duration, in milliseconds, of the request. * @param int $httpResponseCode The response code of the request. * @param bool $isSuccessful Whether or not the request was successful. * @param array $properties An array of name to value pairs. Use the name as the index and any string as the value. * @param array $measurements An array of name to double pairs. Use the name as the index and any double as the value. - */ + */ public function endRequest( Channel\Contracts\Request_Data $request, $durationInMilliseconds = 0, $httpResponseCode = 200, $isSuccessful = true, $properties = NULL, $measurements = NULL ) { $request->setResponseCode($httpResponseCode); $request->setSuccess($isSuccessful); - + $request->setDuration(Channel\Contracts\Utils::convertMillisecondsToTimeSpan($durationInMilliseconds)); - + if ($properties != NULL) { $request->setProperties($properties); } - + if ($measurements != NULL) { $request->setMeasurements($measurements); } - + $this->_channel->addToQueue($request, $this->_context); } - + /** * Sends an Exception_Data to the Application Insights service. - * @param Exception $ex The exception to send + * @param \Exception $ex The exception to send * @param array $properties An array of name to value pairs. Use the name as the index and any string as the value. * @param array $measurements An array of name to double pairs. Use the name as the index and any double as the value. */ @@ -225,12 +225,12 @@ public function trackException(\Exception $ex, $properties = NULL, $measurements $details->setHasFullStack(true); $stackFrames = array(); - + // First stack frame is in the root exception $frameCounter = 0; foreach ($ex->getTrace() as $currentFrame) { - $stackFrame = new Channel\Contracts\Stack_Frame(); + $stackFrame = new Channel\Contracts\Stack_Frame(); if (array_key_exists('class', $currentFrame) == true) { $stackFrame->setAssembly($currentFrame['class']); @@ -247,35 +247,35 @@ public function trackException(\Exception $ex, $properties = NULL, $measurements { $stackFrame->setMethod($currentFrame['function']); } - + // Make it a string to force serialization of zero $stackFrame->setLevel(''.$frameCounter); - + array_unshift($stackFrames, $stackFrame); $frameCounter++; } - + $details->setParsedStack($stackFrames); - + $data = new Channel\Contracts\Exception_Data(); $data->setHandledAt('UserCode'); $data->setExceptions(array($details)); - + if ($properties != NULL) { $data->setProperties($properties); } - + if ($measurements != NULL) { $data->setMeasurements($measurements); } - + $this->_channel->addToQueue($data, $this->_context); } - + /** - * Flushes the underlying Telemetry_Channel queue. + * Flushes the underlying Telemetry_Channel queue. */ public function flush() { diff --git a/ApplicationInsights/Telemetry_Context.php b/ApplicationInsights/Telemetry_Context.php index 7840b3a..8ae5a23 100644 --- a/ApplicationInsights/Telemetry_Context.php +++ b/ApplicationInsights/Telemetry_Context.php @@ -14,37 +14,37 @@ class Telemetry_Context /** * The device context - * @var ApplicationInsights\Channel\Contracts\Device + * @var \ApplicationInsights\Channel\Contracts\Device */ private $_deviceContext; /** * The application context - * @var ApplicationInsights\Channel\Contracts\Application + * @var \ApplicationInsights\Channel\Contracts\Application */ private $_applicationContext; /** * The user context - * @var ApplicationInsights\Channel\Contracts\User + * @var \ApplicationInsights\Channel\Contracts\User */ private $_userContext; /** * The location context - * @var ApplicationInsights\Channel\Contracts\Location + * @var \ApplicationInsights\Channel\Contracts\Location */ private $_locationContext; /** * The operation context - * @var ApplicationInsights\Channel\Contracts\Operation + * @var \ApplicationInsights\Channel\Contracts\Operation */ private $_operationContext; /** * The session context - * @var ApplicationInsights\Channel\Contracts\Session + * @var \ApplicationInsights\Channel\Contracts\Session */ private $_sessionContext; @@ -102,7 +102,7 @@ public function setInstrumentationKey($instrumentationKey) /** * The device context object. Allows you to set properties that will be attached to all telemetry about the device. - * @return ApplicationInsights\Channel\Contracts\Device + * @return \ApplicationInsights\Channel\Contracts\Device */ public function getDeviceContext() { @@ -111,7 +111,7 @@ public function getDeviceContext() /** * Sets device context object. Allows you to set properties that will be attached to all telemetry about the device. - * @param ApplicationInsights\ApplicationInsights\Channel\Contracts\Device $deviceContext + * @param \ApplicationInsights\Channel\Contracts\Device $deviceContext */ public function setDeviceContext(Channel\Contracts\Device $deviceContext) { @@ -120,7 +120,7 @@ public function setDeviceContext(Channel\Contracts\Device $deviceContext) /** * The application context object. Allows you to set properties that will be attached to all telemetry about the application. - * @return ApplicationInsights\Channel\Contracts\Application + * @return \ApplicationInsights\Channel\Contracts\Application */ public function getApplicationContext() { @@ -129,7 +129,7 @@ public function getApplicationContext() /** * Sets application context object. Allows you to set properties that will be attached to all telemetry about the application. - * @param ApplicationInsights\Channel\Contracts\Application $applicationContext + * @param \ApplicationInsights\Channel\Contracts\Application $applicationContext */ public function setApplicationContext(Channel\Contracts\Application $applicationContext) { @@ -138,7 +138,7 @@ public function setApplicationContext(Channel\Contracts\Application $application /** * The user context object. Allows you to set properties that will be attached to all telemetry about the user. - * @return ApplicationInsights\Channel\Contracts\User + * @return \ApplicationInsights\Channel\Contracts\User */ public function getUserContext() { @@ -147,7 +147,7 @@ public function getUserContext() /** * Set user context object. Allows you to set properties that will be attached to all telemetry about the user. - * @param ApplicationInsights\Channel\Contracts\User $userContext + * @param \ApplicationInsights\Channel\Contracts\User $userContext */ public function setUserContext(Channel\Contracts\User $userContext) { @@ -156,7 +156,7 @@ public function setUserContext(Channel\Contracts\User $userContext) /** * The location context object. Allows you to set properties that will be attached to all telemetry about the location. - * @return ApplicationInsights\Channel\Contracts\Location + * @return \ApplicationInsights\Channel\Contracts\Location */ public function getLocationContext() { @@ -165,7 +165,7 @@ public function getLocationContext() /** * Set location context object. Allows you to set properties that will be attached to all telemetry about the location. - * @param ApplicationInsights\Channel\Contracts\Location $locationContext + * @param \ApplicationInsights\Channel\Contracts\Location $locationContext */ public function setLocationContext(Channel\Contracts\Location $locationContext) { @@ -174,7 +174,7 @@ public function setLocationContext(Channel\Contracts\Location $locationContext) /** * The operation context object. Allows you to set properties that will be attached to all telemetry about the operation. - * @return ApplicationInsights\Channel\Contracts\Location + * @return \ApplicationInsights\Channel\Contracts\Operation */ public function getOperationContext() { @@ -183,7 +183,7 @@ public function getOperationContext() /** * Set operation context object. Allows you to set properties that will be attached to all telemetry about the operation. - * @param ApplicationInsights\Channel\Contracts\Operation $operationContext + * @param \ApplicationInsights\Channel\Contracts\Operation $operationContext */ public function setOperationContext(Channel\Contracts\Operation $operationContext) { @@ -192,7 +192,7 @@ public function setOperationContext(Channel\Contracts\Operation $operationContex /** * The session context object. Allows you to set properties that will be attached to all telemetry about the session. - * @return ApplicationInsights\Channel\Contracts\Session + * @return \ApplicationInsights\Channel\Contracts\Session */ public function getSessionContext() { @@ -201,7 +201,7 @@ public function getSessionContext() /** * Set session context object. Allows you to set properties that will be attached to all telemetry about the session. - * @param ApplicationInsights\Channel\Contracts\Session $sessionContext + * @param \ApplicationInsights\Channel\Contracts\Session $sessionContext */ public function setSessionContext(Channel\Contracts\Session $sessionContext) { From 62c6205f535a1dbe81a0412d485484614003ea23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Be=C5=88o?= Date: Tue, 24 May 2016 17:20:25 +0200 Subject: [PATCH 2/2] Fix of Unknown class error when trackMetric provided with type argument = null --- ApplicationInsights/Telemetry_Client.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationInsights/Telemetry_Client.php b/ApplicationInsights/Telemetry_Client.php index 445e149..c25a0fc 100644 --- a/ApplicationInsights/Telemetry_Client.php +++ b/ApplicationInsights/Telemetry_Client.php @@ -89,7 +89,7 @@ public function trackMetric($name, $value, $type = NULL, $count = NULL, $min = N $dataPoiint = new Channel\Contracts\Data_Point(); $dataPoiint->setName($name); $dataPoiint->setValue($value); - $dataPoiint->setKind($type == NULL ? Data_Point_Type::Aggregation : $type); + $dataPoiint->setKind($type == NULL ? Channel\Contracts\Data_Point_Type::Aggregation : $type); $dataPoiint->setCount($count); $dataPoiint->setMin($min); $dataPoiint->setMax($max);