Skip to content

Commit bb99437

Browse files
author
meorphis
committed
dd logs
1 parent 909cd5b commit bb99437

File tree

7 files changed

+154
-10
lines changed

7 files changed

+154
-10
lines changed

dist/build.js

Lines changed: 29 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/internalPreview.js

Lines changed: 33 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/merge.js

Lines changed: 29 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/preview.js

Lines changed: 29 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/comment.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ export function Result({
289289
: CompareLink(base, head)
290290
: null,
291291
MergeConflictLink(head),
292+
DatadogLogsLink(lang, base?.buildId, "base logs"),
293+
DatadogLogsLink(lang, head.buildId, "head logs"),
292294
]
293295
.filter((link): link is string => link !== null)
294296
.join(` ${MD.Symbol.MiddleDot} `),
@@ -465,6 +467,34 @@ function MergeConflictLink(outcome: Outcomes[string]): string | null {
465467
});
466468
}
467469

470+
function DatadogLogsLink(
471+
lang: string,
472+
buildId: string | null | undefined,
473+
text: string,
474+
): string | null {
475+
if (!buildId) return null;
476+
const query = `@jsonPayload.sdk.language:${lang} @jsonPayload.project_build.external_id:"${buildId}"`;
477+
const params = new URLSearchParams({
478+
query,
479+
agg_m: "count",
480+
agg_m_source: "base",
481+
agg_t: "count",
482+
clustering_pattern_field_path: "message",
483+
cols: "host,service",
484+
fromUser: "true",
485+
messageDisplay: "inline",
486+
refresh_mode: "paused",
487+
storage: "hot",
488+
stream_sort: "desc",
489+
viz: "stream",
490+
live: "false",
491+
});
492+
return MD.Link({
493+
text,
494+
href: `https://app.datadoghq.com/logs?${params.toString()}`,
495+
});
496+
}
497+
468498
function DiagnosticsDetails(
469499
head: Outcomes[string],
470500
base: Outcomes[string],

src/outcomes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export type Outcomes = Record<
1010
Omit<Stainless.Builds.BuildTarget, "commit"> & {
1111
commit: Stainless.Builds.BuildTarget.Completed | null;
1212
diagnostics: Stainless.Builds.Diagnostics.BuildDiagnostic[];
13+
buildId: string | null;
1314
hasDiff?: boolean;
1415
codegenCompareUrl?: string;
1516
diffStats?: { additions: number; deletions: number; changedFiles: number };

src/runBuilds.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ export async function* pollBuild({
325325
const outcomes: Outcomes = Object.fromEntries(
326326
languages.map((lang) => [
327327
lang,
328-
{ ...build.targets[lang]!, commit: null, diagnostics: [] },
328+
{ ...build.targets[lang]!, commit: null, diagnostics: [], buildId },
329329
]),
330330
);
331331

@@ -357,6 +357,7 @@ export async function* pollBuild({
357357

358358
outcomes[language] = {
359359
...buildOutput,
360+
buildId,
360361
commit: existing.commit,
361362
diagnostics: existing.diagnostics,
362363
};
@@ -426,6 +427,7 @@ export async function* pollBuild({
426427
const now = new Date().toISOString();
427428
outcomes[language] = {
428429
object: "build_target",
430+
buildId: outcomes[language]?.buildId ?? null,
429431
status: "completed",
430432
lint: {
431433
status: "not_started",

0 commit comments

Comments
 (0)