Atomia Performance Monitoring

Installation

26 views 0

Before you begin

In order for Atomia Performance Monitoring to be fully functional following applications/services need to be installed:

  • Infrastructure applications
    • MS MessageQue service
    • MongoDB database
  • Performance Logging Component (PLC) must be installed into applications to be monitored
  • Peformance Log Distributor Service
  • Performance Control Panel

Infrastructure applications

These applications are windows services which provide environment for storing and transfering performance data. It consists of MongoDBdatabase engine for storage and MS Message Queue service for transfering performance log data. MS Message Queue is usually part of MS Windows installation whereas MongoDB must be installed separately.

Installation of performance logging component

To install Performance Logging Component, corresponding DLL files has to be copied to working folder of application ( bin folder for web applications) and application’s .config file has to be changed. This is the list of files which needs to be copied:

  • Atomia.Performance.Common.dll
  • Atomia.Performance.Logging.dll

Configuration file must have configuration section which configures component itself (buffer size, log writer class, write URL, filters, etc) and sections which hooks message interceptors into request pipeline (http modules, wcf inspectors, etc).

Manual .config setup

Manual .config setup can be divided into couple of sections. These sections configure following artifacts:

  • performance logging component
  • http module
  • wcf service and client interceptors

Configuration of performance logging component

For Performance Logging Component we need to add config section definition and corresponding configuration element in .config file.

Example 1. Performance logging component config section

<configSections>
 <section name="atomiaPerformanceLogging" type="Atomia.Performance.Logging.Configuration.AtomiaPerformanceLogging, Atomia.Performance.Logging" />
</configSections>

Example 2. Performance logging component configuration

<atomiaPerformanceLogging powerSwitch="True" applicationName="Sample client">
<callLogBuffer  bufferSize="1"
writeUrl=".\private$\AtomiaPerformance"
writerType="Atomia.Performance.Logging.IO.MessageQueueWriter" />
<filters>
<filter name="CallName"
value="\.jpg|\.css|\.js|\.png|\.gif|\.axd|\.ico"
type="exclude" />
</filters>
</atomiaPerformanceLogging>

Adding diagnostic Http module to the request pipeline

This interceptor logs incoming Http requests and it is used in ASP.NET applications only.

Important!

For now, usage of Diagnostic http module and WCF Service Interceptors in same application are mutually exclusive. They use different execution contexts (ASP.NET based execution context versus WCF operation context) and cannot exchange call data (for now).

Example 3. Configuration of http module

<system.webServer>
  <modules>
   <add name="DiagnosticsHttpModule" type="Atomia.Performance.Logging.Interceptors.HttpModules.DiagnosticsHttpModule, Atomia.Performance.Logging" />
</modules>
</system.webServer>

Configuration of WCF interceptors

WCF interceptors (both client and service) can be added to WCF client/service by using a concept of behavior extensions. This way we can inject interceptors into WCF pipeline by changing configuration only, and we don’t need to alter existing code.

This is possible by writing custom implementation of Behavior Extensions and hooking them into WCF through configuration. Main idea is to define custom behavior extension, and then adding that behavior extension to behavior configuration which is used by WCF service element (or WCF client endpoint element).

First we need to define behavior extension in configuration file. This is done in <system.serviceModel>/<extensions>/<behaviorExtensions> configuration section. If these sections does not exist we need to create them. After that we define our WCF behavior extensions. Client WCF behavior extensions are named as “clientInterceptors” and service inspectors are named “serviceInspectors”.

Example 4. Adding behavior extensions

             
<system.serviceModel>
<extensions>
<behaviorExtensions>
<add name="clientInterceptors" type="Atomia.Diagnostics.Benchmarking.Interceptors.WcfExtensions.ClientInspectorBehavior, Atomia.Diagnostics.Benchmarking, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
<add name="serviceInterceptors" type="Atomia.Diagnostics.Benchmarking.Interceptors.WcfExtensions.ServiceMessageBehavior, Atomia.Diagnostics.Benchmarking, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</behaviorExtensions>
</extensions>
</system.serviceModel>


Now we have to check which (if any) behavior configuration is used by WCF client/service. If WCF client/service uses behavior configuration, we need to find that behavior configuration definition in config, and add proper behavior extensions.

Example 5. Identify behavior configuration used by WCF client/service

