Skip to content

Commit 2e23f89

Browse files
🔍 add trace id to some logs (#89)
* To more easily trace failures. This will be propagated to other areas in future commits
1 parent ddca073 commit 2e23f89

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

src/services/githubSync.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -464,11 +464,17 @@ export async function SyncTeam(teamName: string, client: InstalledClient, config
464464

465465
export async function SyncOrg(installedGitHubClient: InstalledClient, config: AppConfig, invitationsClient: IGitHubInvitations): Promise<ReturnTypeOfSyncOrg> {
466466
const orgName = installedGitHubClient.GetCurrentOrgName();
467+
468+
// For more context since this repo doesn't fully
469+
// follow OpenTelemetry, yet: https://opentelemetry.io/docs/concepts/signals/traces/
470+
const traceKey = crypto.randomUUID();
471+
467472
Log(JSON.stringify(
468473
{
469474
orgName: orgName,
470475
operation: "OrgSync",
471-
status: "Started"
476+
status: "Started",
477+
trace_id: traceKey
472478
}
473479
));
474480

@@ -480,18 +486,23 @@ export async function SyncOrg(installedGitHubClient: InstalledClient, config: Ap
480486
data: response,
481487
orgName: orgName,
482488
operation: "OrgSync",
483-
status: "completed"
489+
status: "completed",
490+
trace_id: traceKey
484491
}
485492
));
486493

487494
return response;
488495
}
489496
catch (error) {
490-
LogError(error as any);
497+
LogError(JSON.stringify({
498+
error: error as any,
499+
orgName: orgName,
500+
trace_id: traceKey
501+
}));
491502

492503
const response: ReturnTypeOfSyncOrg = {
493504
orgName: orgName,
494-
message: "Failed to sync org. Please check logs.",
505+
message: `Failed to sync org. Please check logs for Trace ID == ${traceKey}`,
495506
status: "failed",
496507
syncedSecurityManagerTeams: [],
497508
orgOwnersGroup: "",
@@ -504,7 +515,8 @@ export async function SyncOrg(installedGitHubClient: InstalledClient, config: Ap
504515
data: response,
505516
orgName: orgName,
506517
operation: "OrgSync",
507-
status: "failed"
518+
status: "failed",
519+
trace_id: traceKey
508520
}
509521
));
510522

0 commit comments

Comments
 (0)