dynatrace-oneagent is a plugin for serverless framework which will add Dynatrace monitoring automatically to serverless deployments.
This plugin is community contributed and not officially supported by Dynatrace. In case of problems, feature requests, or questions submit a ticket on GitHub
The Dynatrace OneAgent serverless plugin will configure serverless and serverless-webpack to bundle Dynatrace npm module for PaaS.
In regular serverless projects, the plugin will npm install and tailor Dynatrace npm module for PaaS during serverless packaging process. It will also reconfigure the function handler definition to load Dynatrace OneAgent at function instance startup.
In serverless-webpack case, the plugin will configure webpack to include Dynatrace npm module for PaaS into the bundle. The resulting deployment zip file will contain the Javascript file for the handler function and a node_modules folder with Dynatrace OneAgent.
Enabling your serverless project for Dynatrace OneAgent is a two steps process:
- add plugin to serverless.yml
- specify OneAgent options
Extend the plugins list of the projects serverless.yml file with @dynatrace/serverless-oneagent plugin.
service: dynatrace-oneagent-sample
plugins:
  - '@dynatrace/serverless-oneagent'
provider:
  name: aws
  runtime: nodejs6.10
functions:
  hello:
    handler: index.hello
    events:
      - http:
          method: GET
          path: helloOneAgent options can be specified in serverless.yml file or serverless (sls) command line.
The option string can be obtained from serverless configuration screen (Deploy Dynatrace > Setup Serverless integration).
Add following to serverless.yml:
custom:
  serverless-oneagent:
    options: '{"server":"...","tenant":"...", "tenanttoken":"..."}'If you do not want to add OneAgent options to the serverless.yml , the options can be specified as a command line argument to serverless (sls) command.
serverless deploy --dt-oneagent-options='{"dynatraceTagPropertyPath":"headers.x-dynatrace","server":"...","tenant":"...","tenanttoken":"..."}'| serverless.yml | command line | description | 
|---|---|---|
| options | --dt-oneagent-options=<option string> | Specifies OneAgent options | 
| npmModuleVersion | --dt-oneagent-module-version=<version> | Specifies the version of OneAgent for PaaS module. Default is latest, specifynextfor @next version. | 
| verbose | --verbose | enables extended output of plugin processing. --verbose enables verbose mode for all plugins, while verbose option in serverless.ymlenables verbose output for this plugin only. | 
custom:
  serverless-oneagent:
    # enable serverless-oneagent plugin verbose mode
    verbose: true
    # specify @next Dynatrace OneAgent npm module
    npmModuleVersion: nextserverless deploy --dt-oneagent-module-version=next --dt-oneagent-options='{"dynatraceTagPropertyPath":"headers.x-dynatrace","server":"...","tenant":"...","tenanttoken":"..."}' --verboseThe samples folder contains ready to go serverless projects.
- AWS Lambda with Node.js runtime serverless
- AWS Lambda with Node.js runtime and serverless-webpack serverless
- The current plugin version supports following deployments
- AWS Lambda with Node.js runtime version 4.x, 6.x, and 8.x
 
In case of problems, feature requests, or questions submit a ticket.
