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.
Using the following code, you can check if a diagnostics configuration for the current role instance exists.
Example 880. 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';
Using the following code, you can load the current role instance diagnostics configuration.
Example 881. 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();
Using the following code, you can store the current role instance diagnostics configuration.
Example 882. 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);
Using the following code, you can subscribe to a performance counter.
Example 883. 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);




