MCPcopy Create free account
hub / github.com/contentlayerdev/contentlayer / addArgsToSpan

Function addArgsToSpan

packages/@contentlayer/utils/src/tracing.ts:79–93  ·  view source on GitHub ↗
(span: Span, argsMapper: ArgKeysOrArgsMapper<any>, args: any[])

Source from the content-addressed store, hash-verified

77}
78
79const addArgsToSpan = (span: Span, argsMapper: ArgKeysOrArgsMapper<any>, args: any[]): void => {
80 const args_ = Array.isArray(argsMapper)
81 ? Object.fromEntries(argsMapper.map((key) => [key, args[0][key]]))
82 : argsMapper(...args)
83
84 try {
85 if (Array.isArray(args_)) {
86 for (const [key, arg] of args_.entries()) {
87 span.setAttribute(`args.${key}`, JSON.stringify(arg, null, 2))
88 }
89 } else {
90 span.setAttribute(`args`, JSON.stringify(args_, null, 2))
91 }
92 } catch (_) {}
93}

Callers 2

traceAsyncFnFunction · 0.85
traceFnFunction · 0.85

Calls 1

mapMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…