Skip to content

Commit 3980c33

Browse files
committed
chore: remove log noise
1 parent 07cd38e commit 3980c33

3 files changed

Lines changed: 17 additions & 50 deletions

File tree

infrastructure/evault-core/src/core/db/db.service.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,11 @@ export class DbService {
4444
private async runQueryInternal(query: string, params: Record<string, any>) {
4545
const firstLine = query.trim().split("\n")[0].slice(0, 80);
4646
return timed(`db.query "${firstLine}"`, async () => {
47-
const session = await timed("db.session.open", async () =>
48-
this.driver.session(),
49-
);
47+
const session = this.driver.session();
5048
try {
51-
return await timed("db.session.run", () =>
52-
session.run(query, params),
53-
);
49+
return await session.run(query, params);
5450
} finally {
55-
await timed("db.session.close", () => session.close());
51+
await session.close();
5652
}
5753
});
5854
}

infrastructure/evault-core/src/core/protocol/vault-access-guard.ts

Lines changed: 10 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { YogaInitialContext } from "graphql-yoga";
33
import * as jose from "jose";
44
import type { DbService } from "../db/db.service";
55
import type { MetaEnvelope } from "../db/types";
6-
import { newTraceId, timed } from "../utils/timing";
6+
import { timed } from "../utils/timing";
77

88
export type VaultContext = YogaInitialContext & {
99
currentUser: string | null;
@@ -64,14 +64,9 @@ export class VaultAccessGuard {
6464
expiresAt: now + JWKS_TTL_MS,
6565
};
6666
jwksCache.set(jwksUrl, cached);
67-
} else {
68-
console.log("[timing] guard.validateToken.jwksCacheHit");
6967
}
7068

71-
const { payload } = await timed(
72-
"guard.validateToken.jwtVerify",
73-
() => jose.jwtVerify(token, cached!.jwks),
74-
);
69+
const { payload } = await jose.jwtVerify(token, cached.jwks);
7570

7671
return payload;
7772
} catch (error) {
@@ -252,13 +247,6 @@ export class VaultAccessGuard {
252247
) => Promise<any>,
253248
) {
254249
return async (parent: T, args: Args, context: VaultContext) => {
255-
const traceId = newTraceId("op");
256-
const opKind = args.id
257-
? "id-targeted"
258-
: args.envelopeId
259-
? "envelope-targeted"
260-
: "bulk";
261-
console.log(`[timing] ${traceId} guard.middleware.begin ${opKind}`);
262250
// Check if this is storeMetaEnvelope operation (has input with ontology, payload, acl)
263251
const isStoreOperation =
264252
args.input &&
@@ -269,20 +257,14 @@ export class VaultAccessGuard {
269257
!args.id; // storeMetaEnvelope doesn't have id, updateMetaEnvelopeById does
270258

271259
// CRITICAL: Validate authentication BEFORE executing any resolver
272-
await timed(
273-
"guard.validateAuthentication",
274-
() => this.validateAuthentication(context, isStoreOperation),
275-
traceId,
260+
await timed("guard.validateAuthentication", () =>
261+
this.validateAuthentication(context, isStoreOperation),
276262
);
277263

278264
// For operations that don't require a specific meta envelope ID (bulk queries)
279265
if (!args.id && !args.envelopeId) {
280266
// Authentication validated, now execute resolver
281-
const result = await timed(
282-
"guard.resolver(bulk)",
283-
() => resolver(parent, args, context),
284-
traceId,
285-
);
267+
const result = await resolver(parent, args, context);
286268

287269
// If the result is an array
288270
if (Array.isArray(result)) {
@@ -307,29 +289,19 @@ export class VaultAccessGuard {
307289
const metaEnvelopeId = args.id || args.envelopeId;
308290
if (!metaEnvelopeId) {
309291
// Authentication validated, now execute resolver
310-
const result = await timed(
311-
"guard.resolver(no-id)",
312-
() => resolver(parent, args, context),
313-
traceId,
314-
);
292+
const result = await resolver(parent, args, context);
315293
return this.filterACL(result);
316294
}
317295

318296
// Check if envelope exists and user has access
319-
const { hasAccess, exists } = await timed(
320-
"guard.checkAccess",
321-
() => this.checkAccess(metaEnvelopeId, context),
322-
traceId,
297+
const { hasAccess, exists } = await timed("guard.checkAccess", () =>
298+
this.checkAccess(metaEnvelopeId, context),
323299
);
324300

325301
// For update operations with input, allow in-place creation if envelope doesn't exist
326302
if (!exists && args.input) {
327303
// Envelope doesn't exist for this eName - allow in-place creation
328-
const result = await timed(
329-
"guard.resolver(in-place-create)",
330-
() => resolver(parent, args, context),
331-
traceId,
332-
);
304+
const result = await resolver(parent, args, context);
333305
return this.filterACL(result);
334306
}
335307

@@ -343,11 +315,7 @@ export class VaultAccessGuard {
343315
}
344316

345317
// Execute resolver and filter ACL
346-
const result = await timed(
347-
"guard.resolver(targeted)",
348-
() => resolver(parent, args, context),
349-
traceId,
350-
);
318+
const result = await resolver(parent, args, context);
351319

352320
// If result is null (envelope not found), return null
353321
if (result === null) {

infrastructure/evault-core/src/core/utils/timing.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
const ENABLED = process.env.EVAULT_TIMING !== "0";
2-
const SLOW_MS = Number(process.env.EVAULT_TIMING_SLOW_MS) || 0;
2+
const SLOW_MS =
3+
process.env.EVAULT_TIMING_SLOW_MS !== undefined
4+
? Number(process.env.EVAULT_TIMING_SLOW_MS)
5+
: 50;
36

47
let counter = 0;
58
export function newTraceId(prefix = "t"): string {

0 commit comments

Comments
 (0)