@ethanshea - I saw the code you linked and tried to use a logRecordProcessor to customize the logs before it is forwarded to Datadog. However this code here is not doing anything, the onEmit never gets called:
export function register() {
registerOTel({
serviceName: SERVICE_NAME,
attributes: {
'service.name': SERVICE_NAME,
'service.version': process.env.VERCEL_DEPLOYMENT_ID || 'unavailable',
env: process.env.VERCEL_ENV || 'unavailable',
environment: process.env.VERCEL_ENV || 'unavailable',
'deployment.environment': process.env.VERCEL_ENV || 'unavailable'
},
spanProcessors: [new DatadogSpanProcessor(), 'auto'],
logRecordProcessor: new DatadogLogProcessor()
});
}
class DatadogLogProcessor implements LogRecordProcessor {
forceFlush(): Promise<void> {
return Promise.resolve();
}
shutdown(): Promise<void> {
return Promise.resolve();
}
onEmit(logRecord: LogRecord, context?: Context): void {
console.log('emitting');
// Get trace context from the log record
// const traceId = logRecord.spanContext?.traceId;
// const spanId = logRecord.spanContext?.spanId;
// if (traceId && spanId) {
// logRecord.attributes = {
// ...logRecord.attributes,
// dd: {
// trace_id: getDatadogTraceId(traceId),
// span_id: getDatadogSpanId(spanId)
// }
// };
// }
}
}
My goal is to add dd.trace_id and dd.span_id to the logs. I successfully do this to the spans with my DatadogSpanProcessor. But by your message I see that this is probably not possible with @vercel/otel correct? Is it possible without the otel package? As it seems logs forward to datadog even without installing the otel package.