File tree Expand file tree Collapse file tree 2 files changed +44
-27
lines changed Expand file tree Collapse file tree 2 files changed +44
-27
lines changed Original file line number Diff line number Diff 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+
181200export 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 ;
Original file line number Diff line number Diff 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 ) ,
You can’t perform that action at this time.
0 commit comments