@grafana/faro-transport-otlp-http (法语)
法罗运输将法罗模型转换为开放遥测模型.
❗️3⁄4 ̄ ̧漯B:这个包是实验性的,可能会频繁地被打破. 冒险使用
❗️3⁄4 ̄ ̧漯B: Grafana 接收器尚未支持此格式 。\\\\\
❗️3⁄4 ̄ ̧漯B: 法罗不支持OpenTeleometry的单独度量衡格式.
这意味着法罗不收集"开放遥测"规格所定义的量子.
例如,法罗没有度量类型,例如高格或苏姆或直方图等
就像开放遥测一样 Faro 将计量值存储为日志行 Measurements。 。 。 .
在遵守《计量法》的同时将计量法翻译成计量法是不可行的
开放遥测光谱. 因此,我们不转换它们,它们仍然作为日志类型发送
安装
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',
}),
],
});
使用量
Faro OtlpHttp Transport将Faro模型转换为Otlp schema,因此可以将Faro数据发送到 兼容的 Otel 接收器.
可选 body 类型日志中的属性 Measurement 财务报告和审定财务报表 Exception
这个 body 字段是 Otel 日志光谱定义的可选字段.
因为这样,我们只把身体属性添加到只有身体价值的信号上.
除了这些信号之外 Measurement 财务报告和审定财务报表 Exception
这会引起一些Otel Collectionor组件出问题.
法罗提供 createErrorLogBody 财务报告和审定财务报表 createMeasurementLogBody 可以使用的函数
为这些日志创建正文字符串.
两个属性都是 otlpTransform 对象在 OtlpHttpTransportOptions。 。 。 .
作为参数,每个函数都得到目前正在转换的日志的传输项. 您可以使用此对象的值来构建自定义字符串 .
示例
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;
},
},
}),
],
});
配置选项
apiKey?: string: 将添加为x-api-key头曰.bufferSize?: number: 总共请求缓冲多少次.concurrency?: number: 要同时执行的请求数.defaultRateLimitBackoffMs?: number尝试请求前需要退后多少毫秒 如果速率限制响应不包含重试后页眉。 中间事件将被放弃, 未缓冲requestOptions?: OtlpTransportRequestOptions: 当 发送数据.tracesURL?: string: 发送 Traces 到的结束点 .logsURL?: string: 发送日志的终点.otlpTransform?::自定义部分日志转换.otlpTransform.createErrorLogBody?: (item: TransportItem<ExceptionEvent>) => string数字 : 创建错误日志的自定义正文.otlpTransform.createMeasurementLogBody?: (item: TransportItem<MeasurementEvent>) => string;数字 : 创建计量日志的自定义正文.