Skip to content

Commit ca51f65

Browse files
authored
Truncate ingested log messages to 4096, and truncate message to 256 in the summary tree view (#1604)
1 parent 46a37fd commit ca51f65

File tree

2 files changed

+44
-27
lines changed

2 files changed

+44
-27
lines changed

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

Lines changed: 41 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,25 @@ export type UpdateEventOptions = {
178178
events?: SpanEvents;
179179
};
180180

181+
type TaskEventSummary = Pick<
182+
TaskEvent,
183+
| "id"
184+
| "spanId"
185+
| "parentId"
186+
| "runId"
187+
| "idempotencyKey"
188+
| "message"
189+
| "style"
190+
| "startTime"
191+
| "duration"
192+
| "isError"
193+
| "isPartial"
194+
| "isCancelled"
195+
| "level"
196+
| "events"
197+
| "environmentType"
198+
>;
199+
181200
export class EventRepository {
182201
private readonly _flushScheduler: DynamicFlushScheduler<CreatableEvent>;
183202
private _randomIdGenerator = new RandomIdGenerator();
@@ -383,32 +402,28 @@ export class EventRepository {
383402

384403
public async getTraceSummary(traceId: string): Promise<TraceSummary | undefined> {
385404
return await startActiveSpan("getTraceSummary", async (span) => {
386-
const events = await this.readReplica.taskEvent.findMany({
387-
select: {
388-
id: true,
389-
spanId: true,
390-
parentId: true,
391-
runId: true,
392-
idempotencyKey: true,
393-
message: true,
394-
style: true,
395-
startTime: true,
396-
duration: true,
397-
isError: true,
398-
isPartial: true,
399-
isCancelled: true,
400-
level: true,
401-
events: true,
402-
environmentType: true,
403-
},
404-
where: {
405-
traceId,
406-
},
407-
orderBy: {
408-
startTime: "asc",
409-
},
410-
take: env.MAXIMUM_TRACE_SUMMARY_VIEW_COUNT,
411-
});
405+
const events = await this.readReplica.$queryRaw<TaskEventSummary[]>`
406+
SELECT
407+
id,
408+
"spanId",
409+
"parentId",
410+
"runId",
411+
"idempotencyKey",
412+
LEFT(message, 256) as message,
413+
style,
414+
"startTime",
415+
duration,
416+
"isError",
417+
"isPartial",
418+
"isCancelled",
419+
level,
420+
events,
421+
"environmentType"
422+
FROM "TaskEvent"
423+
WHERE "traceId" = ${traceId}
424+
ORDER BY "startTime" ASC
425+
LIMIT ${env.MAXIMUM_TRACE_SUMMARY_VIEW_COUNT}
426+
`;
412427

413428
let preparedEvents: Array<PreparedEvent> = [];
414429
let rootSpanId: string | undefined;

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,9 @@ function convertLogsToCreateableEvents(resourceLog: ResourceLogs): Array<Creatab
167167
traceId: binaryToHex(log.traceId),
168168
spanId: eventRepository.generateSpanId(),
169169
parentId: binaryToHex(log.spanId),
170-
message: isStringValue(log.body) ? log.body.stringValue : `${log.severityText} log`,
170+
message: isStringValue(log.body)
171+
? log.body.stringValue.slice(0, 4096)
172+
: `${log.severityText} log`,
171173
isPartial: false,
172174
kind: "INTERNAL" as const,
173175
level: logLevelToEventLevel(log.severityNumber),

0 commit comments

Comments
 (0)