shield360 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +310 -0
- package/dist/__tests__/manual-trace.test.d.ts +1 -0
- package/dist/__tests__/manual-trace.test.js +118 -0
- package/dist/__tests__/manual-trace.test.js.map +1 -0
- package/dist/__tests__/register.test.d.ts +0 -0
- package/dist/__tests__/register.test.js +90 -0
- package/dist/__tests__/register.test.js.map +1 -0
- package/dist/config.d.ts +28 -0
- package/dist/config.js +22 -0
- package/dist/config.js.map +1 -0
- package/dist/constant.d.ts +6 -0
- package/dist/constant.js +14 -0
- package/dist/constant.js.map +1 -0
- package/dist/evals/__tests__/offline.test.d.ts +1 -0
- package/dist/evals/__tests__/offline.test.js +427 -0
- package/dist/evals/__tests__/offline.test.js.map +1 -0
- package/dist/evals/index.d.ts +2 -0
- package/dist/evals/index.js +15 -0
- package/dist/evals/index.js.map +1 -0
- package/dist/evals/offline.d.ts +6 -0
- package/dist/evals/offline.js +350 -0
- package/dist/evals/offline.js.map +1 -0
- package/dist/evals/types.d.ts +74 -0
- package/dist/evals/types.js +23 -0
- package/dist/evals/types.js.map +1 -0
- package/dist/features/__tests__/rule-engine.test.d.ts +1 -0
- package/dist/features/__tests__/rule-engine.test.js +146 -0
- package/dist/features/__tests__/rule-engine.test.js.map +1 -0
- package/dist/features/base.d.ts +8 -0
- package/dist/features/base.js +15 -0
- package/dist/features/base.js.map +1 -0
- package/dist/features/prompt-hub.d.ts +4 -0
- package/dist/features/prompt-hub.js +66 -0
- package/dist/features/prompt-hub.js.map +1 -0
- package/dist/features/rule-engine.d.ts +6 -0
- package/dist/features/rule-engine.js +60 -0
- package/dist/features/rule-engine.js.map +1 -0
- package/dist/features/vault.d.ts +4 -0
- package/dist/features/vault.js +63 -0
- package/dist/features/vault.js.map +1 -0
- package/dist/guard/__tests__/findings.test.d.ts +1 -0
- package/dist/guard/__tests__/findings.test.js +79 -0
- package/dist/guard/__tests__/findings.test.js.map +1 -0
- package/dist/guard/__tests__/integration.test.d.ts +1 -0
- package/dist/guard/__tests__/integration.test.js +215 -0
- package/dist/guard/__tests__/integration.test.js.map +1 -0
- package/dist/guard/__tests__/pii.test.d.ts +1 -0
- package/dist/guard/__tests__/pii.test.js +131 -0
- package/dist/guard/__tests__/pii.test.js.map +1 -0
- package/dist/guard/__tests__/pipeline.test.d.ts +1 -0
- package/dist/guard/__tests__/pipeline.test.js +162 -0
- package/dist/guard/__tests__/pipeline.test.js.map +1 -0
- package/dist/guard/__tests__/prompt-injection.test.d.ts +1 -0
- package/dist/guard/__tests__/prompt-injection.test.js +92 -0
- package/dist/guard/__tests__/prompt-injection.test.js.map +1 -0
- package/dist/guard/__tests__/report.test.d.ts +1 -0
- package/dist/guard/__tests__/report.test.js +50 -0
- package/dist/guard/__tests__/report.test.js.map +1 -0
- package/dist/guard/base.d.ts +79 -0
- package/dist/guard/base.js +136 -0
- package/dist/guard/base.js.map +1 -0
- package/dist/guard/custom.d.ts +19 -0
- package/dist/guard/custom.js +46 -0
- package/dist/guard/custom.js.map +1 -0
- package/dist/guard/findings.d.ts +31 -0
- package/dist/guard/findings.js +156 -0
- package/dist/guard/findings.js.map +1 -0
- package/dist/guard/index.d.ts +24 -0
- package/dist/guard/index.js +42 -0
- package/dist/guard/index.js.map +1 -0
- package/dist/guard/integration.d.ts +44 -0
- package/dist/guard/integration.js +363 -0
- package/dist/guard/integration.js.map +1 -0
- package/dist/guard/moderation.d.ts +18 -0
- package/dist/guard/moderation.js +61 -0
- package/dist/guard/moderation.js.map +1 -0
- package/dist/guard/pii.d.ts +17 -0
- package/dist/guard/pii.js +114 -0
- package/dist/guard/pii.js.map +1 -0
- package/dist/guard/pipeline.d.ts +26 -0
- package/dist/guard/pipeline.js +139 -0
- package/dist/guard/pipeline.js.map +1 -0
- package/dist/guard/prompt-injection.d.ts +21 -0
- package/dist/guard/prompt-injection.js +70 -0
- package/dist/guard/prompt-injection.js.map +1 -0
- package/dist/guard/report.d.ts +34 -0
- package/dist/guard/report.js +182 -0
- package/dist/guard/report.js.map +1 -0
- package/dist/guard/schema.d.ts +20 -0
- package/dist/guard/schema.js +99 -0
- package/dist/guard/schema.js.map +1 -0
- package/dist/guard/sensitive-topic.d.ts +23 -0
- package/dist/guard/sensitive-topic.js +89 -0
- package/dist/guard/sensitive-topic.js.map +1 -0
- package/dist/guard/topic-restriction.d.ts +22 -0
- package/dist/guard/topic-restriction.js +54 -0
- package/dist/guard/topic-restriction.js.map +1 -0
- package/dist/helpers.d.ts +246 -0
- package/dist/helpers.js +903 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.d.ts +71 -0
- package/dist/index.js +234 -0
- package/dist/index.js.map +1 -0
- package/dist/instrumentation/__tests__/ai21-rag-trace-comparison.test.d.ts +13 -0
- package/dist/instrumentation/__tests__/ai21-rag-trace-comparison.test.js +176 -0
- package/dist/instrumentation/__tests__/ai21-rag-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/ai21-trace-comparison.test.d.ts +10 -0
- package/dist/instrumentation/__tests__/ai21-trace-comparison.test.js +203 -0
- package/dist/instrumentation/__tests__/ai21-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/anthropic-wrapper.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/anthropic-wrapper.test.js +284 -0
- package/dist/instrumentation/__tests__/anthropic-wrapper.test.js.map +1 -0
- package/dist/instrumentation/__tests__/assemblyai-wrapper.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/assemblyai-wrapper.test.js +284 -0
- package/dist/instrumentation/__tests__/assemblyai-wrapper.test.js.map +1 -0
- package/dist/instrumentation/__tests__/astra-trace-comparison.test.d.ts +7 -0
- package/dist/instrumentation/__tests__/astra-trace-comparison.test.js +160 -0
- package/dist/instrumentation/__tests__/astra-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/base-wrapper.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/base-wrapper.test.js +171 -0
- package/dist/instrumentation/__tests__/base-wrapper.test.js.map +1 -0
- package/dist/instrumentation/__tests__/bedrock-trace-comparison.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/bedrock-trace-comparison.test.js +422 -0
- package/dist/instrumentation/__tests__/bedrock-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/browser-use-wrapper.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/browser-use-wrapper.test.js +284 -0
- package/dist/instrumentation/__tests__/browser-use-wrapper.test.js.map +1 -0
- package/dist/instrumentation/__tests__/cache-pricing.test.d.ts +15 -0
- package/dist/instrumentation/__tests__/cache-pricing.test.js +155 -0
- package/dist/instrumentation/__tests__/cache-pricing.test.js.map +1 -0
- package/dist/instrumentation/__tests__/chroma-trace-comparison.test.d.ts +18 -0
- package/dist/instrumentation/__tests__/chroma-trace-comparison.test.js +209 -0
- package/dist/instrumentation/__tests__/chroma-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/cohere-wrapper.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/cohere-wrapper.test.js +256 -0
- package/dist/instrumentation/__tests__/cohere-wrapper.test.js.map +1 -0
- package/dist/instrumentation/__tests__/elevenlabs-wrapper.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/elevenlabs-wrapper.test.js +282 -0
- package/dist/instrumentation/__tests__/elevenlabs-wrapper.test.js.map +1 -0
- package/dist/instrumentation/__tests__/firecrawl-wrapper.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/firecrawl-wrapper.test.js +238 -0
- package/dist/instrumentation/__tests__/firecrawl-wrapper.test.js.map +1 -0
- package/dist/instrumentation/__tests__/google-ai-trace-comparison.test.d.ts +4 -0
- package/dist/instrumentation/__tests__/google-ai-trace-comparison.test.js +229 -0
- package/dist/instrumentation/__tests__/google-ai-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/gpu-collector.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/gpu-collector.test.js +247 -0
- package/dist/instrumentation/__tests__/gpu-collector.test.js.map +1 -0
- package/dist/instrumentation/__tests__/gradient-trace-comparison.test.d.ts +11 -0
- package/dist/instrumentation/__tests__/gradient-trace-comparison.test.js +391 -0
- package/dist/instrumentation/__tests__/gradient-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/groq-trace-comparison.test.d.ts +7 -0
- package/dist/instrumentation/__tests__/groq-trace-comparison.test.js +687 -0
- package/dist/instrumentation/__tests__/groq-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/helpers-genai.test.d.ts +14 -0
- package/dist/instrumentation/__tests__/helpers-genai.test.js +347 -0
- package/dist/instrumentation/__tests__/helpers-genai.test.js.map +1 -0
- package/dist/instrumentation/__tests__/huggingface-trace-comparison.test.d.ts +7 -0
- package/dist/instrumentation/__tests__/huggingface-trace-comparison.test.js +529 -0
- package/dist/instrumentation/__tests__/huggingface-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/langchain-role-map.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/langchain-role-map.test.js +19 -0
- package/dist/instrumentation/__tests__/langchain-role-map.test.js.map +1 -0
- package/dist/instrumentation/__tests__/langchain-wrapper.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/langchain-wrapper.test.js +282 -0
- package/dist/instrumentation/__tests__/langchain-wrapper.test.js.map +1 -0
- package/dist/instrumentation/__tests__/letta-wrapper.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/letta-wrapper.test.js +285 -0
- package/dist/instrumentation/__tests__/letta-wrapper.test.js.map +1 -0
- package/dist/instrumentation/__tests__/mem0-trace-comparison.test.d.ts +13 -0
- package/dist/instrumentation/__tests__/mem0-trace-comparison.test.js +208 -0
- package/dist/instrumentation/__tests__/mem0-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/milvus-trace-comparison.test.d.ts +17 -0
- package/dist/instrumentation/__tests__/milvus-trace-comparison.test.js +206 -0
- package/dist/instrumentation/__tests__/milvus-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/mistral-trace-comparison.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/mistral-trace-comparison.test.js +345 -0
- package/dist/instrumentation/__tests__/mistral-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/openai-wrapper.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/openai-wrapper.test.js +179 -0
- package/dist/instrumentation/__tests__/openai-wrapper.test.js.map +1 -0
- package/dist/instrumentation/__tests__/pg-trace-comparison.test.d.ts +21 -0
- package/dist/instrumentation/__tests__/pg-trace-comparison.test.js +455 -0
- package/dist/instrumentation/__tests__/pg-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/qdrant-trace-comparison.test.d.ts +17 -0
- package/dist/instrumentation/__tests__/qdrant-trace-comparison.test.js +182 -0
- package/dist/instrumentation/__tests__/qdrant-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/replicate-trace-comparison.test.d.ts +8 -0
- package/dist/instrumentation/__tests__/replicate-trace-comparison.test.js +346 -0
- package/dist/instrumentation/__tests__/replicate-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/together-trace-comparison.test.d.ts +4 -0
- package/dist/instrumentation/__tests__/together-trace-comparison.test.js +289 -0
- package/dist/instrumentation/__tests__/together-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/trace-comparison-utils.d.ts +67 -0
- package/dist/instrumentation/__tests__/trace-comparison-utils.js +255 -0
- package/dist/instrumentation/__tests__/trace-comparison-utils.js.map +1 -0
- package/dist/instrumentation/__tests__/transformers-trace-comparison.test.d.ts +11 -0
- package/dist/instrumentation/__tests__/transformers-trace-comparison.test.js +214 -0
- package/dist/instrumentation/__tests__/transformers-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/vercel-ai-trace-comparison.test.d.ts +8 -0
- package/dist/instrumentation/__tests__/vercel-ai-trace-comparison.test.js +446 -0
- package/dist/instrumentation/__tests__/vercel-ai-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/vertexai-trace-comparison.test.d.ts +6 -0
- package/dist/instrumentation/__tests__/vertexai-trace-comparison.test.js +409 -0
- package/dist/instrumentation/__tests__/vertexai-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/vllm-trace-comparison.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/vllm-trace-comparison.test.js +519 -0
- package/dist/instrumentation/__tests__/vllm-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/ai21/index.d.ts +11 -0
- package/dist/instrumentation/ai21/index.js +67 -0
- package/dist/instrumentation/ai21/index.js.map +1 -0
- package/dist/instrumentation/ai21/wrapper.d.ts +54 -0
- package/dist/instrumentation/ai21/wrapper.js +511 -0
- package/dist/instrumentation/ai21/wrapper.js.map +1 -0
- package/dist/instrumentation/anthropic/index.d.ts +11 -0
- package/dist/instrumentation/anthropic/index.js +45 -0
- package/dist/instrumentation/anthropic/index.js.map +1 -0
- package/dist/instrumentation/anthropic/wrapper.d.ts +34 -0
- package/dist/instrumentation/anthropic/wrapper.js +426 -0
- package/dist/instrumentation/anthropic/wrapper.js.map +1 -0
- package/dist/instrumentation/assemblyai/index.d.ts +12 -0
- package/dist/instrumentation/assemblyai/index.js +91 -0
- package/dist/instrumentation/assemblyai/index.js.map +1 -0
- package/dist/instrumentation/assemblyai/wrapper.d.ts +35 -0
- package/dist/instrumentation/assemblyai/wrapper.js +238 -0
- package/dist/instrumentation/assemblyai/wrapper.js.map +1 -0
- package/dist/instrumentation/astra/index.d.ts +11 -0
- package/dist/instrumentation/astra/index.js +87 -0
- package/dist/instrumentation/astra/index.js.map +1 -0
- package/dist/instrumentation/astra/wrapper.d.ts +39 -0
- package/dist/instrumentation/astra/wrapper.js +349 -0
- package/dist/instrumentation/astra/wrapper.js.map +1 -0
- package/dist/instrumentation/azure-ai-inference/index.d.ts +11 -0
- package/dist/instrumentation/azure-ai-inference/index.js +76 -0
- package/dist/instrumentation/azure-ai-inference/index.js.map +1 -0
- package/dist/instrumentation/azure-ai-inference/wrapper.d.ts +55 -0
- package/dist/instrumentation/azure-ai-inference/wrapper.js +580 -0
- package/dist/instrumentation/azure-ai-inference/wrapper.js.map +1 -0
- package/dist/instrumentation/base-wrapper.d.ts +16 -0
- package/dist/instrumentation/base-wrapper.js +139 -0
- package/dist/instrumentation/base-wrapper.js.map +1 -0
- package/dist/instrumentation/bedrock/index.d.ts +11 -0
- package/dist/instrumentation/bedrock/index.js +52 -0
- package/dist/instrumentation/bedrock/index.js.map +1 -0
- package/dist/instrumentation/bedrock/wrapper.d.ts +41 -0
- package/dist/instrumentation/bedrock/wrapper.js +494 -0
- package/dist/instrumentation/bedrock/wrapper.js.map +1 -0
- package/dist/instrumentation/browser-use/index.d.ts +11 -0
- package/dist/instrumentation/browser-use/index.js +98 -0
- package/dist/instrumentation/browser-use/index.js.map +1 -0
- package/dist/instrumentation/browser-use/wrapper.d.ts +12 -0
- package/dist/instrumentation/browser-use/wrapper.js +706 -0
- package/dist/instrumentation/browser-use/wrapper.js.map +1 -0
- package/dist/instrumentation/chroma/index.d.ts +11 -0
- package/dist/instrumentation/chroma/index.js +70 -0
- package/dist/instrumentation/chroma/index.js.map +1 -0
- package/dist/instrumentation/chroma/wrapper.d.ts +10 -0
- package/dist/instrumentation/chroma/wrapper.js +127 -0
- package/dist/instrumentation/chroma/wrapper.js.map +1 -0
- package/dist/instrumentation/claude-agent-sdk/index.d.ts +23 -0
- package/dist/instrumentation/claude-agent-sdk/index.js +83 -0
- package/dist/instrumentation/claude-agent-sdk/index.js.map +1 -0
- package/dist/instrumentation/claude-agent-sdk/wrapper.d.ts +13 -0
- package/dist/instrumentation/claude-agent-sdk/wrapper.js +1123 -0
- package/dist/instrumentation/claude-agent-sdk/wrapper.js.map +1 -0
- package/dist/instrumentation/cohere/index.d.ts +11 -0
- package/dist/instrumentation/cohere/index.js +53 -0
- package/dist/instrumentation/cohere/index.js.map +1 -0
- package/dist/instrumentation/cohere/wrapper.d.ts +50 -0
- package/dist/instrumentation/cohere/wrapper.js +452 -0
- package/dist/instrumentation/cohere/wrapper.js.map +1 -0
- package/dist/instrumentation/cursor-sdk/index.d.ts +21 -0
- package/dist/instrumentation/cursor-sdk/index.js +58 -0
- package/dist/instrumentation/cursor-sdk/index.js.map +1 -0
- package/dist/instrumentation/cursor-sdk/wrapper.d.ts +17 -0
- package/dist/instrumentation/cursor-sdk/wrapper.js +789 -0
- package/dist/instrumentation/cursor-sdk/wrapper.js.map +1 -0
- package/dist/instrumentation/elevenlabs/index.d.ts +12 -0
- package/dist/instrumentation/elevenlabs/index.js +92 -0
- package/dist/instrumentation/elevenlabs/index.js.map +1 -0
- package/dist/instrumentation/elevenlabs/wrapper.d.ts +34 -0
- package/dist/instrumentation/elevenlabs/wrapper.js +280 -0
- package/dist/instrumentation/elevenlabs/wrapper.js.map +1 -0
- package/dist/instrumentation/firecrawl/index.d.ts +13 -0
- package/dist/instrumentation/firecrawl/index.js +115 -0
- package/dist/instrumentation/firecrawl/index.js.map +1 -0
- package/dist/instrumentation/firecrawl/wrapper.d.ts +22 -0
- package/dist/instrumentation/firecrawl/wrapper.js +378 -0
- package/dist/instrumentation/firecrawl/wrapper.js.map +1 -0
- package/dist/instrumentation/google-adk/index.d.ts +57 -0
- package/dist/instrumentation/google-adk/index.js +371 -0
- package/dist/instrumentation/google-adk/index.js.map +1 -0
- package/dist/instrumentation/google-adk/utils.d.ts +45 -0
- package/dist/instrumentation/google-adk/utils.js +663 -0
- package/dist/instrumentation/google-adk/utils.js.map +1 -0
- package/dist/instrumentation/google-adk/wrapper.d.ts +11 -0
- package/dist/instrumentation/google-adk/wrapper.js +391 -0
- package/dist/instrumentation/google-adk/wrapper.js.map +1 -0
- package/dist/instrumentation/google-ai/index.d.ts +11 -0
- package/dist/instrumentation/google-ai/index.js +48 -0
- package/dist/instrumentation/google-ai/index.js.map +1 -0
- package/dist/instrumentation/google-ai/wrapper.d.ts +52 -0
- package/dist/instrumentation/google-ai/wrapper.js +466 -0
- package/dist/instrumentation/google-ai/wrapper.js.map +1 -0
- package/dist/instrumentation/gpu/index.d.ts +38 -0
- package/dist/instrumentation/gpu/index.js +233 -0
- package/dist/instrumentation/gpu/index.js.map +1 -0
- package/dist/instrumentation/gradient/index.d.ts +12 -0
- package/dist/instrumentation/gradient/index.js +74 -0
- package/dist/instrumentation/gradient/index.js.map +1 -0
- package/dist/instrumentation/gradient/utils.d.ts +14 -0
- package/dist/instrumentation/gradient/utils.js +119 -0
- package/dist/instrumentation/gradient/utils.js.map +1 -0
- package/dist/instrumentation/gradient/wrapper.d.ts +76 -0
- package/dist/instrumentation/gradient/wrapper.js +584 -0
- package/dist/instrumentation/gradient/wrapper.js.map +1 -0
- package/dist/instrumentation/groq/index.d.ts +11 -0
- package/dist/instrumentation/groq/index.js +43 -0
- package/dist/instrumentation/groq/index.js.map +1 -0
- package/dist/instrumentation/groq/wrapper.d.ts +35 -0
- package/dist/instrumentation/groq/wrapper.js +442 -0
- package/dist/instrumentation/groq/wrapper.js.map +1 -0
- package/dist/instrumentation/huggingface/index.d.ts +13 -0
- package/dist/instrumentation/huggingface/index.js +110 -0
- package/dist/instrumentation/huggingface/index.js.map +1 -0
- package/dist/instrumentation/huggingface/wrapper.d.ts +54 -0
- package/dist/instrumentation/huggingface/wrapper.js +514 -0
- package/dist/instrumentation/huggingface/wrapper.js.map +1 -0
- package/dist/instrumentation/index.d.ts +7 -0
- package/dist/instrumentation/index.js +176 -0
- package/dist/instrumentation/index.js.map +1 -0
- package/dist/instrumentation/langchain/index.d.ts +16 -0
- package/dist/instrumentation/langchain/index.js +91 -0
- package/dist/instrumentation/langchain/index.js.map +1 -0
- package/dist/instrumentation/langchain/wrapper.d.ts +41 -0
- package/dist/instrumentation/langchain/wrapper.js +1235 -0
- package/dist/instrumentation/langchain/wrapper.js.map +1 -0
- package/dist/instrumentation/langgraph/index.d.ts +12 -0
- package/dist/instrumentation/langgraph/index.js +99 -0
- package/dist/instrumentation/langgraph/index.js.map +1 -0
- package/dist/instrumentation/langgraph/wrapper.d.ts +20 -0
- package/dist/instrumentation/langgraph/wrapper.js +620 -0
- package/dist/instrumentation/langgraph/wrapper.js.map +1 -0
- package/dist/instrumentation/letta/index.d.ts +10 -0
- package/dist/instrumentation/letta/index.js +122 -0
- package/dist/instrumentation/letta/index.js.map +1 -0
- package/dist/instrumentation/letta/utils.d.ts +24 -0
- package/dist/instrumentation/letta/utils.js +343 -0
- package/dist/instrumentation/letta/utils.js.map +1 -0
- package/dist/instrumentation/letta/wrapper.d.ts +37 -0
- package/dist/instrumentation/letta/wrapper.js +180 -0
- package/dist/instrumentation/letta/wrapper.js.map +1 -0
- package/dist/instrumentation/llamaindex/index.d.ts +36 -0
- package/dist/instrumentation/llamaindex/index.js +221 -0
- package/dist/instrumentation/llamaindex/index.js.map +1 -0
- package/dist/instrumentation/llamaindex/wrapper.d.ts +36 -0
- package/dist/instrumentation/llamaindex/wrapper.js +811 -0
- package/dist/instrumentation/llamaindex/wrapper.js.map +1 -0
- package/dist/instrumentation/mcp/index.d.ts +20 -0
- package/dist/instrumentation/mcp/index.js +282 -0
- package/dist/instrumentation/mcp/index.js.map +1 -0
- package/dist/instrumentation/mcp/wrapper.d.ts +72 -0
- package/dist/instrumentation/mcp/wrapper.js +571 -0
- package/dist/instrumentation/mcp/wrapper.js.map +1 -0
- package/dist/instrumentation/mem0/index.d.ts +17 -0
- package/dist/instrumentation/mem0/index.js +113 -0
- package/dist/instrumentation/mem0/index.js.map +1 -0
- package/dist/instrumentation/mem0/wrapper.d.ts +37 -0
- package/dist/instrumentation/mem0/wrapper.js +298 -0
- package/dist/instrumentation/mem0/wrapper.js.map +1 -0
- package/dist/instrumentation/milvus/index.d.ts +11 -0
- package/dist/instrumentation/milvus/index.js +67 -0
- package/dist/instrumentation/milvus/index.js.map +1 -0
- package/dist/instrumentation/milvus/wrapper.d.ts +15 -0
- package/dist/instrumentation/milvus/wrapper.js +219 -0
- package/dist/instrumentation/milvus/wrapper.js.map +1 -0
- package/dist/instrumentation/mistral/index.d.ts +11 -0
- package/dist/instrumentation/mistral/index.js +66 -0
- package/dist/instrumentation/mistral/index.js.map +1 -0
- package/dist/instrumentation/mistral/wrapper.d.ts +49 -0
- package/dist/instrumentation/mistral/wrapper.js +482 -0
- package/dist/instrumentation/mistral/wrapper.js.map +1 -0
- package/dist/instrumentation/ollama/index.d.ts +11 -0
- package/dist/instrumentation/ollama/index.js +72 -0
- package/dist/instrumentation/ollama/index.js.map +1 -0
- package/dist/instrumentation/ollama/wrapper.d.ts +73 -0
- package/dist/instrumentation/ollama/wrapper.js +629 -0
- package/dist/instrumentation/ollama/wrapper.js.map +1 -0
- package/dist/instrumentation/openai/index.d.ts +11 -0
- package/dist/instrumentation/openai/index.js +79 -0
- package/dist/instrumentation/openai/index.js.map +1 -0
- package/dist/instrumentation/openai/wrapper.d.ts +80 -0
- package/dist/instrumentation/openai/wrapper.js +1121 -0
- package/dist/instrumentation/openai/wrapper.js.map +1 -0
- package/dist/instrumentation/openai-agents/index.d.ts +20 -0
- package/dist/instrumentation/openai-agents/index.js +174 -0
- package/dist/instrumentation/openai-agents/index.js.map +1 -0
- package/dist/instrumentation/openai-agents/processor.d.ts +35 -0
- package/dist/instrumentation/openai-agents/processor.js +249 -0
- package/dist/instrumentation/openai-agents/processor.js.map +1 -0
- package/dist/instrumentation/openai-agents/utils.d.ts +20 -0
- package/dist/instrumentation/openai-agents/utils.js +624 -0
- package/dist/instrumentation/openai-agents/utils.js.map +1 -0
- package/dist/instrumentation/pg/index.d.ts +20 -0
- package/dist/instrumentation/pg/index.js +74 -0
- package/dist/instrumentation/pg/index.js.map +1 -0
- package/dist/instrumentation/pg/wrapper.d.ts +66 -0
- package/dist/instrumentation/pg/wrapper.js +441 -0
- package/dist/instrumentation/pg/wrapper.js.map +1 -0
- package/dist/instrumentation/pinecone/index.d.ts +11 -0
- package/dist/instrumentation/pinecone/index.js +79 -0
- package/dist/instrumentation/pinecone/index.js.map +1 -0
- package/dist/instrumentation/pinecone/wrapper.d.ts +14 -0
- package/dist/instrumentation/pinecone/wrapper.js +198 -0
- package/dist/instrumentation/pinecone/wrapper.js.map +1 -0
- package/dist/instrumentation/qdrant/index.d.ts +11 -0
- package/dist/instrumentation/qdrant/index.js +67 -0
- package/dist/instrumentation/qdrant/index.js.map +1 -0
- package/dist/instrumentation/qdrant/wrapper.d.ts +14 -0
- package/dist/instrumentation/qdrant/wrapper.js +213 -0
- package/dist/instrumentation/qdrant/wrapper.js.map +1 -0
- package/dist/instrumentation/replicate/index.d.ts +11 -0
- package/dist/instrumentation/replicate/index.js +57 -0
- package/dist/instrumentation/replicate/index.js.map +1 -0
- package/dist/instrumentation/replicate/wrapper.d.ts +28 -0
- package/dist/instrumentation/replicate/wrapper.js +242 -0
- package/dist/instrumentation/replicate/wrapper.js.map +1 -0
- package/dist/instrumentation/strands/index.d.ts +21 -0
- package/dist/instrumentation/strands/index.js +83 -0
- package/dist/instrumentation/strands/index.js.map +1 -0
- package/dist/instrumentation/strands/processor.d.ts +51 -0
- package/dist/instrumentation/strands/processor.js +625 -0
- package/dist/instrumentation/strands/processor.js.map +1 -0
- package/dist/instrumentation/strands/utils.d.ts +24 -0
- package/dist/instrumentation/strands/utils.js +373 -0
- package/dist/instrumentation/strands/utils.js.map +1 -0
- package/dist/instrumentation/together/index.d.ts +11 -0
- package/dist/instrumentation/together/index.js +43 -0
- package/dist/instrumentation/together/index.js.map +1 -0
- package/dist/instrumentation/together/wrapper.d.ts +48 -0
- package/dist/instrumentation/together/wrapper.js +409 -0
- package/dist/instrumentation/together/wrapper.js.map +1 -0
- package/dist/instrumentation/transformers/index.d.ts +35 -0
- package/dist/instrumentation/transformers/index.js +119 -0
- package/dist/instrumentation/transformers/index.js.map +1 -0
- package/dist/instrumentation/transformers/wrapper.d.ts +49 -0
- package/dist/instrumentation/transformers/wrapper.js +472 -0
- package/dist/instrumentation/transformers/wrapper.js.map +1 -0
- package/dist/instrumentation/vercel-ai/index.d.ts +10 -0
- package/dist/instrumentation/vercel-ai/index.js +59 -0
- package/dist/instrumentation/vercel-ai/index.js.map +1 -0
- package/dist/instrumentation/vercel-ai/wrapper.d.ts +50 -0
- package/dist/instrumentation/vercel-ai/wrapper.js +539 -0
- package/dist/instrumentation/vercel-ai/wrapper.js.map +1 -0
- package/dist/instrumentation/vertexai/index.d.ts +11 -0
- package/dist/instrumentation/vertexai/index.js +70 -0
- package/dist/instrumentation/vertexai/index.js.map +1 -0
- package/dist/instrumentation/vertexai/wrapper.d.ts +67 -0
- package/dist/instrumentation/vertexai/wrapper.js +530 -0
- package/dist/instrumentation/vertexai/wrapper.js.map +1 -0
- package/dist/instrumentation/vllm/index.d.ts +13 -0
- package/dist/instrumentation/vllm/index.js +67 -0
- package/dist/instrumentation/vllm/index.js.map +1 -0
- package/dist/instrumentation/vllm/wrapper.d.ts +60 -0
- package/dist/instrumentation/vllm/wrapper.js +482 -0
- package/dist/instrumentation/vllm/wrapper.js.map +1 -0
- package/dist/llm/anthropic.d.ts +5 -0
- package/dist/llm/anthropic.js +39 -0
- package/dist/llm/anthropic.js.map +1 -0
- package/dist/llm/index.d.ts +10 -0
- package/dist/llm/index.js +93 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/llm/openai.d.ts +6 -0
- package/dist/llm/openai.js +52 -0
- package/dist/llm/openai.js.map +1 -0
- package/dist/llm/providers.d.ts +7 -0
- package/dist/llm/providers.js +10 -0
- package/dist/llm/providers.js.map +1 -0
- package/dist/manual-trace.d.ts +40 -0
- package/dist/manual-trace.js +103 -0
- package/dist/manual-trace.js.map +1 -0
- package/dist/otel/__tests__/metrics.test.d.ts +1 -0
- package/dist/otel/__tests__/metrics.test.js +40 -0
- package/dist/otel/__tests__/metrics.test.js.map +1 -0
- package/dist/otel/events.d.ts +11 -0
- package/dist/otel/events.js +74 -0
- package/dist/otel/events.js.map +1 -0
- package/dist/otel/metrics.d.ts +35 -0
- package/dist/otel/metrics.js +219 -0
- package/dist/otel/metrics.js.map +1 -0
- package/dist/otel/tracing.d.ts +12 -0
- package/dist/otel/tracing.js +93 -0
- package/dist/otel/tracing.js.map +1 -0
- package/dist/otel/utils.d.ts +11 -0
- package/dist/otel/utils.js +34 -0
- package/dist/otel/utils.js.map +1 -0
- package/dist/pricing.json +951 -0
- package/dist/prompt-hub.d.ts +4 -0
- package/dist/prompt-hub.js +66 -0
- package/dist/prompt-hub.js.map +1 -0
- package/dist/register.d.ts +4 -0
- package/dist/register.js +52 -0
- package/dist/register.js.map +1 -0
- package/dist/score/__tests__/score.test.d.ts +1 -0
- package/dist/score/__tests__/score.test.js +143 -0
- package/dist/score/__tests__/score.test.js.map +1 -0
- package/dist/score/index.d.ts +2 -0
- package/dist/score/index.js +6 -0
- package/dist/score/index.js.map +1 -0
- package/dist/score/score.d.ts +15 -0
- package/dist/score/score.js +135 -0
- package/dist/score/score.js.map +1 -0
- package/dist/semantic-convention.d.ts +555 -0
- package/dist/semantic-convention.js +630 -0
- package/dist/semantic-convention.js.map +1 -0
- package/dist/types.d.ts +131 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +136 -0
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const api_1 = require("@opentelemetry/api");
|
|
7
|
+
const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
|
|
8
|
+
const config_1 = __importDefault(require("../../config"));
|
|
9
|
+
const constant_1 = require("../../constant");
|
|
10
|
+
const helpers_1 = __importDefault(require("../../helpers"));
|
|
11
|
+
const semantic_convention_1 = __importDefault(require("../../semantic-convention"));
|
|
12
|
+
const base_wrapper_1 = __importDefault(require("../base-wrapper"));
|
|
13
|
+
const DEFAULT_SERVER = {
|
|
14
|
+
serverAddress: 'astra.datastax.com',
|
|
15
|
+
serverPort: 443,
|
|
16
|
+
};
|
|
17
|
+
let astraDbSdkVersion = 'unknown';
|
|
18
|
+
try {
|
|
19
|
+
// Optional runtime dependency: keep this guarded so Shield360 can load without Astra installed.
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
21
|
+
astraDbSdkVersion = require('@datastax/astra-db-ts/package.json')?.version || 'unknown';
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
astraDbSdkVersion = 'unknown';
|
|
25
|
+
}
|
|
26
|
+
class AstraWrapper extends base_wrapper_1.default {
|
|
27
|
+
static _setCommonAttributes(span, dbOperation, collectionName, instance) {
|
|
28
|
+
const applicationName = config_1.default.applicationName || '';
|
|
29
|
+
const environment = config_1.default.environment || '';
|
|
30
|
+
const { serverAddress, serverPort } = AstraWrapper._getServerAddressAndPort(instance);
|
|
31
|
+
span.setAttribute(semantic_convention_1.default.DB_SYSTEM_NAME, AstraWrapper.dbSystem);
|
|
32
|
+
span.setAttribute(semantic_convention_1.default.DB_OPERATION_NAME, dbOperation);
|
|
33
|
+
span.setAttribute(semantic_convention_1.default.DB_COLLECTION_NAME, collectionName);
|
|
34
|
+
span.setAttribute(semantic_convention_1.default.SERVER_ADDRESS, serverAddress);
|
|
35
|
+
span.setAttribute(semantic_convention_1.default.SERVER_PORT, serverPort);
|
|
36
|
+
span.setAttribute(semantic_conventions_1.ATTR_TELEMETRY_SDK_NAME, constant_1.SDK_NAME);
|
|
37
|
+
span.setAttribute(semantic_convention_1.default.GEN_AI_OPERATION, semantic_convention_1.default.GEN_AI_OPERATION_TYPE_VECTORDB);
|
|
38
|
+
span.setAttribute(semantic_convention_1.default.ATTR_DEPLOYMENT_ENVIRONMENT, environment);
|
|
39
|
+
span.setAttribute(semantic_conventions_1.ATTR_SERVICE_NAME, applicationName);
|
|
40
|
+
span.setAttribute(semantic_convention_1.default.DB_SDK_VERSION, astraDbSdkVersion);
|
|
41
|
+
span.setAttribute(semantic_convention_1.default.GEN_AI_ENVIRONMENT, environment);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Async wrapper for methods that return Promises (all Collection CRUD methods except `find`).
|
|
45
|
+
*/
|
|
46
|
+
static _patchCollectionMethod(tracer, dbOperation) {
|
|
47
|
+
return (originalMethod) => {
|
|
48
|
+
return async function (...args) {
|
|
49
|
+
const collectionName = this?.name || 'unknown';
|
|
50
|
+
const spanName = `${dbOperation} ${collectionName}`;
|
|
51
|
+
const span = tracer.startSpan(spanName, { kind: api_1.SpanKind.CLIENT });
|
|
52
|
+
const startTime = Date.now();
|
|
53
|
+
return api_1.context.with(api_1.trace.setSpan(api_1.context.active(), span), async () => {
|
|
54
|
+
try {
|
|
55
|
+
const response = await originalMethod.apply(this, args);
|
|
56
|
+
const duration = (Date.now() - startTime) / 1000;
|
|
57
|
+
const actualDbOperation = AstraWrapper._getActualDbOperation(dbOperation, args);
|
|
58
|
+
AstraWrapper._setCommonAttributes(span, actualDbOperation, collectionName, this);
|
|
59
|
+
span.setAttribute(semantic_convention_1.default.DB_CLIENT_OPERATION_DURATION, duration);
|
|
60
|
+
AstraWrapper._setOperationAttributes(span, {
|
|
61
|
+
dbOperation: actualDbOperation,
|
|
62
|
+
collectionName,
|
|
63
|
+
args,
|
|
64
|
+
response,
|
|
65
|
+
});
|
|
66
|
+
span.setStatus({ code: api_1.SpanStatusCode.OK });
|
|
67
|
+
return response;
|
|
68
|
+
}
|
|
69
|
+
catch (e) {
|
|
70
|
+
helpers_1.default.handleException(span, e);
|
|
71
|
+
throw e;
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
span.end();
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Synchronous wrapper for `find()` which returns a cursor synchronously.
|
|
82
|
+
* Wrapping it as async would break the cursor API (e.g. `collection.find({}).toArray()`).
|
|
83
|
+
*/
|
|
84
|
+
static _patchSyncFindMethod(tracer) {
|
|
85
|
+
return (originalMethod) => {
|
|
86
|
+
return function (...args) {
|
|
87
|
+
const collectionName = this?.name || 'unknown';
|
|
88
|
+
const spanName = `${semantic_convention_1.default.DB_OPERATION_SELECT} ${collectionName}`;
|
|
89
|
+
const span = tracer.startSpan(spanName, { kind: api_1.SpanKind.CLIENT });
|
|
90
|
+
const startTime = Date.now();
|
|
91
|
+
try {
|
|
92
|
+
const cursor = originalMethod.apply(this, args);
|
|
93
|
+
const duration = (Date.now() - startTime) / 1000;
|
|
94
|
+
AstraWrapper._setCommonAttributes(span, semantic_convention_1.default.DB_OPERATION_SELECT, collectionName, this);
|
|
95
|
+
span.setAttribute(semantic_convention_1.default.DB_CLIENT_OPERATION_DURATION, duration);
|
|
96
|
+
AstraWrapper._setOperationAttributes(span, {
|
|
97
|
+
dbOperation: semantic_convention_1.default.DB_OPERATION_SELECT,
|
|
98
|
+
collectionName,
|
|
99
|
+
args,
|
|
100
|
+
response: cursor,
|
|
101
|
+
});
|
|
102
|
+
span.setStatus({ code: api_1.SpanStatusCode.OK });
|
|
103
|
+
return cursor;
|
|
104
|
+
}
|
|
105
|
+
catch (e) {
|
|
106
|
+
helpers_1.default.handleException(span, e);
|
|
107
|
+
throw e;
|
|
108
|
+
}
|
|
109
|
+
finally {
|
|
110
|
+
span.end();
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
static _setOperationAttributes(span, context) {
|
|
116
|
+
switch (context.dbOperation) {
|
|
117
|
+
case semantic_convention_1.default.DB_OPERATION_INSERT:
|
|
118
|
+
AstraWrapper._setInsertAttributes(span, context);
|
|
119
|
+
break;
|
|
120
|
+
case semantic_convention_1.default.DB_OPERATION_UPDATE:
|
|
121
|
+
AstraWrapper._setUpdateAttributes(span, context);
|
|
122
|
+
break;
|
|
123
|
+
case semantic_convention_1.default.DB_OPERATION_REPLACE:
|
|
124
|
+
case semantic_convention_1.default.DB_OPERATION_UPSERT:
|
|
125
|
+
AstraWrapper._setReplaceAttributes(span, context);
|
|
126
|
+
break;
|
|
127
|
+
case semantic_convention_1.default.DB_OPERATION_SELECT:
|
|
128
|
+
AstraWrapper._setSelectAttributes(span, context);
|
|
129
|
+
break;
|
|
130
|
+
case semantic_convention_1.default.DB_OPERATION_DELETE:
|
|
131
|
+
case semantic_convention_1.default.DB_OPERATION_FIND_AND_DELETE:
|
|
132
|
+
AstraWrapper._setDeleteAttributes(span, context);
|
|
133
|
+
break;
|
|
134
|
+
default:
|
|
135
|
+
span.setAttribute(semantic_convention_1.default.DB_QUERY_SUMMARY, `${context.dbOperation} ${context.collectionName}`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
static _setInsertAttributes(span, { dbOperation, collectionName, args, response }) {
|
|
139
|
+
const documents = args[0];
|
|
140
|
+
const documentsCount = AstraWrapper._objectCount(documents);
|
|
141
|
+
span.setAttribute(semantic_convention_1.default.DB_DOCUMENTS_COUNT, documentsCount);
|
|
142
|
+
if (config_1.default.captureMessageContent) {
|
|
143
|
+
span.setAttribute(semantic_convention_1.default.DB_QUERY_TEXT, AstraWrapper._safeStringify(documents));
|
|
144
|
+
}
|
|
145
|
+
const returnedRows = AstraWrapper._getInsertReturnedRows(response);
|
|
146
|
+
if (returnedRows !== undefined) {
|
|
147
|
+
span.setAttribute(semantic_convention_1.default.DB_RESPONSE_RETURNED_ROWS, returnedRows);
|
|
148
|
+
}
|
|
149
|
+
span.setAttribute(semantic_convention_1.default.DB_QUERY_SUMMARY, `${dbOperation} ${collectionName} documents_count=${documentsCount}`);
|
|
150
|
+
}
|
|
151
|
+
static _setUpdateAttributes(span, { dbOperation, collectionName, args, response }) {
|
|
152
|
+
const filter = args[0] || {};
|
|
153
|
+
const update = args[1] || {};
|
|
154
|
+
AstraWrapper._setFilterAttribute(span, filter);
|
|
155
|
+
if (config_1.default.captureMessageContent) {
|
|
156
|
+
span.setAttribute(semantic_convention_1.default.DB_QUERY_TEXT, AstraWrapper._safeStringify(update));
|
|
157
|
+
}
|
|
158
|
+
const returnedRows = AstraWrapper._getUpdateReturnedRows(response);
|
|
159
|
+
if (returnedRows !== undefined) {
|
|
160
|
+
span.setAttribute(semantic_convention_1.default.DB_RESPONSE_RETURNED_ROWS, returnedRows);
|
|
161
|
+
}
|
|
162
|
+
span.setAttribute(semantic_convention_1.default.DB_QUERY_SUMMARY, `${dbOperation} ${collectionName} filter=${AstraWrapper._summaryValue(filter)} update=${AstraWrapper._summaryValue(update)}`);
|
|
163
|
+
}
|
|
164
|
+
static _setReplaceAttributes(span, { dbOperation, collectionName, args }) {
|
|
165
|
+
const filter = args[0] || {};
|
|
166
|
+
const upsert = AstraWrapper._hasUpsertOption(args);
|
|
167
|
+
AstraWrapper._setFilterAttribute(span, filter);
|
|
168
|
+
if (config_1.default.captureMessageContent) {
|
|
169
|
+
span.setAttribute(semantic_convention_1.default.DB_QUERY_TEXT, AstraWrapper._safeStringify(filter));
|
|
170
|
+
}
|
|
171
|
+
span.setAttribute(semantic_convention_1.default.DB_QUERY_SUMMARY, `${dbOperation} ${collectionName} filter=${AstraWrapper._summaryValue(filter)} upsert=${upsert}`);
|
|
172
|
+
}
|
|
173
|
+
static _setSelectAttributes(span, { dbOperation, collectionName, args, response }) {
|
|
174
|
+
const filter = args[0] || {};
|
|
175
|
+
AstraWrapper._setFilterAttribute(span, filter);
|
|
176
|
+
if (config_1.default.captureMessageContent) {
|
|
177
|
+
span.setAttribute(semantic_convention_1.default.DB_QUERY_TEXT, AstraWrapper._safeStringify(filter));
|
|
178
|
+
}
|
|
179
|
+
const returnedRows = AstraWrapper._getSelectReturnedRows(response);
|
|
180
|
+
if (returnedRows !== undefined) {
|
|
181
|
+
span.setAttribute(semantic_convention_1.default.DB_RESPONSE_RETURNED_ROWS, returnedRows);
|
|
182
|
+
}
|
|
183
|
+
span.setAttribute(semantic_convention_1.default.DB_QUERY_SUMMARY, `${dbOperation} ${collectionName} filter=${AstraWrapper._summaryValue(filter)}`);
|
|
184
|
+
}
|
|
185
|
+
static _setDeleteAttributes(span, { dbOperation, collectionName, args, response }) {
|
|
186
|
+
const filter = args[0] || {};
|
|
187
|
+
AstraWrapper._setFilterAttribute(span, filter);
|
|
188
|
+
if (config_1.default.captureMessageContent) {
|
|
189
|
+
span.setAttribute(semantic_convention_1.default.DB_QUERY_TEXT, AstraWrapper._safeStringify(filter));
|
|
190
|
+
}
|
|
191
|
+
const returnedRows = AstraWrapper._getDeleteReturnedRows(response, dbOperation);
|
|
192
|
+
if (returnedRows !== undefined) {
|
|
193
|
+
span.setAttribute(semantic_convention_1.default.DB_RESPONSE_RETURNED_ROWS, returnedRows);
|
|
194
|
+
}
|
|
195
|
+
span.setAttribute(semantic_convention_1.default.DB_QUERY_SUMMARY, `${dbOperation} ${collectionName} filter=${AstraWrapper._summaryValue(filter)}`);
|
|
196
|
+
}
|
|
197
|
+
static _getActualDbOperation(dbOperation, args) {
|
|
198
|
+
if (dbOperation === semantic_convention_1.default.DB_OPERATION_REPLACE && AstraWrapper._hasUpsertOption(args)) {
|
|
199
|
+
return semantic_convention_1.default.DB_OPERATION_UPSERT;
|
|
200
|
+
}
|
|
201
|
+
return dbOperation;
|
|
202
|
+
}
|
|
203
|
+
static _hasUpsertOption(args) {
|
|
204
|
+
return args.slice(2).some((arg) => arg && typeof arg === 'object' && arg.upsert === true);
|
|
205
|
+
}
|
|
206
|
+
static _setFilterAttribute(span, filter) {
|
|
207
|
+
if (filter && typeof filter === 'object' && Object.keys(filter).length > 0) {
|
|
208
|
+
span.setAttribute(semantic_convention_1.default.DB_FILTER, AstraWrapper._safeStringify(filter));
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
static _getInsertReturnedRows(response) {
|
|
212
|
+
if (!response)
|
|
213
|
+
return undefined;
|
|
214
|
+
if (typeof response.insertedCount === 'number')
|
|
215
|
+
return response.insertedCount;
|
|
216
|
+
if (typeof response.inserted_count === 'number')
|
|
217
|
+
return response.inserted_count;
|
|
218
|
+
if (Array.isArray(response.insertedIds))
|
|
219
|
+
return response.insertedIds.length;
|
|
220
|
+
if (Array.isArray(response.inserted_ids))
|
|
221
|
+
return response.inserted_ids.length;
|
|
222
|
+
if (response.insertedIds && typeof response.insertedIds === 'object')
|
|
223
|
+
return Object.keys(response.insertedIds).length;
|
|
224
|
+
if (response.inserted_ids && typeof response.inserted_ids === 'object')
|
|
225
|
+
return Object.keys(response.inserted_ids).length;
|
|
226
|
+
if (response.insertedId || response.inserted_id)
|
|
227
|
+
return 1;
|
|
228
|
+
return undefined;
|
|
229
|
+
}
|
|
230
|
+
static _getUpdateReturnedRows(response) {
|
|
231
|
+
if (!response)
|
|
232
|
+
return undefined;
|
|
233
|
+
if (typeof response.modifiedCount === 'number')
|
|
234
|
+
return response.modifiedCount;
|
|
235
|
+
if (typeof response.modified_count === 'number')
|
|
236
|
+
return response.modified_count;
|
|
237
|
+
if (typeof response.matchedCount === 'number')
|
|
238
|
+
return response.matchedCount;
|
|
239
|
+
if (typeof response.matched_count === 'number')
|
|
240
|
+
return response.matched_count;
|
|
241
|
+
if (typeof response.update_info?.nModified === 'number')
|
|
242
|
+
return response.update_info.nModified;
|
|
243
|
+
if (typeof response.updateInfo?.nModified === 'number')
|
|
244
|
+
return response.updateInfo.nModified;
|
|
245
|
+
return undefined;
|
|
246
|
+
}
|
|
247
|
+
static _getSelectReturnedRows(response) {
|
|
248
|
+
if (!response || AstraWrapper._isCursorLike(response))
|
|
249
|
+
return undefined;
|
|
250
|
+
if (Array.isArray(response))
|
|
251
|
+
return response.length;
|
|
252
|
+
if (typeof response.length === 'number')
|
|
253
|
+
return response.length;
|
|
254
|
+
return 1;
|
|
255
|
+
}
|
|
256
|
+
static _getDeleteReturnedRows(response, dbOperation) {
|
|
257
|
+
if (!response)
|
|
258
|
+
return dbOperation === semantic_convention_1.default.DB_OPERATION_FIND_AND_DELETE ? 0 : undefined;
|
|
259
|
+
if (typeof response.deletedCount === 'number')
|
|
260
|
+
return response.deletedCount;
|
|
261
|
+
if (typeof response.deleted_count === 'number')
|
|
262
|
+
return response.deleted_count;
|
|
263
|
+
if (dbOperation === semantic_convention_1.default.DB_OPERATION_FIND_AND_DELETE)
|
|
264
|
+
return 1;
|
|
265
|
+
return undefined;
|
|
266
|
+
}
|
|
267
|
+
static _objectCount(obj) {
|
|
268
|
+
if (Array.isArray(obj))
|
|
269
|
+
return obj.length;
|
|
270
|
+
if (obj !== undefined && obj !== null)
|
|
271
|
+
return 1;
|
|
272
|
+
return 0;
|
|
273
|
+
}
|
|
274
|
+
static _isCursorLike(response) {
|
|
275
|
+
return !!response && (typeof response[Symbol.asyncIterator] === 'function'
|
|
276
|
+
|| typeof response[Symbol.iterator] === 'function'
|
|
277
|
+
|| typeof response.toArray === 'function'
|
|
278
|
+
|| typeof response.next === 'function');
|
|
279
|
+
}
|
|
280
|
+
static _summaryValue(value) {
|
|
281
|
+
return AstraWrapper._truncate(AstraWrapper._safeStringify(value));
|
|
282
|
+
}
|
|
283
|
+
static _safeStringify(value) {
|
|
284
|
+
if (typeof value === 'string')
|
|
285
|
+
return value;
|
|
286
|
+
try {
|
|
287
|
+
return JSON.stringify(value);
|
|
288
|
+
}
|
|
289
|
+
catch {
|
|
290
|
+
return String(value);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
static _truncate(value, maxLength = 200) {
|
|
294
|
+
return value.length > maxLength ? `${value.slice(0, maxLength)}...` : value;
|
|
295
|
+
}
|
|
296
|
+
static _getServerAddressAndPort(instance) {
|
|
297
|
+
const endpoint = AstraWrapper._findEndpoint(instance);
|
|
298
|
+
if (!endpoint)
|
|
299
|
+
return DEFAULT_SERVER;
|
|
300
|
+
return AstraWrapper._parseEndpoint(endpoint);
|
|
301
|
+
}
|
|
302
|
+
static _findEndpoint(instance) {
|
|
303
|
+
const candidates = [
|
|
304
|
+
instance,
|
|
305
|
+
instance?.database,
|
|
306
|
+
instance?.db,
|
|
307
|
+
instance?.client,
|
|
308
|
+
instance?._client,
|
|
309
|
+
instance?.database?.client,
|
|
310
|
+
instance?.db?.client,
|
|
311
|
+
];
|
|
312
|
+
const keys = ['apiEndpoint', 'api_endpoint', 'endpoint', 'baseUrl', 'base_url'];
|
|
313
|
+
for (const candidate of candidates) {
|
|
314
|
+
if (!candidate || typeof candidate !== 'object')
|
|
315
|
+
continue;
|
|
316
|
+
for (const key of keys) {
|
|
317
|
+
const value = candidate[key];
|
|
318
|
+
if (typeof value === 'string' && value.length > 0)
|
|
319
|
+
return value;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
return undefined;
|
|
323
|
+
}
|
|
324
|
+
static _parseEndpoint(endpoint) {
|
|
325
|
+
const fallbackPort = endpoint.startsWith('http://') ? 80 : DEFAULT_SERVER.serverPort;
|
|
326
|
+
try {
|
|
327
|
+
if (endpoint.startsWith('http://') || endpoint.startsWith('https://')) {
|
|
328
|
+
const parsed = new URL(endpoint);
|
|
329
|
+
return {
|
|
330
|
+
serverAddress: parsed.hostname || DEFAULT_SERVER.serverAddress,
|
|
331
|
+
serverPort: parsed.port ? Number(parsed.port) : fallbackPort,
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
catch {
|
|
336
|
+
return DEFAULT_SERVER;
|
|
337
|
+
}
|
|
338
|
+
const [serverAddress, port] = endpoint.split(':');
|
|
339
|
+
return {
|
|
340
|
+
serverAddress: serverAddress || DEFAULT_SERVER.serverAddress,
|
|
341
|
+
serverPort: port ? Number(port) || DEFAULT_SERVER.serverPort : DEFAULT_SERVER.serverPort,
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
AstraWrapper.dbSystem = semantic_convention_1.default.DB_SYSTEM_ASTRA;
|
|
346
|
+
AstraWrapper.serverAddress = DEFAULT_SERVER.serverAddress;
|
|
347
|
+
AstraWrapper.serverPort = DEFAULT_SERVER.serverPort;
|
|
348
|
+
exports.default = AstraWrapper;
|
|
349
|
+
//# sourceMappingURL=wrapper.js.map
|
|
@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UAAU,CAAC;QAErF,IAAI,CAAC;YACH,IAAI,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,QAAQ,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;gBACtE,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;gBACjC,OAAO;oBACL,aAAa,EAAE,MAAM,CAAC,QAAQ,IAAI,cAAc,CAAC,aAAa;oBAC9D,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,YAAY;iBAC7D,CAAC;YACJ,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,cAAc,CAAC;QACxB,CAAC;QAED,MAAM,CAAC,aAAa,EAAE,IAAI,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAClD,OAAO;YACL,aAAa,EAAE,aAAa,IAAI,cAAc,CAAC,aAAa;YAC5D,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC,cAAc,CAAC,UAAU;SACzF,CAAC;IACJ,CAAC;;AAhWM,qBAAQ,GAAG,6BAAkB,CAAC,eAAe,CAAC;AAC9C,0BAAa,GAAG,cAAc,CAAC,aAAa,CAAC;AAC7C,uBAAU,GAAG,cAAc,CAAC,UAAU,CAAC;AAiWhD,kBAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { InstrumentationBase, InstrumentationModuleDefinition } from '@opentelemetry/instrumentation';
|
|
2
|
+
import { InstrumentationConfig } from '@opentelemetry/instrumentation';
|
|
3
|
+
export interface AzureAIInferenceInstrumentationConfig extends InstrumentationConfig {
|
|
4
|
+
}
|
|
5
|
+
export default class Shield360AzureAIInferenceInstrumentation extends InstrumentationBase {
|
|
6
|
+
constructor(config?: AzureAIInferenceInstrumentationConfig);
|
|
7
|
+
protected init(): void | InstrumentationModuleDefinition | InstrumentationModuleDefinition[];
|
|
8
|
+
manualPatch(azureAIInference: any): void;
|
|
9
|
+
protected _patch(moduleExports: any): void;
|
|
10
|
+
protected _unpatch(moduleExports: any): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const instrumentation_1 = require("@opentelemetry/instrumentation");
|
|
7
|
+
const constant_1 = require("../../constant");
|
|
8
|
+
const wrapper_1 = __importDefault(require("./wrapper"));
|
|
9
|
+
class Shield360AzureAIInferenceInstrumentation extends instrumentation_1.InstrumentationBase {
|
|
10
|
+
constructor(config = {}) {
|
|
11
|
+
super(`${constant_1.INSTRUMENTATION_PREFIX}/instrumentation-azure-ai-inference`, '1.0.0', config);
|
|
12
|
+
}
|
|
13
|
+
init() {
|
|
14
|
+
const module = new instrumentation_1.InstrumentationNodeModuleDefinition('@azure-rest/ai-inference', ['>=1.0.0-beta.1'], (moduleExports) => {
|
|
15
|
+
this._patch(moduleExports);
|
|
16
|
+
return moduleExports;
|
|
17
|
+
}, (moduleExports) => {
|
|
18
|
+
if (moduleExports !== undefined) {
|
|
19
|
+
this._unpatch(moduleExports);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
return [module];
|
|
23
|
+
}
|
|
24
|
+
manualPatch(azureAIInference) {
|
|
25
|
+
this._patch(azureAIInference);
|
|
26
|
+
}
|
|
27
|
+
_patch(moduleExports) {
|
|
28
|
+
try {
|
|
29
|
+
if (!moduleExports.default || typeof moduleExports.default !== 'function') {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if ((0, instrumentation_1.isWrapped)(moduleExports.default)) {
|
|
33
|
+
this._unwrap(moduleExports, 'default');
|
|
34
|
+
}
|
|
35
|
+
const tracer = this.tracer;
|
|
36
|
+
this._wrap(moduleExports, 'default', (original) => {
|
|
37
|
+
return function (...args) {
|
|
38
|
+
const client = original.apply(this, args);
|
|
39
|
+
const endpoint = typeof args[0] === 'string' ? args[0] : '';
|
|
40
|
+
const { serverAddress, serverPort } = wrapper_1.default.parseEndpoint(endpoint);
|
|
41
|
+
if (client && typeof client.path === 'function') {
|
|
42
|
+
const originalPath = client.path;
|
|
43
|
+
client.path = function (...pathArgs) {
|
|
44
|
+
const route = pathArgs[0];
|
|
45
|
+
const handler = originalPath.apply(client, pathArgs);
|
|
46
|
+
if (route === '/chat/completions' &&
|
|
47
|
+
handler &&
|
|
48
|
+
typeof handler.post === 'function') {
|
|
49
|
+
const origPost = handler.post;
|
|
50
|
+
handler.post = wrapper_1.default._patchChatComplete(tracer, serverAddress, serverPort)(origPost);
|
|
51
|
+
}
|
|
52
|
+
else if (route === '/embeddings' &&
|
|
53
|
+
handler &&
|
|
54
|
+
typeof handler.post === 'function') {
|
|
55
|
+
const origPost = handler.post;
|
|
56
|
+
handler.post = wrapper_1.default._patchEmbeddings(tracer, serverAddress, serverPort)(origPost);
|
|
57
|
+
}
|
|
58
|
+
return handler;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
return client;
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
catch (e) {
|
|
66
|
+
console.error('Error in _patch method:', e);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
_unpatch(moduleExports) {
|
|
70
|
+
if (moduleExports.default) {
|
|
71
|
+
this._unwrap(moduleExports, 'default');
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.default = Shield360AzureAIInferenceInstrumentation;
|
|
76
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/inst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gBAChB,CAAC,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,CAAC,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;IAES,QAAQ,CAAC,aAAkB;QACnC,IAAI,aAAa,CAAC,OAAO,EAAE,CAAC;YAC1B,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;CACF;AA7FD,2DA6FC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Span, Tracer } from '@opentelemetry/api';
|
|
2
|
+
import BaseWrapper, { BaseSpanAttributes } from '../base-wrapper';
|
|
3
|
+
declare class AzureAIInferenceWrapper extends BaseWrapper {
|
|
4
|
+
static aiSystem: string;
|
|
5
|
+
static defaultServerAddress: string;
|
|
6
|
+
static defaultServerPort: number;
|
|
7
|
+
/**
|
|
8
|
+
* Stamp `shield360.agent.version_hash` (auto) and `gen_ai.agent.version`
|
|
9
|
+
* (user override, if set) on the span and return the same attributes so
|
|
10
|
+
* the caller can merge them into the inference event extras.
|
|
11
|
+
*/
|
|
12
|
+
static _stampAgentVersion(span: Span, args: {
|
|
13
|
+
systemInstructionsJson?: string;
|
|
14
|
+
toolDefinitionsJson?: string;
|
|
15
|
+
primaryModel?: string;
|
|
16
|
+
temperature?: number | null;
|
|
17
|
+
top_p?: number | null;
|
|
18
|
+
max_tokens?: number | null;
|
|
19
|
+
}): Record<string, string>;
|
|
20
|
+
/**
|
|
21
|
+
* Extracts server address and port from an endpoint URL string.
|
|
22
|
+
*/
|
|
23
|
+
static parseEndpoint(endpoint: string): {
|
|
24
|
+
serverAddress: string;
|
|
25
|
+
serverPort: number;
|
|
26
|
+
};
|
|
27
|
+
static _patchChatComplete(tracer: Tracer, serverAddress: string, serverPort: number): any;
|
|
28
|
+
static _chatCompletion({ body, genAIEndpoint, httpResponse, span, serverAddress, serverPort, }: {
|
|
29
|
+
body: any;
|
|
30
|
+
genAIEndpoint: string;
|
|
31
|
+
httpResponse: any;
|
|
32
|
+
span: Span;
|
|
33
|
+
serverAddress: string;
|
|
34
|
+
serverPort: number;
|
|
35
|
+
}): Promise<any>;
|
|
36
|
+
/**
|
|
37
|
+
* Wraps an SSE body stream (Node.js IncomingMessage / ReadableStream) to
|
|
38
|
+
* aggregate telemetry while passing through chunks to the caller.
|
|
39
|
+
* Returns an async-iterable that yields the raw SSE buffers/strings so
|
|
40
|
+
* downstream consumers (e.g. createSseStream) keep working.
|
|
41
|
+
*/
|
|
42
|
+
static _wrapSseStream(body: any, requestBody: any, genAIEndpoint: string, span: Span, serverAddress: string, serverPort: number): any;
|
|
43
|
+
static _chatCompletionCommonSetter({ body, genAIEndpoint, result, span, serverAddress, serverPort, ttft, tbt, }: {
|
|
44
|
+
body: any;
|
|
45
|
+
genAIEndpoint: string;
|
|
46
|
+
result: any;
|
|
47
|
+
span: Span;
|
|
48
|
+
serverAddress: string;
|
|
49
|
+
serverPort: number;
|
|
50
|
+
ttft?: number;
|
|
51
|
+
tbt?: number;
|
|
52
|
+
}): BaseSpanAttributes;
|
|
53
|
+
static _patchEmbeddings(tracer: Tracer, serverAddress: string, serverPort: number): any;
|
|
54
|
+
}
|
|
55
|
+
export default AzureAIInferenceWrapper;
|