D
DavidHernandez
The platform engineering journey requires abundant information to make informed decisions. Understanding how developers use the platform—how frequently and for how long—is invaluable. Since the internal developer portal (IDP) serves as the central hub for developers’ regular tasks, it becomes the ideal location for monitoring these activities and collecting essential data.
Backstage, a common IDP implementation, provides an excellent opportunity to demonstrate how to integrate monitoring. In this article, we’ll explore how to add monitoring to the Backstage portal using Azure Monitor, specifically Application Insights.
Upon reviewing the Backstage documentation, we find that the portal is already instrumented using OpenTelemetry. Furthermore, Application Insights is a supported provider for OpenTelemetry.
This is excellent news, as it streamlines the process and saves time that would otherwise be spent manually adding tracing calls to the Backstage code.
To enable OpenTelemetry instrumentation, follow the steps in the official documentation(Setup OpenTelemetry | Backstage Software Catalog and Developer Platform). Start by adding the required packages using the following command:
Code:
yarn --cwd packages/backend add \
@opentelemetry/sdk-node \
@opentelemetry/auto-instrumentations-node \
/monitor-opentelemetry-exporter
Next, create a new file named
instrumentation.js
inside the backend/src
folder.The content of the file should be:
Code:
const { NodeSDK } = require('@opentelemetry/sdk-node');
const {
getNodeAutoInstrumentations,
} = require('@opentelemetry/auto-instrumentations-node');
const { AzureMonitorTraceExporter } = require("@azure/monitor-opentelemetry-exporter");
const { AzureMonitorMetricExporter } = require("@azure/monitor-opentelemetry-exporter");
// Create an exporter instance
const azTraceExporter = new AzureMonitorTraceExporter({
connectionString:
process.env["APPLICATIONINSIGHTS_CONNECTION_STRING"] || "<YourAppInsightsConnectionString>"
});
const sdk = new NodeSDK({
traceExporter: azTraceExporter,
instrumentations: [getNodeAutoInstrumentations()],
});
sdk.start();
And with that...we are done!
Browse some pages within the Backstage portal and in a few minutes, telemetry will be available in Application Insights.
Here are some samples of information that has been gathered. All this information is out-of-the-box reports, so without any other customization, we can obtain a wealth of information.
We can check if the portal is returning errors, if the response time is within acceptable parameters, how many requests are made and the usage pattern...
Examine the details of a request to Backstage, the time taken to serve the request and the time spent on all dependencies...
Retrieve information from the accessed URLs, for example, to identify the most common searches and ascertain developers' interests.
Continue reading...