PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

API Examples

This topic lists some examples of using the Zend_Service_WindowsAzure_Diagnostics_Manager class. Other features are available in the download package, as well as a detailed API documentation of those features.

Checking if a diagnostics configuration for the current role instance exists

Using the following code, you can check if a diagnostics configuration for the current role instance exists.

Example 899. Checking if a diagnostics configuration for the current role instance exists

<?php
/** Zend_Service_WindowsAzure_Storage_Blob */
require_once 'Zend/Service/WindowsAzure/Storage/Blob.php';

/** Zend_Service_WindowsAzure_Diagnostics_Manager */
require_once 'Zend/Service/WindowsAzure/Diagnostics/Manager.php';

$storageClient = new Zend_Service_WindowsAzure_Storage_Blob();
$manager = new Zend_Service_WindowsAzure_Diagnostics_Manager($storageClient);

$configurationExists $manager->configurationForCurrentRoleInstanceExists();

echo 
'The configuration ' . ($configurationExists 'exists' 'does not exist';

Loading the current role instance diagnostics configuration

Using the following code, you can load the current role instance diagnostics configuration.

Example 900. Loading the current role instance diagnostics configuration

<?php
/** Zend_Service_WindowsAzure_Storage_Blob */
require_once 'Zend/Service/WindowsAzure/Storage/Blob.php';

/** Zend_Service_WindowsAzure_Diagnostics_Manager */
require_once 'Zend/Service/WindowsAzure/Diagnostics/Manager.php';

$storageClient = new Zend_Service_WindowsAzure_Storage_Blob();
$manager = new Zend_Service_WindowsAzure_Diagnostics_Manager($storageClient);

$configuration $manager->getConfigurationForCurrentRoleInstance();

Storing the current role instance diagnostics configuration

Using the following code, you can store the current role instance diagnostics configuration.

Example 901. Storing the current role instance diagnostics configuration

<?php
/** Zend_Service_WindowsAzure_Storage_Blob */
require_once 'Zend/Service/WindowsAzure/Storage/Blob.php';

/** Zend_Service_WindowsAzure_Diagnostics_Manager */
require_once 'Zend/Service/WindowsAzure/Diagnostics/Manager.php';

$storageClient = new Zend_Service_WindowsAzure_Storage_Blob();
$manager = new Zend_Service_WindowsAzure_Diagnostics_Manager($storageClient);

$configuration // ...;
$manager->setConfigurationForCurrentRoleInstance($configuration);

Subscribing to a performance counter

Using the following code, you can subscribe to a performance counter.

Example 902. Subscribing to a performance counter

<?php
/** Zend_Service_WindowsAzure_Storage_Blob */
require_once 'Zend/Service/WindowsAzure/Storage/Blob.php';

/** Zend_Service_WindowsAzure_Diagnostics_Manager */
require_once 'Zend/Service/WindowsAzure/Diagnostics/Manager.php';

$storageClient = new Zend_Service_WindowsAzure_Storage_Blob();
$manager = new Zend_Service_WindowsAzure_Diagnostics_Manager($storageClient);

$configuration $manager->getConfigurationForCurrentRoleInstance();

// Subscribe to \Processor(*)\% Processor Time
$configuration->DataSources->PerformanceCounters->addSubscription('\Processor(*)\% Processor Time'1);

$manager->setConfigurationForCurrentRoleInstance($configuration);

Getting the current role instance id

The current role instance id is defined in the server variable RdRoleId. It will only be available when the application is run in Development Fabric or Windows Azure Fabric.

Example 903. Getting the current role instance id

<?php
echo 'The role instance id is ' $_SERVER['RdRoleId'];

Zend Framework