( name: string, op: string, table: string, attrs: Record<string, string | number | boolean | undefined>, fn: () => Promise<T> )
| 30 | // Cancellation is routed through `markSpanForError` so aborts record the |
| 31 | // exception event but don't paint spans red. |
| 32 | async function withDbSpan<T>( |
| 33 | name: string, |
| 34 | op: string, |
| 35 | table: string, |
| 36 | attrs: Record<string, string | number | boolean | undefined>, |
| 37 | fn: () => Promise<T> |
| 38 | ): Promise<T> { |
| 39 | const span = getAsyncRunsTracer().startSpan(name, { |
| 40 | attributes: { |
| 41 | [TraceAttr.DbSystem]: 'postgresql', |
| 42 | [TraceAttr.DbOperation]: op, |
| 43 | [TraceAttr.DbSqlTable]: table, |
| 44 | ...filterUndefined(attrs), |
| 45 | }, |
| 46 | }) |
| 47 | try { |
| 48 | return await fn() |
| 49 | } catch (error) { |
| 50 | markSpanForError(span, error) |
| 51 | throw error |
| 52 | } finally { |
| 53 | span.end() |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | export interface CreateRunSegmentInput { |
| 58 | id?: string |
no test coverage detected