@grafana/faro-transport-otlp-http

中文文档
2.14.0发布于 2026/11/09Apache-2.0TypeScriptESM + CJS构建来源已验证近 30 天下载 7.6万

Faro transport which converts the Faro data model to the Otlp data model.

原始使用文档
文档目录4 节
  1. Installation
  2. Usage
  3. Optional body property in Logs of type Measurement and Exce…
  4. Config Options

@grafana/faro-transport-otlp-http

Faro transport which converts the Faro model to the Open Telemetry model.

❗️Warning: this package is experimental and may be subject to frequent and breaking changes. Use at your own risk.❗️

❗️Warning: The Grafana Receiver does not support this format yet.❗️

❗️Warning: Faro does not support a separate metrics format as Open Telemetry does. This means Faro does not collect Metrics as defined by the Open Telemetry specification. For example Faro does not have metric types, such as Gauge or Sum or Histogram and so on as Open Telemetry does. Faro stores Metric values as log lines called Measurements. It is not feasible to translate Measurements to Metrics while staying compliant with the Open Telemetry spec. So we do not convert them and they are still be sent as a log type.❗️

Installation

import { getWebInstrumentations, initializeFaro } from '@grafana/faro-react';
import { OtlpHttpTransport } from '@grafana/faro-transport-otlp-http';

initializeFaro({
  // ...
  instrumentations: [
    // Load the default Web instrumentations
    ...getWebInstrumentations(),
  ],
  transports: [
    new OtlpHttpTransport({
      apiKey: env.faro.apiKey,
      logsURL: 'https://example.com/v1/logs',
      tracesURL: 'https://example.com/v1/traces',
    }),
  ],
});

Usage

The Faro OtlpHttpTransport converts the Faro model to the Otlp schema, so you can send Faro data to compatible Otel Receivers.

Optional body property in Logs of type Measurement and Exception

The body field is optional as defined by the Otel Log spec. Because of this we only add the body property only to signals which have a body value. This is all signals besides of Measurement and Exception

This can cause issues with some Otel Collector components.

Faro provides the createErrorLogBody and createMeasurementLogBody functions which you can use to create a body string for these logs. Both properties are part of the otlpTransform object in OtlpHttpTransportOptions.

As a parameter each function gets the transport item of the log which is currently in transformation. You can use values from this object to built a custom string.

Example

initializeFaro({
  // ...
  instrumentations: [
    // Load the default Web instrumentations
    ...getWebInstrumentations(),
  ],
  transports: [
    new OtlpHttpTransport({
      apiKey: env.faro.apiKey,
      logsURL: 'https://example.com/v1/logs',
      tracesURL: 'https://example.com/v1/traces',

      // customize logs transformation
      otlpTransform: {
        // create custom body string for measurement logs
        createMeasurementLogBody(item) {
          // Note: It's not advisable to built big strings which contain redundant data because
          // it ads unnecessary bytes to the requests and your storage solution
          // This example is to show how we can use the transport-item to built a custom string
          const { payload } = item;
          const [measurementName, measurementValue] = Object.entries(payload.values)[0] ?? [];
          const body = `faro.signal.measurement: type=${payload.type} name=${measurementName} value=${measurementValue}`;
          return body;
        },
        // create custom body string for error logs
        createErrorLogBody(item) {
          // Note: It's not advisable to built big strings which contain redundant data because
          // it ads unnecessary bytes to the requests and your storage solution
          // This example is to show how we can use the transport-item to built a custom string
          const { payload } = item;
          const body = `faro.signal.error: type=${payload.type} message=${payload.value}`;
          return body;
        },
      },
    }),
  ],
});

Config Options

  • apiKey?: string: Will be added as x-api-key header.
  • bufferSize?: number: How many requests to buffer in total.
  • concurrency?: number: How many requests to execute concurrently.
  • defaultRateLimitBackoffMs?: number How many milliseconds to back off before attempting a request if rate limit response does not include a Retry-After header. ❗️Intermediate events will be dropped, not buffered❗️
  • requestOptions?: OtlpTransportRequestOptions: Additional options to add to requests when sending the data.
  • tracesURL?: string: Endpoint to send Traces to.
  • logsURL?: string: Endpoint to send Logs to.
  • otlpTransform?:: Customize parts of logs transformation.
  • otlpTransform.createErrorLogBody?: (item: TransportItem<ExceptionEvent>) => string: create custom body for error logs. otlpTransform.createMeasurementLogBody?: (item: TransportItem<MeasurementEvent>) => string;: create custom body for measurement logs.

版本与发布记录

@grafana/faro-transport-otlp-http 共发布 95 个版本,首次发布于 2023/04/26;过去 12 个月发布了 26 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.14.0latest2026/11/097 天前
2.13.02026/10/2225 天前
2.12.12026/09/221 个月前
2.12.02026/09/181 个月前
2.11.02026/08/272 个月前
2.10.02026/08/182 个月前

关于 @grafana/faro-transport-otlp-http 的常见问题

@grafana/faro-transport-otlp-http 是什么?

Faro transport which converts the Faro data model to the Otlp data model.

如何安装 @grafana/faro-transport-otlp-http?

在项目目录运行 npm install @grafana/faro-transport-otlp-http,或使用 pnpm add / yarn add / bun add。

@grafana/faro-transport-otlp-http 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@grafana/faro-transport-otlp-http 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@grafana/faro-transport-otlp-http 可以商用吗?

@grafana/faro-transport-otlp-http 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@grafana/faro-transport-otlp-http 的下载量有多少?

根据 npm 官方下载统计,@grafana/faro-transport-otlp-http 在 2026/10/17 – 2026/11/15 这 30 天内被下载 76,027 次,日均约 2,534 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@grafana/faro-transport-otlp-http 还在维护吗?

最新版本 2.14.0 发布于 2026/11/09(7 天前);至今共发布 95 个版本,其中过去 12 个月发布了 26 个;首次发布于 2023/04/26。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。