Skip to content

Commit cd7f869

Browse files
committed
Actually collect worker_id and then make it a link to deployments when pretty formatting in Query. Also update the core columns for metrics in Query.
1 parent 7da856a commit cd7f869

File tree

7 files changed

+117
-23
lines changed

7 files changed

+117
-23
lines changed

apps/webapp/app/components/code/TSQLResultsTable.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,8 @@ function getDisplayLength(value: unknown, column: OutputColumnMetadata): number
300300
return typeof value === "string" ? Math.min(value.length, 20) : 12;
301301
case "queue":
302302
return typeof value === "string" ? Math.min(value.length, 25) : 15;
303+
case "deploymentId":
304+
return typeof value === "string" ? Math.min(value.length, 25) : 20;
303305
}
304306
}
305307

@@ -644,6 +646,19 @@ function CellValue({
644646
}
645647
return <span>{String(value)}</span>;
646648
}
649+
case "deploymentId": {
650+
if (typeof value === "string" && value.startsWith("deployment_")) {
651+
return (
652+
<SimpleTooltip
653+
content="Jump to deployment"
654+
disableHoverableContent
655+
hidden={!hovered}
656+
button={<TextLink to={`/deployments/${value}`}>{value}</TextLink>}
657+
/>
658+
);
659+
}
660+
return <span>{String(value)}</span>;
661+
}
647662
}
648663
}
649664

apps/webapp/app/env.server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ const EnvironmentSchema = z
384384
DEV_OTEL_LOG_EXPORT_TIMEOUT_MILLIS: z.string().default("30000"),
385385
DEV_OTEL_LOG_MAX_QUEUE_SIZE: z.string().default("512"),
386386
DEV_OTEL_METRICS_EXPORT_INTERVAL_MILLIS: z.string().optional(),
387+
DEV_OTEL_METRICS_EXPORT_TIMEOUT_MILLIS: z.string().optional(),
387388
DEV_OTEL_METRICS_COLLECTION_INTERVAL_MILLIS: z.string().optional(),
388389

389390
PROD_OTEL_BATCH_PROCESSING_ENABLED: z.string().default("0"),
@@ -396,6 +397,7 @@ const EnvironmentSchema = z
396397
PROD_OTEL_LOG_EXPORT_TIMEOUT_MILLIS: z.string().default("30000"),
397398
PROD_OTEL_LOG_MAX_QUEUE_SIZE: z.string().default("512"),
398399
PROD_OTEL_METRICS_EXPORT_INTERVAL_MILLIS: z.string().optional(),
400+
PROD_OTEL_METRICS_EXPORT_TIMEOUT_MILLIS: z.string().optional(),
399401
PROD_OTEL_METRICS_COLLECTION_INTERVAL_MILLIS: z.string().optional(),
400402

401403
TRIGGER_OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT: z.string().default("1024"),
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import { redirect, type LoaderFunctionArgs } from "@remix-run/server-runtime";
2+
import { z } from "zod";
3+
import { prisma } from "~/db.server";
4+
import { redirectWithErrorMessage } from "~/models/message.server";
5+
import { requireUser } from "~/services/session.server";
6+
import { rootPath, v3DeploymentPath } from "~/utils/pathBuilder";
7+
8+
const ParamsSchema = z.object({
9+
deploymentParam: z.string(),
10+
});
11+
12+
export async function loader({ params, request }: LoaderFunctionArgs) {
13+
const user = await requireUser(request);
14+
15+
const { deploymentParam } = ParamsSchema.parse(params);
16+
17+
const deployment = await prisma.workerDeployment.findFirst({
18+
where: {
19+
friendlyId: deploymentParam,
20+
project: {
21+
organization: {
22+
members: {
23+
some: {
24+
userId: user.id,
25+
},
26+
},
27+
},
28+
},
29+
},
30+
select: {
31+
shortCode: true,
32+
environment: {
33+
select: {
34+
slug: true,
35+
},
36+
},
37+
project: {
38+
select: {
39+
slug: true,
40+
organization: {
41+
select: {
42+
slug: true,
43+
},
44+
},
45+
},
46+
},
47+
},
48+
});
49+
50+
if (!deployment) {
51+
return redirectWithErrorMessage(
52+
rootPath(),
53+
request,
54+
"Deployment either doesn't exist or you don't have permission to view it",
55+
{
56+
ephemeral: false,
57+
}
58+
);
59+
}
60+
61+
return redirect(
62+
v3DeploymentPath(
63+
{ slug: deployment.project.organization.slug },
64+
{ slug: deployment.project.slug },
65+
{ slug: deployment.environment.slug },
66+
{ shortCode: deployment.shortCode },
67+
0
68+
)
69+
);
70+
}

apps/webapp/app/v3/environmentVariables/environmentVariablesRepository.server.ts

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -964,16 +964,17 @@ async function resolveBuiltInDevVariables(runtimeEnvironment: RuntimeEnvironment
964964
}
965965

