Skip to content

Latest commit

 

History

History

opentelemetry-exporter-metrics-otlp-fastly-logger

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

OpenTelemetry Metrics Exporter for Fastly Compute named log providers

This module provides a metrics exporter that exports metrics using the OTLP/HTTP JSON format over a Fastly named log provider.

Installation

npm install --save @fastly/compute-js-opentelemetry

Usage

import { OTLPMetricExporter } from "@fastly/compute-js-opentelemetry/exporter-metrics-otlp-fastly-logger";

// Instantiate a metric exporter.
// "@fastly/compute-js-opentelemetry/exporter-metrics-otlp-fastly-logger" sends metrics data to the named
// log provider, using the OTLP format. Be sure to specify the log provider, rather than a URL.
const metricExporter = new OTLPMetricExporter({
  endpoint: 'test_logger'
});

// Attach the exporter to a metric reader.
// For Fastly Compute, use FastlyMetricReader which collects metrics
// for a single invocation and submits them at the end of the invocation.
const metricReader = new FastlyMetricReader({
  exporter: metricExporter,
});

// Specify the metricReader when instantiating the SDK
import { FastlySDK } from "@fastly/compute-js-opentelemetry/sdk-fastly";
const sdk = new FastlySDK({
  metricReader,
});
await sdk.start();

// or, register it with the API directly
import { metrics } from '@opentelemetry/api';
metrics.setGlobalMeterProvider(meterProvider);