Module @libp2p/opentelemetry-metrics

Uses OpenTelemetry to store metrics and method traces in libp2p.

Example: Node.js

Use with OpenTelemetry Desktop Viewer:

import { createLibp2p } from 'libp2p'
import { openTelemetryMetrics } from '@libp2p/opentelemetry-metrics'
import { PrometheusExporter } from '@opentelemetry/exporter-prometheus'
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http'
import { NodeSDK } from '@opentelemetry/sdk-node'

const sdk = new NodeSDK({
traceExporter: new OTLPTraceExporter({
url: 'http://127.0.0.1:4318/v1/traces'
}),
metricReader: new PrometheusExporter({
port: 9464
}),
serviceName: 'my-app'
})
sdk.start()

const node = await createLibp2p({
// ... other options
metrics: openTelemetryMetrics()
})

@libp2p/opentelemetry-metrics

libp2p.io Discuss codecov CI

Opentelemetry metrics gathering for libp2p

About

Uses OpenTelemetry to store metrics and method traces in libp2p.

Example - Node.js

Use with OpenTelemetry Desktop Viewer:

import { createLibp2p } from 'libp2p'
import { openTelemetryMetrics } from '@libp2p/opentelemetry-metrics'
import { PrometheusExporter } from '@opentelemetry/exporter-prometheus'
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http'
import { NodeSDK } from '@opentelemetry/sdk-node'

const sdk = new NodeSDK({
traceExporter: new OTLPTraceExporter({
url: 'http://127.0.0.1:4318/v1/traces'
}),
metricReader: new PrometheusExporter({
port: 9464
}),
serviceName: 'my-app'
})
sdk.start()

const node = await createLibp2p({
// ... other options
metrics: openTelemetryMetrics()
})

Install

$ npm i @libp2p/opentelemetry-metrics

API Docs

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Index

Interfaces

Functions