Deploy AppMon .NET Agents on Cloud Foundry sample app

Overview

Cloud Foundry is an enterprise PaaS (Platform as a Service). Cloud Foundry itself is an open source project but a commercial distribution is available from Pivotal.

Requirements

  • Working Cloud Foundry deployment
  • Working Diego Windows deployment as part of the Cloud Foundry deployment
  • CF command line tools
  • Dynatrace environment setup to support the .NET agent

Initial setup

Setting up the .NET agent requires deploying the agent .dll files with your application.

Download one of the following All Agents for Windows installers:

  1. The Community portal.
  2. The public download location at http://downloads.dynatracesaas.com

Extract files from the installer into a temporary folder.

msiexec /a dynatrace-agent.msi /qn TARGETDIR="c:\\temp\\agentfiles"

Add the .NET Agent to your solution

  1. Locate the .NET agent DLL's within it's installation folder as shown in the following.
  2. Copy dtangent.dll and dtagentcore.dll from the lib and lib64 folders into subfolders of your application.

The following example shows output from the CF .NET sample application from https://github.com/cloudfoundry-incubator/NET-sample-app as it unpacks and copies the agents to the dynatrace folder within the application.

Configure Application environment variables of your .NET Application

Environment variables must be populated in your application to enable the agent. The following table shows the values to set for the required environment variables.

Environment variable Value
COR_ENABLE_PROFILING: Always 0x01 to enable
COR_PROFILER "{DA7CFC47-3E35-4C4E-B495-534F93B28683}" for AppMon
COR_PROFILER_PATH Path to agent DLL inside your application
DT_AGENTNAME Name of Agent
DT_SERVER Address of Collector
DT_LOGFILE Path to agent log
DT_LOGLEVELCON Agent log level, one of:
  • NONE | OFF
  • FINEST
  • FINER
  • FINE
  • INFO
  • WARNING
  • SEVERE
DT_AGENTACTIVE Always true to enable agent

Define these environment variables in the manifest.yml file for your application to. For example, using the CF .NET sample application from https://github.com/cloudfoundry-incubator/NET-sample-app:

---
applications:
- name: my-app
  memory: 1G
  buildpack: binary_buildpack
  stack: windows2012R2
  path: ./ViewEnvironment/
  env:
      COR_ENABLE_PROFILING: 0x01
      COR_PROFILER: "{DA7CFC47-3E35-4C4E-B495-534F93B28683}"
      COR_PROFILER_PATH: ./dynatrace/agent/lib64/dtagent.dll
      DT_AGENTNAME: cf-dotnet-ViewEnvironment
      DT_SERVER: collector-address:9998
      DT_LOGFILE: ./dynatrace/agentlog.log
      DT_LOGLEVELCON: FINEST
      DT_AGENTACTIVE: true

Alternatively, you can use the cf set-env command to define these variables. For example:

cf set-env Net-sample-app COR_ENABLE_PROFILING 0x01