This is the urgent issue for compatibility for the typing.
Issue: Currently the registerOTel() only allow to pass the type LogRecordProcessor. But the opentelemetry library has more specific types (eg. BatchLogRecordProcessor). And it is causing the type checking issues.
Target: We should update the registerOTel and allow it to pass more specific types.
Reproduce: The below is the code:
import {
BatchLogRecordProcessor,
LogRecordExporter,
} from '@opentelemetry/sdk-logs';
import { registerOTel } from '@vercel/otel';
const logRecordProcessor = new BatchLogRecordProcessor(
logExporter as LogRecordExporter
);
registerOTel({
serviceName, // use your own service name
traceExporter, // use your own trace exporter
logRecordProcessor,
});
And then we can see the error:
Type 'BatchLogRecordProcessor' is not assignable to type 'LogRecordProcessor'.
Types of property 'onEmit' are incompatible.
Type '(logRecord: LogRecord) => void' is not assignable to type '(logRecord: LogRecord, context?: Context | undefined) => void'.
Types of parameters 'logRecord' and 'logRecord' are incompatible.
Type 'import("/Users/jerry.huang/Documents/GitHub/unloan-web/node_modules/.pnpm/@opentelemetry+sdk-logs@0.200.0_@opentelemetry+api@1.8.0/node_modules/@opentelemetry/sdk-logs/build/src/LogRecord").LogRecord' is not assignable to type 'import("/Users/jerry.huang/Documents/GitHub/unloan-web/node_modules/.pnpm/@opentelemetry+sdk-logs@0.50.0_@opentelemetry+api-logs@0.50.0_@opentelemetry+api@1.8.0/node_modules/@opentelemetry/sdk-logs/build/src/LogRecord").LogRecord'.
Types of property 'attributes' are incompatible.
Type 'import("/Users/jerry.huang/Documents/GitHub/unloan-web/node_modules/.pnpm/@opentelemetry+api-logs@0.200.0/node_modules/@opentelemetry/api-logs/build/src/types/AnyValue").AnyValueMap' is not assignable to type 'import("/Users/jerry.huang/Documents/GitHub/unloan-web/node_modules/.pnpm/@opentelemetry+api-logs@0.50.0/node_modules/@opentelemetry/api-logs/build/src/types/AnyValue").AnyValueMap'.
'string' index signatures are incompatible.
Type 'AnyValue' is not assignable to type 'AnyValue | undefined'.
Type 'null' is not assignable to type 'AnyValue | undefined'.
This is the urgent issue for compatibility for the typing.
Issue: Currently the
registerOTel()only allow to pass the typeLogRecordProcessor. But the opentelemetry library has more specific types (eg.BatchLogRecordProcessor). And it is causing the type checking issues.Target: We should update the
registerOTeland allow it to pass more specific types.Reproduce: The below is the code:
And then we can see the error: