Skip to content

Commit

Permalink
Fix Sentry and add trace propagation
Browse files Browse the repository at this point in the history
  • Loading branch information
thaddeus committed Aug 10, 2024
1 parent 8ea269b commit a12afba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 0 additions & 2 deletions http/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ import cluster from 'node:cluster';
import os from 'node:os';
import * as Sentry from "@sentry/node";
import "./instrument.mjs";
import express from 'express';
import { createServer } from 'node:http';

import 'dotenv/config';

import getYoga from '../graphql-yoga.mjs';
import getEnv from './env-binding.mjs';
import * as Sentry from "@sentry/node";

const port = process.env.PORT ?? 8788;
const workerCount = parseInt(process.env.WORKERS ?? String(os.cpus().length - 1));
Expand Down
8 changes: 5 additions & 3 deletions utils/cache-machine.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ async function updateCache(env, query, variables, body, ttl = '', specialCache =
method: 'POST',
headers: {
'content-type': 'application/json;charset=UTF-8',
'Authorization': `Basic ${env.CACHE_BASIC_AUTH}`
'Authorization': `Basic ${env.CACHE_BASIC_AUTH}`,
'sentry-trace': Sentry.getCurrentHub().getScope().getSpan().toTraceparent(),
'baggage': Sentry.getCurrentHub().getScope().getSpan().toBaggageHeader()
},
timeout: 10000,
};
Expand Down Expand Up @@ -109,11 +111,11 @@ async function checkCache(env, query, variables, specialCache = '') {
return false;
}

const response = await fetchWithTimeout(`${cacheUrl}/api/cache?key=${cacheKey}`, {
const response = await fetchWithTimeout(`${cacheUrl}/api/cache?key=${cacheKey}`, {
headers: {
'content-type': 'application/json;charset=UTF-8',
'Authorization': `Basic ${env.CACHE_BASIC_AUTH}`
},
},
});
cacheFailCount = 0;
if (response.status === 200) {
Expand Down

0 comments on commit a12afba

Please sign in to comment.