diff --git a/src/trace/trace.module.ts b/src/trace/trace.module.ts index 83cbbcc..3d06435 100644 --- a/src/trace/trace.module.ts +++ b/src/trace/trace.module.ts @@ -19,6 +19,7 @@ import { StatusCodes } from 'http-status-codes'; import { withResultsResponse, withResultResponse, Tags } from '../utils/swagger.js'; import { ExportTraceServiceRequest__Output } from '../types/generated/opentelemetry/proto/collector/trace/v1/ExportTraceServiceRequest.js'; +import { getModuleLogger } from '../utils/logger-factories.js'; import { traceSchema, @@ -31,6 +32,8 @@ import { } from './trace.dto.js'; import { createTrace, getTrace, getTraces, traceProtobufBufferParser } from './trace.service.js'; +const logger = getModuleLogger('trace'); + const module: FastifyPluginAsyncJsonSchemaToTs = async (app) => { // Custom parser for "application/x-protobuf" app.addContentTypeParser( @@ -89,6 +92,17 @@ const module: FastifyPluginAsyncJsonSchemaToTs = async (app) => { } }, async ({ body }, res) => { + logger.debug( + body.resourceSpans.flatMap((resourceSpan) => + resourceSpan.scopeSpans.flatMap((scopeSpan) => { + return { + scopeName: scopeSpan.scope?.name, + spanNames: scopeSpan.spans.map((span) => span.name) + }; + }) + ), + 'incoming trace data' + ); await createTrace(body); res.code(StatusCodes.CREATED); diff --git a/src/trace/trace.service.ts b/src/trace/trace.service.ts index 8ef724d..345574d 100644 --- a/src/trace/trace.service.ts +++ b/src/trace/trace.service.ts @@ -154,6 +154,7 @@ export function traceProtobufBufferParser( ) ); } + logger.debug({ base64: payload.toString().slice(0, 100) }, 'trace buffer base64 data'); if (!Buffer.isBuffer(payload)) { return done( new ErrorWithProps( diff --git a/src/utils/error.ts b/src/utils/error.ts index 59a7eaa..a074b42 100644 --- a/src/utils/error.ts +++ b/src/utils/error.ts @@ -109,12 +109,12 @@ export const errorPlugin: FastifyPluginAsync = fp.default(async (app) => { message: error.message }); } else { - this.log.error(error); reply.status(StatusCodes.INTERNAL_SERVER_ERROR).send({ code: ErrorWithPropsCodes.INTERNAL_SERVER_ERROR, message: 'An unspecified error occurred' }); } + this.log.error(error); }); }); diff --git a/src/utils/logger-factories.ts b/src/utils/logger-factories.ts index 3f5b12d..f366b99 100644 --- a/src/utils/logger-factories.ts +++ b/src/utils/logger-factories.ts @@ -18,6 +18,7 @@ import { getLogger } from './logger.js'; import { QueueName } from './queue.js'; export const getServiceLogger = (service: string) => getLogger().child({ service }); +export const getModuleLogger = (module: string) => getLogger().child({ module }); export const getQueueLogger = ({ service, queue }: { service: string; queue: QueueName }) => getServiceLogger(service).child({ queue });