Skip to content

Commit a4497ed

Browse files
committed
Associate logs and spans with the machine id
1 parent 3bc200b commit a4497ed

File tree

5 files changed

+14
-0
lines changed

5 files changed

+14
-0
lines changed

apps/webapp/app/v3/eventRepository/clickhouseEventRepository.server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ export class ClickhouseEventRepository implements IEventRepository {
266266
expires_at: convertDateToClickhouseDateTime(
267267
new Date(Date.now() + 365 * 24 * 60 * 60 * 1000) // 1 year
268268
),
269+
machine_id: event.machineId ?? "",
269270
},
270271
...this.spanEventsToTaskEventV1Input(event),
271272
];

apps/webapp/app/v3/eventRepository/eventRepository.types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export type CreateEventInput = Omit<
5656
resourceProperties?: Attributes;
5757
metadata: Attributes | undefined;
5858
style: Attributes | undefined;
59+
machineId?: string;
5960
};
6061

6162
export type CreatableEventKind = TaskEventKind;

apps/webapp/app/v3/otlpExporter.server.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ function convertLogsToCreateableEvents(
331331
projectId: logProperties.projectId ?? resourceProperties.projectId ?? "unknown",
332332
runId: logProperties.runId ?? resourceProperties.runId ?? "unknown",
333333
taskSlug: logProperties.taskSlug ?? resourceProperties.taskSlug ?? "unknown",
334+
machineId: logProperties.machineId ?? resourceProperties.machineId,
334335
attemptNumber:
335336
extractNumberAttribute(
336337
log.attributes ?? [],
@@ -437,6 +438,7 @@ function convertSpansToCreateableEvents(
437438
projectId: spanProperties.projectId ?? resourceProperties.projectId ?? "unknown",
438439
runId: spanProperties.runId ?? resourceProperties.runId ?? "unknown",
439440
taskSlug: spanProperties.taskSlug ?? resourceProperties.taskSlug ?? "unknown",
441+
machineId: spanProperties.machineId ?? resourceProperties.machineId,
440442
attemptNumber:
441443
extractNumberAttribute(
442444
span.attributes ?? [],
@@ -672,6 +674,7 @@ function extractEventProperties(attributes: KeyValue[], prefix?: string) {
672674
SemanticInternalAttributes.ATTEMPT_NUMBER,
673675
]),
674676
taskSlug: extractStringAttribute(attributes, [prefix, SemanticInternalAttributes.TASK_SLUG]),
677+
machineId: extractStringAttribute(attributes, [prefix, SemanticInternalAttributes.MACHINE_ID]),
675678
};
676679
}
677680

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-- +goose Up
2+
ALTER TABLE trigger_dev.task_events_v2
3+
ADD COLUMN machine_id String DEFAULT '' CODEC(ZSTD(1));
4+
5+
-- +goose Down
6+
ALTER TABLE trigger_dev.task_events_v2
7+
DROP COLUMN machine_id;

internal-packages/clickhouse/src/taskEvents.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export const TaskEventV1Input = z.object({
1919
attributes: z.unknown(),
2020
metadata: z.string(),
2121
expires_at: z.string(),
22+
machine_id: z.string().optional(),
2223
});
2324

2425
export type TaskEventV1Input = z.input<typeof TaskEventV1Input>;
@@ -153,6 +154,7 @@ export const TaskEventV2Input = z.object({
153154
attributes: z.unknown(),
154155
metadata: z.string(),
155156
expires_at: z.string(),
157+
machine_id: z.string().optional(),
156158
// inserted_at has a default value in the table, so it's optional for inserts
157159
inserted_at: z.string().optional(),
158160
});

0 commit comments

Comments
 (0)