By default, OtlpHttpTransport only adds the body property to signals that have a body value. This excludes Measurement and Exception signals, which can cause issues with some Otel Collector components.
To resolve this, use the otlpTransform property in OtlpHttpTransportOptions to provide custom body string generators: createErrorLogBody and createMeasurementLogBody. Each function receives a TransportItem representing the log being transformed, allowing you to build a custom string from the payload.
initializeFaro({
// ...
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) {
const { payload } = item;
const [measurementName, measurementValue] = Object.entries(payload.values).flat();
const body = `faro.signal.measurement: type=${payload.type} name=${measurementName} value=${measurementValue}`;
return body;
},
// create custom body string for error logs
createErrorLogBody(item) {
const { payload } = item;
const body = `faro.signal.error: type=${payload.type} message=${payload.value}`;
return body;
},
},
}),
],
});