MCPcopy Create free account
hub / github.com/Noumena-Network/code / addToolContentEvent

Function addToolContentEvent

src/utils/telemetry/sessionTracing.ts:748–777  ·  view source on GitHub ↗
(
  eventName: string,
  attributes: Record<string, string | number | boolean>,
)

Source from the content-addressed store, hash-verified

746 * Truncates content if it exceeds MAX_CONTENT_SIZE.
747 */
748export function addToolContentEvent(
749 eventName: string,
750 attributes: Record<string, string | number | boolean>,
751): void {
752 if (!isAnyTracingEnabled() || !isToolContentLoggingEnabled()) {
753 return
754 }
755
756 const currentSpanCtx = toolContext.getStore()
757 if (!currentSpanCtx) {
758 return
759 }
760
761 // Truncate string attributes that might be large
762 const processedAttributes: Record<string, string | number | boolean> = {}
763 for (const [key, value] of Object.entries(attributes)) {
764 if (typeof value === 'string') {
765 const { content, truncated } = truncateContent(value)
766 processedAttributes[key] = content
767 if (truncated) {
768 processedAttributes[`${key}_truncated`] = true
769 processedAttributes[`${key}_original_length`] = value.length
770 }
771 } else {
772 processedAttributes[key] = value
773 }
774 }
775
776 currentSpanCtx.span.addEvent(eventName, processedAttributes)
777}
778
779export function getCurrentSpan(): Span | null {
780 if (!isAnyTracingEnabled()) {

Callers 1

Calls 4

isAnyTracingEnabledFunction · 0.85
truncateContentFunction · 0.85
entriesMethod · 0.80

Tested by

no test coverage detected