<system.serviceModel>
<services>
<service behaviorConfiguration="Atomia.Billing.Core.Lib.AtomiaBillingApiBehavior"  
<!-- we need behavior configuration value -->
name="Atomia.Billing.Core.Lib.AtomiaBillingApi">
<endpoint address="" binding="wsFederationHttpBinding" bindingConfiguration="STSBindingConfiguration" contract="Atomia.Billing.Core.Sdk.IAtomiaBillingApi" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost/AtomiaBillingApi/" />
</baseAddresses>
</host>
</service>
</services>
<client>
<endpoint
address="http://deployment.atomia.troxo.net/AtomiaAccountApi/AtomiaAccountApi.svc"
behaviorConfiguration="ClientCertificateBehaviorAccountApi" <!-- we need this name -->
binding="wsFederationHttpBinding"
bindingConfiguration="WSFederationHttpBinding_IAtomiaAccountApi"
contract="AtomiaAccountApi.IAtomiaAccountApi"
name="WSFederationHttpBinding_IAtomiaAccountApi">
<identity>
<certificate encodedValue="..." />
</identity>
</endpoint>
</client>
</system.serviceModel>


From the above code snippet we can see that IAtomiaBillingApi service uses Atomia.Billing.Core.Lib.AtomiaBillingApiBehavior behavior configuration, and AccountAPI client endpoint uses ClientCertificateBehaviorAccountApi behavior configuration. In this case we must add our behavior extension to behavior configuration which is used by WCF clients and services. Example for this is in code snippet below:

Example 6. Add behaviorExtensions to behavior configuration which is used by WCF client/service

<system.serviceModel>
<behaviors>
<serviceBehaviors>
<!-- Atomia.Billing.Core.Lib.AtomiaBillingApiBehavior behavior -->
<behavior name="Atomia.Billing.Core.Lib.AtomiaBillingApiBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceAuthorization principalPermissionMode="None" />
<serviceCredentials>
<serviceCertificate findValue="Atomia Billing" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />
<issuedTokenAuthentication audienceUriMode="Never" certificateValidationMode="PeerTrust" revocationMode="Online" trustedStoreLocation="LocalMachine" allowUntrustedRsaIssuers="false">
<knownCertificates>
<add findValue="Atomia Identity" storeLocation="LocalMachine" storeName="TrustedPeople" x509FindType="FindBySubjectName" />
</knownCertificates>
</issuedTokenAuthentication>
</serviceCredentials>
<serviceInterceptors /> <!-- we add "serviceInspectors" behavior extensions to existing behavior configuration -->
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<!-- ClientCertificateBehaviorAccountApi -->
<behavior name="ClientCertificateBehaviorAccountApi">
<clientCredentials>
<clientCertificate findValue="Atomia Billing" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />
</clientCredentials>
<clientInterceptors /> 
<!-- we add "clientInterceptors" behavior extensions to existing behavior configuration -->
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>


However, if we WCF client or service doesn’t use any behavior configuration, we have to define a new one.

<system.serviceModel>
<behaviors>
<!-- WCF service behavior configuration which uses service interceptors
<serviceBehaviors>
<behavior name="serviceInspectorsBehavior">
<serviceInterceptors />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<!--  Behavior configuration used by WCF client which contains client interceptors-->
<behavior name="clientInterceptorBehavior">
<clientInterceptors />
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>

After we’ve created WCF client/service behavior configuration we need to add them to WCF client/service element (if they don’t exist).

Example 7. Add WCF client/service behavior to proper client/service element

<system.serviceModel>
<services>
<service behaviorConfiguration="SampleService.SampleServiceBehavior"  <!-- our behavior configuration--> name="SampleService.SimpleService">
<endpoint address="" binding="wsHttpBinding" contract="SampleService.ISampleService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<client>
<endpoint address="http://deployment.atomia.troxo.net/AtomiaIdentityStS/AtomiaSts.svc/username/"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IWSTrustFeb2005Sync" contract="Microsoft.IdentityModel.Protocols.WSTrust.IWSTrustChannelContract"
name="WSHttpBinding_IWSTrustFeb2005Sync"
behaviorConfiguration="clientInterceptorBehavior"> <!-- our behavior configuration -->
</client>
</system.serviceModel>

Removal of Performance Logging Component

