import { Controller, Get, UseGuards, UseInterceptors } from '@nestjs/common';
import { AppService } from './app.service';
import { FileInterceptor } from '@nestjs/platform-express';
import { context, trace } from '@opentelemetry/api';
@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}
@Get('/')
@UseInterceptors(FileInterceptor('file'))
testFile() {
var span = trace.getSpan(context.active());
console.log(span);
if (!span) {
return {
trace_id: '',
span_id: '',
};
}
return 'test';
}
}
tracing.js
import { NodeSDK } from '@opentelemetry/sdk-node';
import { ConsoleSpanExporter } from '@opentelemetry/sdk-trace-node';
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
import {
PeriodicExportingMetricReader,
ConsoleMetricExporter,
} from '@opentelemetry/sdk-metrics';
const sdk = new NodeSDK({
traceExporter: new ConsoleSpanExporter(),
metricReader: new PeriodicExportingMetricReader({
exporter: new ConsoleMetricExporter(),
}),
instrumentations: [getNodeAutoInstrumentations()],
});
sdk.start();
2 when i comment the filter FileInterceptor , i got print span info in the console.
3 when i uncoment the filter FileInterceptor, it got undefined
4 package.json
What happened?
Steps to Reproduce
simple demo in stackblitz 1 simple controller demo
tracing.js
2 when i comment the filter FileInterceptor , i got print span info in the console. 3 when i uncoment the filter FileInterceptor, it got undefined 4 package.json
Expected Result
print span info in console
Actual Result
print undefined
Additional Details
OpenTelemetry Setup Code
package.json
Relevant log output
No response