Opentelemetry metrics gathering for libp2p
Uses OpenTelemetry to store metrics and method traces in libp2p.
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()
})
$ npm i @libp2p/opentelemetry-metrics
Licensed under either of
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.
Uses OpenTelemetry to store metrics and method traces in libp2p.
Example: Node.js
Use with OpenTelemetry Desktop Viewer: