Skip to main content

Visual Studio Code extension for creating Dynatrace Apps

Build smarter and faster for the Dynatrace platform: The Visual Studio Code Extension "Dynatrace Apps" helps developers create, test, and debug apps for the Dynatrace platform.

The extension supports the following functionalities:

Requirements

Before you start, be sure you meet the following requirements:

  • Visual Studio Code version 1.85.0 or higher.
  • A VS Code Dynatrace app project containing an app.config.json configuration file in the root directory.
  • A Dynatrace account and user: If you're new to Dynatrace, visit our website to learn more about our offering and sign up for a free trial.

Installation

You can install the extension from the Microsoft Visual Code Marketplace or directly from the extensions tab inside your Visual Studio Code IDE.

Build an app with the Dynatrace App Toolkit

The extension wraps essential functionality from the Dynatrace App Toolkit, such as configuring or starting the server, building and deploying apps, or generating app functions.

Configure your app

You can define all necessary options from the app manifest using the provided Configure app functionality. It includes metadata such as app ID or name and scopes or content security policies.

Configure your custom app

Test your new app without (re)deployment

Using the built-in Dynatrace development server, you can quickly review changes to your app by reloading the browser instead of deploying a new version. You can start the development servers on localhost from the command panel in the sidebar. Browse the documentation to investigate more options for the server.

Build and deploy apps

Selecting Build app runs the npx dt-app build script to create the app bundle and run validation checks. Have a look at the documentation to explore more build options. Clicking on Deploy app will perform a build and deploy the app to your connected development environment.

Stay up to date with your dependencies

When selecting Update dependencies, the extensions will run the npx update command to check if there are any new Dynatrace packages available on npm and will install them.

Update Dynatrace dependencies from the Visual Studio Code extension

Generate app functions

App functions represent the backend, including all the business logic, of a Dynatrace app. You use them for requirements such as accessing third-party APIs, heavy data processing and manipulation, or capsule functionality requiring elevated access rights.

You can create a new app function by clicking on the Generate app function and entering a name. It will execute a script, which creates a file in your app's API directory and exposes the new function in the respective app function section.

After the wizard finishes, it creates a file in your app's API directory and exposes the new function in the respective App functions section. From there, you can test it using mocked parameters.

TerminalOutputAppFunctionGenerated

Query data from within the extension

Write queries

The Dynatrace Query Language (DQL) is a powerful tool to explore, filter, and aggregate data stored in Dynatrace. To query data from within the IDE, you need to create and open a file with a .dql postfix (logQuery.dql) and insert your query. Below, you can see an example DQL statement that shows the first 100 log entries:

fetch logs
| limit 100

When you start typing, the auto-completion will suggest available DQL commands.

First query

You can also create multiple queries to trigger them individually or use them within TypeScript, as in the example below. To do so, you need to add a name for each of them:

@name("GetLogs")
fetch logs
| limit 100

@name("GetSevereLogs")
fetch logs
| filter loglevel == "SEVERE"

Call dynamic queries from within your app

With this extension, you can create TypeScript functions to query data dynamically from within your Dynatrace app. Each query is exposed by its given name. You can also add parameters to create dynamic queries by adding a @param(fieldname, default) annotation as shown below:

@name('ErrorLogs')
@param('logType', '"error"') // string
@param('maxLogs', 100) // number
fetch logs
| filter contains(content, {{logType}})
| fields dt.app.id, timestamp
| limit {{maxLogs}}

use a query in the code

Permissions

The extension has all permissions to query DQL data, so the preview function returns data immediately. When you use the generated typescript function for this query, include the query scope in your app.config.json. It requires either the storage:events:read or storage:logs:read permission.

Still have questions?
Find answers in the Dynatrace Community