MCPcopy
hub / github.com/simstudioai/sim / withDbSpan

Function withDbSpan

apps/sim/lib/copilot/async-runs/repository.ts:32–55  ·  view source on GitHub ↗
(
  name: string,
  op: string,
  table: string,
  attrs: Record<string, string | number | boolean | undefined>,
  fn: () => Promise<T>
)

Source from the content-addressed store, hash-verified

30// Cancellation is routed through `markSpanForError` so aborts record the
31// exception event but don't paint spans red.
32async 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
57export interface CreateRunSegmentInput {
58 id?: string

Callers 12

createRunSegmentFunction · 0.85
updateRunStatusFunction · 0.85
getLatestRunForExecutionFunction · 0.85
getRunSegmentFunction · 0.85
createRunCheckpointFunction · 0.85
upsertAsyncToolCallFunction · 0.85
getAsyncToolCallFunction · 0.85
markAsyncToolStatusFunction · 0.85
listAsyncToolCallsForRunFunction · 0.85
getAsyncToolCallsFunction · 0.85

Calls 5

filterUndefinedFunction · 0.90
markSpanForErrorFunction · 0.90
getAsyncRunsTracerFunction · 0.85
startSpanMethod · 0.80
fnFunction · 0.50

Tested by

no test coverage detected