Azure Monitor

Azure Monitor Application Insights collects distributed traces, logs, and metrics from Node.js applications. PURISTA integrates through the Azure Monitor OpenTelemetry exporter — the official, supported path for sending traces from Node.js to Application Insights.

Install

npm install @azure/monitor-opentelemetry-exporter @opentelemetry/sdk-trace-node

TypeScript setup

Use AzureMonitorTraceExporter from @azure/monitor-opentelemetry-exporter. Provide your Application Insights connection string via an environment variable:

import { AzureMonitorTraceExporter } from '@azure/monitor-opentelemetry-exporter'
import { SimpleSpanProcessor } from '@opentelemetry/sdk-trace-node'

export function getSpanProcessor() {
  return new SimpleSpanProcessor(
    new AzureMonitorTraceExporter({
      connectionString: process.env.APPLICATIONINSIGHTS_CONNECTION_STRING,
    })
  )
}

Wire it into your application:

import { getSpanProcessor } from './tracing.js'
import { AmqpBridge } from '@purista/amqpbridge'

const spanProcessor = getSpanProcessor()

const eventBridge = new AmqpBridge({ spanProcessor })
await eventBridge.start()

const myService = await myV1Service.getInstance(eventBridge, { spanProcessor })
await myService.start()

Environment variables

VariableDescription
APPLICATIONINSIGHTS_CONNECTION_STRINGYour App Insights connection string from the Azure Portal
OTEL_SERVICE_NAMEService name shown in Azure Monitor

Viewing traces

  1. Open the Azure Portal
  2. Navigate to your Application Insights resource
  3. Go to Transaction search to find PURISTA traces by trace ID
  4. Use Application map to see service-to-service dependencies

Resources