966966
if (env.DEV_OTEL_METRICS_EXPORT_INTERVAL_MILLIS) {
967-
result.push(
968-
{
969-
key: "TRIGGER_OTEL_METRICS_EXPORT_INTERVAL_MILLIS",
970-
value: env.DEV_OTEL_METRICS_EXPORT_INTERVAL_MILLIS,
971-
},
972-
{
973-
key: "TRIGGER_OTEL_METRICS_EXPORT_TIMEOUT_MILLIS",
974-
value: env.DEV_OTEL_METRICS_EXPORT_INTERVAL_MILLIS,
975-
}
976-
);
967+
result.push({
968+
key: "TRIGGER_OTEL_METRICS_EXPORT_INTERVAL_MILLIS",
969+
value: env.DEV_OTEL_METRICS_EXPORT_INTERVAL_MILLIS,
970+
});
971+
}
972+
973+
if (env.DEV_OTEL_METRICS_EXPORT_TIMEOUT_MILLIS) {
974+
result.push({
975+
key: "TRIGGER_OTEL_METRICS_EXPORT_TIMEOUT_MILLIS",
976+
value: env.DEV_OTEL_METRICS_EXPORT_TIMEOUT_MILLIS,
977+
});
977978
}
978979

979980
if (env.DEV_OTEL_METRICS_COLLECTION_INTERVAL_MILLIS) {
@@ -1115,16 +1116,17 @@ async function resolveBuiltInProdVariables(
11151116
}
11161117

11171118
if (env.PROD_OTEL_METRICS_EXPORT_INTERVAL_MILLIS) {
1118-
result.push(
1119-
{
1120-
key: "TRIGGER_OTEL_METRICS_EXPORT_INTERVAL_MILLIS",
1121-
value: env.PROD_OTEL_METRICS_EXPORT_INTERVAL_MILLIS,
1122-
},
1123-
{
1124-
key: "TRIGGER_OTEL_METRICS_EXPORT_TIMEOUT_MILLIS",
1125-
value: env.PROD_OTEL_METRICS_EXPORT_INTERVAL_MILLIS,
1126-
}
1127-
);
1119+
result.push({
1120+
key: "TRIGGER_OTEL_METRICS_EXPORT_INTERVAL_MILLIS",
1121+
value: env.PROD_OTEL_METRICS_EXPORT_INTERVAL_MILLIS,
1122+
});
1123+
}
1124+
1125+
if (env.PROD_OTEL_METRICS_EXPORT_TIMEOUT_MILLIS) {
1126+
result.push({
1127+
key: "TRIGGER_OTEL_METRICS_EXPORT_TIMEOUT_MILLIS",
1128+
value: env.PROD_OTEL_METRICS_EXPORT_TIMEOUT_MILLIS,
1129+
});
11281130
}
11291131

11301132
if (env.PROD_OTEL_METRICS_COLLECTION_INTERVAL_MILLIS) {

apps/webapp/app/v3/querySchemas.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,13 +503,15 @@ export const metricsSchema: TableSchema = {
503503
...column("UInt64", {
504504
description: "Number of data points in this bucket",
505505
example: "6",
506+
coreColumn: true,
506507
}),
507508
},
508509
sum_value: {
509510
name: "sum_value",
510511
...column("Float64", {
511512
description: "Sum of values in this bucket",
512513
example: "0.45",
514+
coreColumn: true,
513515
}),
514516
},
515517
max_value: {
@@ -525,6 +527,7 @@ export const metricsSchema: TableSchema = {
525527
...column("Float64", {
526528
description: "Minimum value in this bucket",
527529
example: "0.12",
530+
coreColumn: true,
528531
}),
529532
},
530533
last_value: {
@@ -543,6 +546,7 @@ export const metricsSchema: TableSchema = {
543546
description: "The run ID associated with this metric",
544547
customRenderType: "runId",
545548
example: "run_cm1a2b3c4d5e6f7g8h9i",
549+
coreColumn: true,
546550
}),
547551
expression: "attributes.trigger.run_id",
548552
},
@@ -586,7 +590,8 @@ export const metricsSchema: TableSchema = {
586590
name: "worker_id",
587591
...column("String", {
588592
description: "The worker ID that produced this metric",
589-
example: "worker-abc123",
593+
customRenderType: "deploymentId",
594+
example: "deployment_cm1a2b3c4d5e",
590595
}),
591596
expression: "attributes.trigger.worker_id",
592597
},

packages/cli-v3/src/entryPoints/dev-run-controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ export class DevRunController {
596596
const { taskRunProcess, isReused } = await this.opts.taskRunProcessPool.getProcess(
597597
this.opts.worker.manifest,
598598
{
599-
id: "unmanaged",
599+
id: this.opts.worker.serverWorker.id,
600600
contentHash: this.opts.worker.build.contentHash,
601601
version: this.opts.worker.serverWorker?.version,
602602
engine: "V2",

packages/cli-v3/src/entryPoints/managed/taskRunProcessProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ export class TaskRunProcessProvider {
251251
workerManifest: this.workerManifest,
252252
env: processEnv,
253253
serverWorker: {
254-
id: "managed",
254+
id: this.env.TRIGGER_DEPLOYMENT_ID,
255255
contentHash: this.env.TRIGGER_CONTENT_HASH,
256256
version: this.env.TRIGGER_DEPLOYMENT_VERSION,
257257
engine: "V2",

0 commit comments

Comments
 (0)