Skip to content

Commit

Permalink
fix(Observe): remove observe not found error logs (#149)
Browse files Browse the repository at this point in the history
Signed-off-by: Milan Gallas <[email protected]>
  • Loading branch information
GALLLASMILAN authored Jan 9, 2025
1 parent b611ab9 commit f50e20d
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/observe/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import { FetchResponse } from 'openapi-fetch';
import { FastifyReply } from 'fastify';
import { StatusCodes } from 'http-status-codes';

import { Client } from './api/client.js';

Expand Down Expand Up @@ -61,20 +62,21 @@ function isAPIErrorCode(value: any): value is APIErrorCode {

type MediaType = `${string}/${string}`;
export async function processApiProxyResponse<T, O, M extends MediaType>(
response: Promise<FetchResponse<T, O, M>>,
fetchResponse: Promise<FetchResponse<T, O, M>>,
reply: FastifyReply
): Promise<FetchResponse<T, O, M>['data']> {
const {
data,
error,
response: { headers }
} = await response;
const { data, error, response } = await fetchResponse;

// apply only allowed headers from Observe API response
reply.headers(pickHeaders(headers, ['Retry-After']));
reply.headers(pickHeaders(response.headers, ['Retry-After']));

if (error) {
getTraceLogger().error({ err: error }, 'Observe API: Invalid response');
if (response.status === StatusCodes.NOT_FOUND) {
getTraceLogger().trace({ err: error }, 'The trace does not exist in the Observe yet');
} else {
getTraceLogger().error({ err: error }, 'Observe API: Invalid response');
}

const errorCode = error.code.toLocaleLowerCase();

throw new APIError(
Expand Down

0 comments on commit f50e20d

Please sign in to comment.