Azure Monitor is a suite of tools for collecting, analyzing and responding to infrastructure and application telemetry data from cloud and on-premises environments. AMAI is one of the Azure Monitor tools and provides Application Performance Monitoring (APM) to its users. Additionally, Azure Monitor Application Insights supports distributed discovery, one of the pillars of the observability paradigm, across multiple applications. OpenTelemetry is a framework that provides APIs, SDKs, vendor-agnostic, and tools for consuming, transforming, and exporting telemetry data to Observability back-ends. In a 2021 blog post, Microsoft outlined its roadmap for integrating OpenTelemetry into its broader Azure Monitor ecosystem. The immediate goal of this was to create direct exporters from OpenTelemetry-based applications to AMAI as opposed to the de facto OpenTelemetry route of an OTLP exporter to Azure Monitor via the OpenTelemetry Collector. Source: A sample of the direct exporter in a Node.js application with OpenTelemetry tracing in place would be: const { AzureMonitorTraceExporter } = require(“@azure/monitor-opentelemetry-exporter”); const { NodeTracerProvider } = require(“@opentelemetry/sdk-trace-node”); const { BatchSpanProcessor } = require(“@opentelemetry/sdk-trace-base”); const provider = new NodeTracerProvider({ resource: new Resource({ [SemanticResourceAttributes.SERVICE_NAME]: “basic-service”, }), }); provider.register(); // Create exporter instance const exporter = new AzureMonitorTraceExporter({ connectionString: process.env[“APPLICATIONINSIGHTS_CONNECTION_STRING”] || “<η συμβολοσειρά σύνδεσης σας>” }); // Add the exporter to the provider provider.addSpanProcessor( new BatchSpanProcessor(exporter, { bufferTimeout: 15000, bufferSize: 1000 }) ); With the release of the new updates to the Azure Monitor OpenTelemetry Exporter packages, exporting metrics to AMAI will now be possible, as shown below: const { MeterProvider, PeriodicExportingMetricReader } = require(“@opentelemetry/sdk-metrics”); const { Resource } = require(“@opentelemetry/resources”); const { AzureMonitorMetricExporter } = require(“@azure/monitor-opentelemetry-exporter”); // Add the exporter to the MetricReader and register it in the provider Const MeterProvider = new MeterProvider(); const exporter = new AzureMonitorMetricExporter({connectionString: process.env[“APPLICATIONINSIGHTS_CONNECTION_STRING”] || “<η συμβολοσειρά σύνδεσης σας>“, }); const metricReaderOptions = { exporter: exporter, }; const metricReader = new PeriodicExportingMetricReader(metricReaderOptions); provider.addMetricReader(metricReader); ) To manage the volume of telemetry data sent to Application Insights, packages now include a sampler that controls the percentage of traces sent. For the Node.js trace example from earlier, it would look like this: import { ApplicationInsightsSampler, AzureMonitorTraceExporter } from “@azure/monitor-opentelemetry-exporter”; // Sampler expects a sample rate between 0 and 1 inclusive // A rate of 0.75 means about 75% of traces are sent const aiSampler = new ApplicationInsightsSampler(0.75); const provider = new NodeTracerProvider({ resource: new Resource({ [SemanticResourceAttributes.SERVICE_NAME]: “basic-service”, }), sampler: aiSampler }); Finally, in the event of a connection failure with AMAI, direct exporters write their payloads to local storage and periodically retry deliveries within 48 hours. These settings can be configured in an exporter’s presentation, as shown below: const exporter = new AzureMonitorTraceExporter({ connectionString: process.env[“APPLICATIONINSIGHTS_CONNECTION_STRING”]storageDirectory: “C:\SomeDirectory”, // your desired location disableOfflineStorage: false // enabled by default, set to disabled });