mackerel-exporter
TypeScript icon, indicating that this package has built-in type declarations

0.0.8 • Public • Published

OpenTelemetry Mackerel Metric Exporter

The OpenTelemetry Mackerel Metric Exporter is allow the user to send metrics to Mackerel.

Installation

npm i mackerel-exporter

Usage

import {
  PeriodicExportingMetricReader,
  MeterProvider,
} from "@opentelemetry/sdk-metrics";
import { SemanticResourceAttributes } from "@opentelemetry/semantic-conventions";
import { Resource } from "@opentelemetry/resources";
import { MackerelExporter } from "mackerel-exporter";

const meterProvider = new MeterProvider({
  resource: new Resource({
    [SemanticResourceAttributes.SERVICE_NAME]: "basic-metric-service",
  }),
});

const exporter = new MackerelExporter({
  apiKey: process.env.MACKEREL_API_KEY,
});

meterProvider.addMetricReader(
  new PeriodicExportingMetricReader({
    exporter,
  }),
);

const meter = meterProvider.getMeter("example-meter");

const diceRollCounter = meter.createCounter("dice", {
  description: "Dice roll counter",
});

const dice = Math.floor(Math.random() * 6) + 1;
diceRollCounter.add(1, {
  dice: dice,
});

See examples for more details.

Configuration

Name Type Required Description
apiKey string Mackerel API key.
compression "none" | "gzip" Compression algorithm to use.
headers Record<string, string> Additional headers to send with the request.

License

MIT

Package Sidebar

Install

npm i mackerel-exporter

Weekly Downloads

0

Version

0.0.8

License

MIT

Unpacked Size

1.06 MB

Total Files

23

Last publish

Collaborators

  • azukiazusa