Performance logging can be shut down by setting powerSwitch attribute of <atomiaPerformanceLogging> element to false. This action causes Performance Logging Component to have minimal drawback on overall application performance, but it doesn’t remove interceptors from request pipeline. To completely remove Perfomance Logging Component interceptors from request pipeline we must reverse installation process, i.e make changes to application configuration files:

  1. Remove atomiaPerformanceLogging config section definition and concrete config section
    1. Locate and remove from .config file
      <section name="atomiaPerformanceLogging" type="Atomia.Performance.Logging.Configuration.AtomiaPerformanceLogging, Atomia.Performance.Logging" />
      
    2. Locate and remove <atomiaPerformanceLogging> element
  2. Remove http module (if exists)
    1. Locate and remove
      <add name="DiagnosticsHttpModule" type="Atomia.Performance.Logging.Interceptors.HttpModules.DiagnosticsHttpModule, Atomia.Performance.Logging" />
      
  3. Remove WCF interceptors
    1. Remove behavior extensions for instantination of interceptors:
      <add name="clientInterceptors"                    type="Atomia.Diagnostics.Benchmarking.Interceptors.WcfExtensions.ClientInspectorBehavior, Atomia.Diagnostics.Benchmarking, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
      <add name="serviceInterceptors"                  type="Atomia.Diagnostics.Benchmarking.Interceptors.WcfExtensions.ServiceMessageBehavior, Atomia.Diagnostics.Benchmarking, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
      
    2. Remove behavior extensions from behavior configuration. Locate behaviors which use <clientIterceptors /> and <serviceInterceptors /> elements, and remove those lines:
      <system.serviceModel>
      <behaviors>
      <serviceBehaviors>
      <!-- Atomia.Billing.Core.Lib.AtomiaBillingApiBehavior behavior -->
      <behavior name="Atomia.Billing.Core.Lib.AtomiaBillingApiBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
      <serviceAuthorization principalPermissionMode="None" />
      <serviceCredentials>
      <serviceCertificate findValue="Atomia Billing" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />
      <issuedTokenAuthentication audienceUriMode="Never" certificateValidationMode="PeerTrust" revocationMode="Online" trustedStoreLocation="LocalMachine" allowUntrustedRsaIssuers="false">
      <knownCertificates>
      <add findValue="Atomia Identity" storeLocation="LocalMachine" storeName="TrustedPeople" x509FindType="FindBySubjectName" />
      </knownCertificates>
      </issuedTokenAuthentication>
      </serviceCredentials>
      <serviceInterceptors /> <!-- REMOVE THIS LINE -->
      </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
      <!-- ClientCertificateBehaviorAccountApi -->
      <behavior name="ClientCertificateBehaviorAccountApi">
      <clientCredentials>
      <clientCertificate findValue="Atomia Billing" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />
      </clientCredentials>
      <clientInterceptors /> <!-- REMOVE THIS LINE -->
      </behavior>
      </endpointBehaviors>
      </behaviors>
      </system.serviceModel>
      
  4. Remove Performance Logging Component dll files from application folder (or bin folder):
    1. Atomia.Perfomance.Logging.dll
    2. Atomia.Performance.Common.dll

Automatic setup

Fortunately, Performance Logging Component installation can be automated. Component’s DLL can be copied to selected applications and those application’s config files can also be automaticaly altered as well. Automatic installation should be provided by Performance GUI Application/Service. User should be presented with a list of IIS applications together with information whether performance monitoring is installed on application and if it’s enabled. If user chooses installation, installer engine should then analyze .config files of chosen application and change it accordingly. Before changes are saved, backup should be made and new .config files should be presented to user for inspection.

Enabling/disabling of monitoring is done via changing value of one element inside configuration section of Performance Logging Component.

Installer routine should search for specific configuration sections (e.g. <system.serviceModel>) and change them in proper way. Before changes are saved, they should be presented to user who can check if changes are ok. Also, in that installation step, user can choose whether some calls needs to be monitored at all.

Example 8. Workflow for automatic altering of configuration files

            1. add config section for Performance Logging Component

            1.1 find <configSections element and add following line:

            <section name="atomiaPerformanceLogging" type="Atomia.Performance.Logging.Configuration.AtomiaPerformanceLogging, Atomia.Performance.Logging" />

            1.2 append configuration xml to root (<configuration>) element:

            <atomiaPerformanceLogging powerSwitch="True" applicationName="Sample client">

            <callLogBuffer  bufferSize="1"

            writeUrl=".\private$\AtomiaPerformance"

            writerType="Atomia.Performance.Logging.IO.MessageQueueWriter" />

            <filters>

            <filter name="CallName"

            value="\.jpg|\.css|\.js|\.png|\.gif|\.axd|\.ico"

            type="exclude" />

            </filters>

            </atomiaPerformanceLogging>

            2. add http module to {{<system.webServer>}}

            <modules>

            <add name="DiagnosticsHttpModule" type="Atomia.Performance.Logging.Interceptors.HttpModules.DiagnosticsHttpModule, Atomia.Performance.Logging" />

            </modules>

            3 search for <system.serviceModel> and add behavior extensions (client and service)

            3.1 check if .config file contains {{<behaviors>}} element and if it does

            3.1.1 add <clientInterceptors> to <endpointBehaviors> element

            3.1.1.1 check if {{<endpoint>}} configuration uses endpoint behavior and add it as attribute if it doesn't:

            behaviorConfiguration="clientInspectors"

            3.1.2 add <serviceInterceptors> to <serviceBehaviors> element

Was this helpful?