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,20 @@
|
|
|
1
|
+
import { InstrumentationBase, InstrumentationModuleDefinition, InstrumentationConfig } from '@opentelemetry/instrumentation';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for the PostgreSQL (`pg`) instrumentation.
|
|
4
|
+
*
|
|
5
|
+
* `captureDbParameters` mirrors the Python psycopg instrumentor's
|
|
6
|
+
* `capture_db_parameters` flag. It is OFF by default because query parameters
|
|
7
|
+
* may contain PII / secrets. Enable only when you are certain parameters are safe.
|
|
8
|
+
*/
|
|
9
|
+
export interface PgInstrumentationConfig extends InstrumentationConfig {
|
|
10
|
+
captureDbParameters?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export default class Shield360PgInstrumentation extends InstrumentationBase {
|
|
13
|
+
private _clientProto;
|
|
14
|
+
constructor(config?: PgInstrumentationConfig);
|
|
15
|
+
private get captureDbParameters();
|
|
16
|
+
protected init(): void | InstrumentationModuleDefinition | InstrumentationModuleDefinition[];
|
|
17
|
+
manualPatch(pg: any): void;
|
|
18
|
+
protected _patch(moduleExports: any, moduleVersion?: string): void;
|
|
19
|
+
protected _unpatch(moduleExports?: any): void;
|
|
20
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
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 api_1 = require("@opentelemetry/api");
|
|
8
|
+
const constant_1 = require("../../constant");
|
|
9
|
+
const wrapper_1 = __importDefault(require("./wrapper"));
|
|
10
|
+
class Shield360PgInstrumentation extends instrumentation_1.InstrumentationBase {
|
|
11
|
+
constructor(config = {}) {
|
|
12
|
+
super(`${constant_1.INSTRUMENTATION_PREFIX}/instrumentation-pg`, '1.0.0', config);
|
|
13
|
+
this._clientProto = null;
|
|
14
|
+
}
|
|
15
|
+
get captureDbParameters() {
|
|
16
|
+
return Boolean(this.getConfig()?.captureDbParameters);
|
|
17
|
+
}
|
|
18
|
+
init() {
|
|
19
|
+
const module = new instrumentation_1.InstrumentationNodeModuleDefinition('pg', ['>=7.0.0', '>=8.0.0'], (moduleExports, moduleVersion) => {
|
|
20
|
+
this._patch(moduleExports, moduleVersion);
|
|
21
|
+
return moduleExports;
|
|
22
|
+
}, (moduleExports) => {
|
|
23
|
+
if (moduleExports !== undefined) {
|
|
24
|
+
this._unpatch(moduleExports);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
return [module];
|
|
28
|
+
}
|
|
29
|
+
manualPatch(pg) {
|
|
30
|
+
this._patch(pg);
|
|
31
|
+
}
|
|
32
|
+
_patch(moduleExports, moduleVersion) {
|
|
33
|
+
try {
|
|
34
|
+
if (!moduleExports)
|
|
35
|
+
return;
|
|
36
|
+
const sdkVersion = moduleVersion ? String(moduleVersion) : undefined;
|
|
37
|
+
const wrapperConfig = { captureDbParameters: this.captureDbParameters, sdkVersion };
|
|
38
|
+
// Wrap ONLY Client.prototype.query.
|
|
39
|
+
//
|
|
40
|
+
// We deliberately do NOT wrap Pool.prototype.query. In `pg`, Pool.query()
|
|
41
|
+
// checks out a pooled Client and delegates to that Client's query(), so
|
|
42
|
+
// client-level wrapping already captures pool-routed queries. Wrapping both
|
|
43
|
+
// would emit two spans for a single logical pool query (a Pool span plus a
|
|
44
|
+
// child Client span). This matches the OTel community pg instrumentation,
|
|
45
|
+
// which also instruments only the Client. Result: exactly one span per query.
|
|
46
|
+
const Client = moduleExports.Client;
|
|
47
|
+
if (Client?.prototype && typeof Client.prototype.query === 'function') {
|
|
48
|
+
if ((0, instrumentation_1.isWrapped)(Client.prototype.query)) {
|
|
49
|
+
this._unwrap(Client.prototype, 'query');
|
|
50
|
+
}
|
|
51
|
+
this._clientProto = Client.prototype;
|
|
52
|
+
this._wrap(Client.prototype, 'query', wrapper_1.default._patchQuery(this.tracer, wrapperConfig));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
catch (e) {
|
|
56
|
+
api_1.diag.error('pg instrumentation: error in _patch method', e);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
_unpatch(moduleExports) {
|
|
60
|
+
try {
|
|
61
|
+
if (moduleExports?.Client?.prototype && (0, instrumentation_1.isWrapped)(moduleExports.Client.prototype.query)) {
|
|
62
|
+
this._unwrap(moduleExports.Client.prototype, 'query');
|
|
63
|
+
}
|
|
64
|
+
else if (this._clientProto && (0, instrumentation_1.isWrapped)(this._clientProto.query)) {
|
|
65
|
+
this._unwrap(this._clientProto, 'query');
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
/* ignore */
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.default = Shield360PgInstrumentation;
|
|
74
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/instrumentation/pg/index.ts"],"names":[],"mappings":";;;;;AAAA,oEAMwC;AACxC,4CAA0C;AAC1C,6CAAwD;AACxD,wDAAkC;AAalC,MAAqB,0BAA2B,SAAQ,qCAAmB;IAGzE,YAAY,SAAkC,EAAE;QAC9C,KAAK,CAAC,GAAG,iCAAsB,qBAAqB,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAHjE,iBAAY,GAAQ,IAAI,CAAC;IAIjC,CAAC;IAED,IAAY,mBAAmB;QAC7B,OAAO,OAAO,CAAE,IAAI,CAAC,SAAS,EAA8B,EAAE,mBAAmB,CAAC,CAAC;IACrF,CAAC;IAES,IAAI;QACZ,MAAM,MAAM,GAAG,IAAI,qDAAmC,CACpD,IAAI,EACJ,CAAC,SAAS,EAAE,SAAS,CAAC,EACtB,CAAC,aAAa,EAAE,aAAa,EAAE,EAAE;YAC/B,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;YAC1C,OAAO,aAAa,CAAC;QACvB,CAAC,EACD,CAAC,aAAa,EAAE,EAAE;YAChB,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;gBAChC,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;YAC/B,CAAC;QACH,CAAC,CACF,CAAC;QACF,OAAO,CAAC,MAAM,CAAC,CAAC;IAClB,CAAC;IAEM,WAAW,CAAC,EAAO;QACxB,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAClB,CAAC;IAES,MAAM,CAAC,aAAkB,EAAE,aAAsB;QACzD,IAAI,CAAC;YACH,IAAI,CAAC,aAAa;gBAAE,OAAO;YAC3B,MAAM,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CA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AAC,EAAE,CAAC;gBACnE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,YAAY;QACd,CAAC;IACH,CAAC;CACF;AAtED,6CAsEC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Span, Tracer } from '@opentelemetry/api';
|
|
2
|
+
import BaseWrapper from '../base-wrapper';
|
|
3
|
+
export interface PgWrapperConfig {
|
|
4
|
+
captureDbParameters?: boolean;
|
|
5
|
+
sdkVersion?: string;
|
|
6
|
+
}
|
|
7
|
+
declare class PgWrapper extends BaseWrapper {
|
|
8
|
+
static dbSystem: string;
|
|
9
|
+
/** Detect the SQL operation verb from a query string (mirrors Python parse_sql_operation). */
|
|
10
|
+
static parseSqlOperation(query: unknown): string;
|
|
11
|
+
/** Extract the target table name for span naming (mirrors Python extract_table_name). */
|
|
12
|
+
static extractTableName(query: unknown): string;
|
|
13
|
+
/** Detect pgvector similarity operator → metric name (mirrors Python detect_special_features). */
|
|
14
|
+
static detectSimilarityMetric(query: unknown): string | undefined;
|
|
15
|
+
/** Detect full-text search keywords (mirrors Python detect_special_features). */
|
|
16
|
+
static detectFullTextSearch(query: unknown): boolean;
|
|
17
|
+
/** Resolve batch size when values is an array of parameter arrays (executemany-style). */
|
|
18
|
+
static resolveBatchSize(values: unknown): number | undefined;
|
|
19
|
+
/** Build the human-readable query summary (mirrors Python get_query_summary). */
|
|
20
|
+
static getQuerySummary(dbOperation: string, tableName: string, query: unknown): string;
|
|
21
|
+
/** Sanitize a parameter value for safe inclusion in a span (mirrors Python sanitize_parameter). */
|
|
22
|
+
static sanitizeParameter(value: unknown): string;
|
|
23
|
+
/**
|
|
24
|
+
* Extract { host, port, database } from a `pg` Client / Pool instance.
|
|
25
|
+
* `pg` stores connection params on the instance (and Pool on `options`).
|
|
26
|
+
* Defaults mirror the Python psycopg instrumentation (localhost:5432).
|
|
27
|
+
*/
|
|
28
|
+
static extractConnectionInfo(instance: any): {
|
|
29
|
+
host: string;
|
|
30
|
+
port: number;
|
|
31
|
+
database?: string;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Resolve the SQL text and the parameter values from the `pg` query() arguments.
|
|
35
|
+
* Supports: (text, values?, cb?), ({ text, values, name }, cb?), and submittables.
|
|
36
|
+
*/
|
|
37
|
+
static resolveQuery(args: any[]): {
|
|
38
|
+
queryText: unknown;
|
|
39
|
+
values: unknown;
|
|
40
|
+
};
|
|
41
|
+
/** Pull the last argument if it is a node-style callback. */
|
|
42
|
+
static extractCallback(args: any[]): ((...cbArgs: any[]) => void) | undefined;
|
|
43
|
+
/** Stamp all span attributes (mirrors Python common_psycopg_logic). */
|
|
44
|
+
static setSpanAttributes(span: Span, { dbOperation, tableName, queryText, values, connInfo, durationSeconds, rowCount, batchSize, captureDbParameters, sdkVersion, }: {
|
|
45
|
+
dbOperation: string;
|
|
46
|
+
tableName: string;
|
|
47
|
+
queryText: unknown;
|
|
48
|
+
values: unknown;
|
|
49
|
+
connInfo: {
|
|
50
|
+
host: string;
|
|
51
|
+
port: number;
|
|
52
|
+
database?: string;
|
|
53
|
+
};
|
|
54
|
+
durationSeconds: number;
|
|
55
|
+
rowCount?: number | null;
|
|
56
|
+
batchSize?: number;
|
|
57
|
+
captureDbParameters: boolean;
|
|
58
|
+
sdkVersion?: string;
|
|
59
|
+
}): void;
|
|
60
|
+
/**
|
|
61
|
+
* Build the patched `query()` replacement. Handles callback, promise, and
|
|
62
|
+
* submittable forms while always producing a single CLIENT span.
|
|
63
|
+
*/
|
|
64
|
+
static _patchQuery(tracer: Tracer, config?: PgWrapperConfig): any;
|
|
65
|
+
}
|
|
66
|
+
export default PgWrapper;
|
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
const api_1 = require("@opentelemetry/api");
|
|
40
|
+
const core_1 = require("@opentelemetry/core");
|
|
41
|
+
const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
|
|
42
|
+
const config_1 = __importDefault(require("../../config"));
|
|
43
|
+
const constant_1 = require("../../constant");
|
|
44
|
+
const helpers_1 = __importStar(require("../../helpers"));
|
|
45
|
+
const metrics_1 = __importDefault(require("../../otel/metrics"));
|
|
46
|
+
const semantic_convention_1 = __importDefault(require("../../semantic-convention"));
|
|
47
|
+
const base_wrapper_1 = __importDefault(require("../base-wrapper"));
|
|
48
|
+
/**
|
|
49
|
+
* PostgreSQL (`pg`) instrumentation wrapper.
|
|
50
|
+
*
|
|
51
|
+
* Mirrors the Python SDK psycopg instrumentation
|
|
52
|
+
* (sdk/python/src/shield360/instrumentation/psycopg) for the Node `pg` driver:
|
|
53
|
+
* - parses the SQL operation (SELECT/INSERT/...) and target table for span naming,
|
|
54
|
+
* - detects pgvector similarity operators (`<=>`, `<->`, `<#>`),
|
|
55
|
+
* - honors a `captureDbParameters` toggle to record query parameters
|
|
56
|
+
* (off by default — parameters can contain PII/secrets),
|
|
57
|
+
* - sets the same `db.*` semantic-convention attributes the Python SDK sets.
|
|
58
|
+
*
|
|
59
|
+
* The `pg` `query()` method has three call shapes which must all be handled:
|
|
60
|
+
* 1. callback: client.query(text, values?, (err, res) => {}) → no return value
|
|
61
|
+
* 2. promise: const res = await client.query(text, values?) → returns a thenable
|
|
62
|
+
* 3. submittable: client.query(new Query(...)) / cursors → returns the submittable
|
|
63
|
+
*/
|
|
64
|
+
// Maximum number of query parameters to capture (matches Python MAX_PARAMS_COUNT).
|
|
65
|
+
const MAX_PARAMS_COUNT = 50;
|
|
66
|
+
// Maximum captured parameter value length (matches Python MAX_PARAM_LENGTH).
|
|
67
|
+
const MAX_PARAM_LENGTH = 256;
|
|
68
|
+
// Map of leading SQL keyword → db.operation.name value (mirrors Python SQL_OPERATION_MAP).
|
|
69
|
+
const SQL_OPERATION_MAP = {
|
|
70
|
+
SELECT: semantic_convention_1.default.DB_OPERATION_SELECT,
|
|
71
|
+
INSERT: semantic_convention_1.default.DB_OPERATION_INSERT,
|
|
72
|
+
UPDATE: semantic_convention_1.default.DB_OPERATION_UPDATE,
|
|
73
|
+
DELETE: semantic_convention_1.default.DB_OPERATION_DELETE,
|
|
74
|
+
COPY: semantic_convention_1.default.DB_OPERATION_COPY,
|
|
75
|
+
CREATE: semantic_convention_1.default.DB_OPERATION_CREATE,
|
|
76
|
+
ALTER: semantic_convention_1.default.DB_OPERATION_ALTER,
|
|
77
|
+
DROP: semantic_convention_1.default.DB_OPERATION_DROP,
|
|
78
|
+
TRUNCATE: semantic_convention_1.default.DB_OPERATION_TRUNCATE,
|
|
79
|
+
COMMIT: semantic_convention_1.default.DB_OPERATION_COMMIT,
|
|
80
|
+
ROLLBACK: semantic_convention_1.default.DB_OPERATION_ROLLBACK,
|
|
81
|
+
};
|
|
82
|
+
// Table-name extraction patterns (mirrors Python TABLE_PATTERNS).
|
|
83
|
+
const TABLE_PATTERNS = [
|
|
84
|
+
/INSERT\s+INTO\s+["']?(\w+)["']?/i,
|
|
85
|
+
/UPDATE\s+["']?(\w+)["']?/i,
|
|
86
|
+
/DELETE\s+FROM\s+["']?(\w+)["']?/i,
|
|
87
|
+
/FROM\s+["']?(\w+)["']?/i,
|
|
88
|
+
/TRUNCATE\s+(?:TABLE\s+)?["']?(\w+)["']?/i,
|
|
89
|
+
/CREATE\s+(?:TABLE|INDEX)\s+(?:IF\s+NOT\s+EXISTS\s+)?["']?(\w+)["']?/i,
|
|
90
|
+
/ALTER\s+TABLE\s+["']?(\w+)["']?/i,
|
|
91
|
+
/DROP\s+(?:TABLE|INDEX)\s+(?:IF\s+EXISTS\s+)?["']?(\w+)["']?/i,
|
|
92
|
+
/COPY\s+["']?(\w+)["']?/i,
|
|
93
|
+
];
|
|
94
|
+
function recordDbMetrics(dbOperation, connInfo, durationSeconds) {
|
|
95
|
+
if (config_1.default.disableMetrics) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const applicationName = config_1.default.applicationName || '';
|
|
99
|
+
const environment = config_1.default.environment || '';
|
|
100
|
+
const attributes = {
|
|
101
|
+
[semantic_conventions_1.ATTR_TELEMETRY_SDK_NAME]: constant_1.SDK_NAME,
|
|
102
|
+
[semantic_conventions_1.ATTR_SERVICE_NAME]: applicationName,
|
|
103
|
+
[semantic_conventions_1.SEMRESATTRS_DEPLOYMENT_ENVIRONMENT]: environment,
|
|
104
|
+
[semantic_convention_1.default.DB_SYSTEM_NAME]: PgWrapper.dbSystem,
|
|
105
|
+
[semantic_convention_1.default.DB_OPERATION_NAME]: dbOperation,
|
|
106
|
+
[semantic_convention_1.default.SERVER_ADDRESS]: connInfo.host,
|
|
107
|
+
[semantic_convention_1.default.SERVER_PORT]: connInfo.port,
|
|
108
|
+
};
|
|
109
|
+
metrics_1.default.dbRequests?.add(1, attributes);
|
|
110
|
+
metrics_1.default.dbClientOperationDuration?.record(durationSeconds, attributes);
|
|
111
|
+
}
|
|
112
|
+
class PgWrapper extends base_wrapper_1.default {
|
|
113
|
+
/** Detect the SQL operation verb from a query string (mirrors Python parse_sql_operation). */
|
|
114
|
+
static parseSqlOperation(query) {
|
|
115
|
+
if (query === null || query === undefined) {
|
|
116
|
+
return semantic_convention_1.default.DB_OPERATION_QUERY;
|
|
117
|
+
}
|
|
118
|
+
const queryStr = String(query).trim();
|
|
119
|
+
if (!queryStr) {
|
|
120
|
+
return semantic_convention_1.default.DB_OPERATION_QUERY;
|
|
121
|
+
}
|
|
122
|
+
const queryUpper = queryStr.toUpperCase();
|
|
123
|
+
for (const [keyword, operation] of Object.entries(SQL_OPERATION_MAP)) {
|
|
124
|
+
if (queryUpper.startsWith(keyword)) {
|
|
125
|
+
return operation;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
// Handle WITH ... SELECT/INSERT/UPDATE/DELETE (CTEs).
|
|
129
|
+
if (queryUpper.startsWith('WITH')) {
|
|
130
|
+
for (const [keyword, operation] of Object.entries(SQL_OPERATION_MAP)) {
|
|
131
|
+
if (queryUpper.includes(keyword)) {
|
|
132
|
+
return operation;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return semantic_convention_1.default.DB_OPERATION_QUERY;
|
|
137
|
+
}
|
|
138
|
+
/** Extract the target table name for span naming (mirrors Python extract_table_name). */
|
|
139
|
+
static extractTableName(query) {
|
|
140
|
+
if (query === null || query === undefined) {
|
|
141
|
+
return 'unknown';
|
|
142
|
+
}
|
|
143
|
+
const queryStr = String(query);
|
|
144
|
+
for (const pattern of TABLE_PATTERNS) {
|
|
145
|
+
const match = pattern.exec(queryStr);
|
|
146
|
+
if (match) {
|
|
147
|
+
return match[1];
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return 'unknown';
|
|
151
|
+
}
|
|
152
|
+
/** Detect pgvector similarity operator → metric name (mirrors Python detect_special_features). */
|
|
153
|
+
static detectSimilarityMetric(query) {
|
|
154
|
+
if (query === null || query === undefined) {
|
|
155
|
+
return undefined;
|
|
156
|
+
}
|
|
157
|
+
const queryStr = String(query);
|
|
158
|
+
if (queryStr.includes('<=>'))
|
|
159
|
+
return 'cosine';
|
|
160
|
+
if (queryStr.includes('<->'))
|
|
161
|
+
return 'l2';
|
|
162
|
+
if (queryStr.includes('<#>'))
|
|
163
|
+
return 'inner_product';
|
|
164
|
+
return undefined;
|
|
165
|
+
}
|
|
166
|
+
/** Detect full-text search keywords (mirrors Python detect_special_features). */
|
|
167
|
+
static detectFullTextSearch(query) {
|
|
168
|
+
if (query === null || query === undefined) {
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
const queryUpper = String(query).toUpperCase();
|
|
172
|
+
return (queryUpper.includes('TSVECTOR') ||
|
|
173
|
+
queryUpper.includes('TSQUERY') ||
|
|
174
|
+
queryUpper.includes('TS_RANK') ||
|
|
175
|
+
queryUpper.includes('WEBSEARCH_TO_TSQUERY'));
|
|
176
|
+
}
|
|
177
|
+
/** Resolve batch size when values is an array of parameter arrays (executemany-style). */
|
|
178
|
+
static resolveBatchSize(values) {
|
|
179
|
+
if (!Array.isArray(values) || values.length === 0) {
|
|
180
|
+
return undefined;
|
|
181
|
+
}
|
|
182
|
+
if (Array.isArray(values[0])) {
|
|
183
|
+
return values.length;
|
|
184
|
+
}
|
|
185
|
+
return undefined;
|
|
186
|
+
}
|
|
187
|
+
/** Build the human-readable query summary (mirrors Python get_query_summary). */
|
|
188
|
+
static getQuerySummary(dbOperation, tableName, query) {
|
|
189
|
+
let summary = `${dbOperation} ${tableName}`;
|
|
190
|
+
const metric = PgWrapper.detectSimilarityMetric(query);
|
|
191
|
+
if (metric) {
|
|
192
|
+
summary += ` (vector ${metric})`;
|
|
193
|
+
}
|
|
194
|
+
if (PgWrapper.detectFullTextSearch(query)) {
|
|
195
|
+
summary += ' (full-text)';
|
|
196
|
+
}
|
|
197
|
+
return summary;
|
|
198
|
+
}
|
|
199
|
+
/** Sanitize a parameter value for safe inclusion in a span (mirrors Python sanitize_parameter). */
|
|
200
|
+
static sanitizeParameter(value) {
|
|
201
|
+
if (value === null || value === undefined) {
|
|
202
|
+
return 'NULL';
|
|
203
|
+
}
|
|
204
|
+
if (value instanceof Uint8Array || Buffer.isBuffer(value)) {
|
|
205
|
+
return `<bytes:${value.length}>`;
|
|
206
|
+
}
|
|
207
|
+
let strValue;
|
|
208
|
+
try {
|
|
209
|
+
strValue = typeof value === 'object' ? JSON.stringify(value) : String(value);
|
|
210
|
+
}
|
|
211
|
+
catch {
|
|
212
|
+
return '<unrepresentable>';
|
|
213
|
+
}
|
|
214
|
+
if (strValue.length > MAX_PARAM_LENGTH) {
|
|
215
|
+
return `${strValue.slice(0, MAX_PARAM_LENGTH)}...<truncated:${strValue.length}>`;
|
|
216
|
+
}
|
|
217
|
+
return strValue;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Extract { host, port, database } from a `pg` Client / Pool instance.
|
|
221
|
+
* `pg` stores connection params on the instance (and Pool on `options`).
|
|
222
|
+
* Defaults mirror the Python psycopg instrumentation (localhost:5432).
|
|
223
|
+
*/
|
|
224
|
+
static extractConnectionInfo(instance) {
|
|
225
|
+
const defaults = { host: 'localhost', port: 5432 };
|
|
226
|
+
try {
|
|
227
|
+
const params = instance?.connectionParameters || instance?.options || instance || {};
|
|
228
|
+
const host = params.host || defaults.host;
|
|
229
|
+
const port = params.port ? Number(params.port) : defaults.port;
|
|
230
|
+
const database = params.database;
|
|
231
|
+
return { host, port: Number.isFinite(port) ? port : defaults.port, database };
|
|
232
|
+
}
|
|
233
|
+
catch {
|
|
234
|
+
return defaults;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Resolve the SQL text and the parameter values from the `pg` query() arguments.
|
|
239
|
+
* Supports: (text, values?, cb?), ({ text, values, name }, cb?), and submittables.
|
|
240
|
+
*/
|
|
241
|
+
static resolveQuery(args) {
|
|
242
|
+
const first = args[0];
|
|
243
|
+
if (typeof first === 'string') {
|
|
244
|
+
return { queryText: first, values: Array.isArray(args[1]) ? args[1] : undefined };
|
|
245
|
+
}
|
|
246
|
+
if (first && typeof first === 'object') {
|
|
247
|
+
// Query config object or a Submittable (Query/Cursor) — both may carry `text`/`values`.
|
|
248
|
+
const queryText = 'text' in first ? first.text : undefined;
|
|
249
|
+
const values = 'values' in first ? first.values : undefined;
|
|
250
|
+
return { queryText, values };
|
|
251
|
+
}
|
|
252
|
+
return { queryText: undefined, values: undefined };
|
|
253
|
+
}
|
|
254
|
+
/** Pull the last argument if it is a node-style callback. */
|
|
255
|
+
static extractCallback(args) {
|
|
256
|
+
const last = args[args.length - 1];
|
|
257
|
+
return typeof last === 'function' ? last : undefined;
|
|
258
|
+
}
|
|
259
|
+
/** Stamp all span attributes (mirrors Python common_psycopg_logic). */
|
|
260
|
+
static setSpanAttributes(span, { dbOperation, tableName, queryText, values, connInfo, durationSeconds, rowCount, batchSize, captureDbParameters, sdkVersion, }) {
|
|
261
|
+
const applicationName = config_1.default.applicationName || '';
|
|
262
|
+
const environment = config_1.default.environment || '';
|
|
263
|
+
span.setAttribute(semantic_conventions_1.ATTR_TELEMETRY_SDK_NAME, constant_1.SDK_NAME);
|
|
264
|
+
span.setAttribute(semantic_convention_1.default.GEN_AI_OPERATION, semantic_convention_1.default.GEN_AI_OPERATION_TYPE_VECTORDB);
|
|
265
|
+
span.setAttribute(semantic_convention_1.default.DB_SYSTEM_NAME, PgWrapper.dbSystem);
|
|
266
|
+
span.setAttribute(semantic_convention_1.default.DB_OPERATION_NAME, dbOperation);
|
|
267
|
+
span.setAttribute(semantic_convention_1.default.SERVER_ADDRESS, connInfo.host);
|
|
268
|
+
span.setAttribute(semantic_convention_1.default.SERVER_PORT, connInfo.port);
|
|
269
|
+
span.setAttribute(semantic_convention_1.default.ATTR_DEPLOYMENT_ENVIRONMENT, environment);
|
|
270
|
+
span.setAttribute(semantic_conventions_1.ATTR_SERVICE_NAME, applicationName);
|
|
271
|
+
span.setAttribute(semantic_convention_1.default.DB_CLIENT_OPERATION_DURATION, durationSeconds);
|
|
272
|
+
if (sdkVersion) {
|
|
273
|
+
span.setAttribute(semantic_convention_1.default.DB_SDK_VERSION, sdkVersion);
|
|
274
|
+
}
|
|
275
|
+
if (connInfo.database && connInfo.database !== 'unknown') {
|
|
276
|
+
span.setAttribute(semantic_convention_1.default.DB_NAMESPACE_POSTGRESQL, connInfo.database);
|
|
277
|
+
}
|
|
278
|
+
if (tableName && tableName !== 'unknown') {
|
|
279
|
+
span.setAttribute(semantic_convention_1.default.DB_COLLECTION_NAME, tableName);
|
|
280
|
+
}
|
|
281
|
+
if (typeof batchSize === 'number' && batchSize > 0) {
|
|
282
|
+
span.setAttribute(semantic_convention_1.default.DB_BATCH_SIZE, batchSize);
|
|
283
|
+
}
|
|
284
|
+
// Capture query text when message-content capture is enabled (parity w/ Python).
|
|
285
|
+
if (config_1.default.captureMessageContent && queryText) {
|
|
286
|
+
let queryStr = String(queryText);
|
|
287
|
+
const maxLen = config_1.default.maxContentLength;
|
|
288
|
+
if (typeof maxLen === 'number' && maxLen > 0 && queryStr.length > maxLen) {
|
|
289
|
+
queryStr = queryStr.slice(0, maxLen);
|
|
290
|
+
}
|
|
291
|
+
span.setAttribute(semantic_convention_1.default.DB_QUERY_TEXT, queryStr);
|
|
292
|
+
}
|
|
293
|
+
// Capture query parameters (OTel per-index convention) only when explicitly enabled.
|
|
294
|
+
const paramsForCapture = typeof batchSize === 'number' && batchSize > 0 && Array.isArray(values)
|
|
295
|
+
? values[0]
|
|
296
|
+
: values;
|
|
297
|
+
if (captureDbParameters && paramsForCapture !== null && paramsForCapture !== undefined) {
|
|
298
|
+
if (Array.isArray(paramsForCapture)) {
|
|
299
|
+
paramsForCapture.slice(0, MAX_PARAMS_COUNT).forEach((value, idx) => {
|
|
300
|
+
span.setAttribute(`${semantic_convention_1.default.DB_QUERY_PARAMETER}.${idx}`, PgWrapper.sanitizeParameter(value));
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
else if (typeof paramsForCapture === 'object') {
|
|
304
|
+
Object.entries(paramsForCapture)
|
|
305
|
+
.slice(0, MAX_PARAMS_COUNT)
|
|
306
|
+
.forEach(([key, value]) => {
|
|
307
|
+
span.setAttribute(`${semantic_convention_1.default.DB_QUERY_PARAMETER}.${key}`, PgWrapper.sanitizeParameter(value));
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
span.setAttribute(semantic_convention_1.default.DB_QUERY_SUMMARY, PgWrapper.getQuerySummary(dbOperation, tableName, queryText));
|
|
312
|
+
if (typeof rowCount === 'number' && rowCount >= 0) {
|
|
313
|
+
span.setAttribute(semantic_convention_1.default.DB_RESPONSE_RETURNED_ROWS, rowCount);
|
|
314
|
+
}
|
|
315
|
+
// pgvector similarity metric.
|
|
316
|
+
const metric = PgWrapper.detectSimilarityMetric(queryText);
|
|
317
|
+
if (metric) {
|
|
318
|
+
span.setAttribute(semantic_convention_1.default.DB_SEARCH_SIMILARITY_METRIC, metric);
|
|
319
|
+
}
|
|
320
|
+
(0, helpers_1.applyCustomSpanAttributes)(span);
|
|
321
|
+
span.setStatus({ code: api_1.SpanStatusCode.OK });
|
|
322
|
+
recordDbMetrics(dbOperation, connInfo, durationSeconds);
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Build the patched `query()` replacement. Handles callback, promise, and
|
|
326
|
+
* submittable forms while always producing a single CLIENT span.
|
|
327
|
+
*/
|
|
328
|
+
static _patchQuery(tracer, config = {}) {
|
|
329
|
+
const captureDbParameters = Boolean(config.captureDbParameters);
|
|
330
|
+
const sdkVersion = config.sdkVersion;
|
|
331
|
+
return (originalQuery) => {
|
|
332
|
+
return function (...args) {
|
|
333
|
+
if ((0, core_1.isTracingSuppressed)(api_1.context.active())) {
|
|
334
|
+
return originalQuery.apply(this, args);
|
|
335
|
+
}
|
|
336
|
+
const { queryText, values } = PgWrapper.resolveQuery(args);
|
|
337
|
+
const dbOperation = PgWrapper.parseSqlOperation(queryText);
|
|
338
|
+
const tableName = PgWrapper.extractTableName(queryText);
|
|
339
|
+
const batchSize = PgWrapper.resolveBatchSize(values);
|
|
340
|
+
const connInfo = PgWrapper.extractConnectionInfo(this);
|
|
341
|
+
const spanName = typeof batchSize === 'number' && batchSize > 0
|
|
342
|
+
? `${dbOperation} ${tableName} (batch)`
|
|
343
|
+
: `${dbOperation} ${tableName}`;
|
|
344
|
+
const span = tracer.startSpan(spanName, { kind: api_1.SpanKind.CLIENT });
|
|
345
|
+
const startTime = Date.now();
|
|
346
|
+
const finalize = (result) => {
|
|
347
|
+
try {
|
|
348
|
+
const durationSeconds = (Date.now() - startTime) / 1000;
|
|
349
|
+
const rowCount = result && typeof result.rowCount === 'number' ? result.rowCount : undefined;
|
|
350
|
+
PgWrapper.setSpanAttributes(span, {
|
|
351
|
+
dbOperation,
|
|
352
|
+
tableName,
|
|
353
|
+
queryText,
|
|
354
|
+
values,
|
|
355
|
+
connInfo,
|
|
356
|
+
durationSeconds,
|
|
357
|
+
rowCount,
|
|
358
|
+
batchSize,
|
|
359
|
+
captureDbParameters,
|
|
360
|
+
sdkVersion,
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
catch (attrErr) {
|
|
364
|
+
helpers_1.default.handleException(span, attrErr);
|
|
365
|
+
}
|
|
366
|
+
finally {
|
|
367
|
+
span.end();
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
const fail = (error) => {
|
|
371
|
+
helpers_1.default.handleException(span, error);
|
|
372
|
+
span.end();
|
|
373
|
+
};
|
|
374
|
+
return api_1.context.with(api_1.trace.setSpan(api_1.context.active(), span), () => {
|
|
375
|
+
const callback = PgWrapper.extractCallback(args);
|
|
376
|
+
// ── Callback form ────────────────────────────────────────────────
|
|
377
|
+
if (callback) {
|
|
378
|
+
const wrappedCallback = function (err, res) {
|
|
379
|
+
if (err) {
|
|
380
|
+
fail(err);
|
|
381
|
+
}
|
|
382
|
+
else {
|
|
383
|
+
finalize(res);
|
|
384
|
+
}
|
|
385
|
+
return callback.apply(this, [err, res]);
|
|
386
|
+
};
|
|
387
|
+
const newArgs = args.slice(0, -1).concat(wrappedCallback);
|
|
388
|
+
try {
|
|
389
|
+
return originalQuery.apply(this, newArgs);
|
|
390
|
+
}
|
|
391
|
+
catch (syncErr) {
|
|
392
|
+
fail(syncErr);
|
|
393
|
+
throw syncErr;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
// ── Promise / submittable form ───────────────────────────────────
|
|
397
|
+
let result;
|
|
398
|
+
try {
|
|
399
|
+
result = originalQuery.apply(this, args);
|
|
400
|
+
}
|
|
401
|
+
catch (syncErr) {
|
|
402
|
+
fail(syncErr);
|
|
403
|
+
throw syncErr;
|
|
404
|
+
}
|
|
405
|
+
if (result && typeof result.then === 'function') {
|
|
406
|
+
return result.then((res) => {
|
|
407
|
+
finalize(res);
|
|
408
|
+
return res;
|
|
409
|
+
}, (err) => {
|
|
410
|
+
fail(err);
|
|
411
|
+
throw err;
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
// Submittable (Query/Cursor) — no promise, no callback. Listen for completion.
|
|
415
|
+
if (result && typeof result.on === 'function') {
|
|
416
|
+
let settled = false;
|
|
417
|
+
result.on('end', () => {
|
|
418
|
+
if (settled)
|
|
419
|
+
return;
|
|
420
|
+
settled = true;
|
|
421
|
+
finalize(result);
|
|
422
|
+
});
|
|
423
|
+
result.on('error', (err) => {
|
|
424
|
+
if (settled)
|
|
425
|
+
return;
|
|
426
|
+
settled = true;
|
|
427
|
+
fail(err);
|
|
428
|
+
});
|
|
429
|
+
return result;
|
|
430
|
+
}
|
|
431
|
+
// Unknown shape — close the span without a row count.
|
|
432
|
+
finalize(result);
|
|
433
|
+
return result;
|
|
434
|
+
});
|
|
435
|
+
};
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
PgWrapper.dbSystem = semantic_convention_1.default.DB_SYSTEM_POSTGRESQL;
|
|
440
|
+
exports.default = PgWrapper;
|
|
441
|
+
//# sourceMappingURL=wrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrapper.js","sourceRoot":"","sources":["../../../src/instrumentation/pg/wrapper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAQ4B;AAC5B,8CAA0D;AAC1D,8EAI6C;AAC7C,0DAA2C;AAC3C,6CAA0C;AAC1C,yDAA2E;AAC3E,iEAAyC;AACzC,oFAA2D;AAC3D,mEAA0C;AAE1C;;;;;;;;;;;;;;;GAeG;AAEH,mFAAmF;AACnF,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAC5B,6EAA6E;AAC7E,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAE7B,2FAA2F;AAC3F,MAAM,iBAAiB,GAA2B;IAChD,MAAM,EAAE,6BAAkB,CAAC,mBAAmB;IAC9C,MAAM,EAAE,6BAAkB,CAAC,mBAAmB;IAC9C,MAAM,EAAE,6BAAkB,CAAC,mBAAmB;IAC9C,MAAM,EAAE,6BAAkB,CAAC,mBAAmB;IAC9C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ACZ,CAAC,CAAC,CAAC;wBACH,OAAO,MAAM,CAAC;oBAChB,CAAC;oBAED,sDAAsD;oBACtD,QAAQ,CAAC,MAAM,CAAC,CAAC;oBACjB,OAAO,MAAM,CAAC;gBAChB,CAAC,CAAC,CAAC;YACL,CAAC,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC;;AAjYM,kBAAQ,GAAG,6BAAkB,CAAC,oBAAoB,CAAC;AAoY5D,kBAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { InstrumentationBase, InstrumentationModuleDefinition } from '@opentelemetry/instrumentation';
|
|
2
|
+
import { InstrumentationConfig } from '@opentelemetry/instrumentation';
|
|
3
|
+
export interface PineconeInstrumentationConfig extends InstrumentationConfig {
|
|
4
|
+
}
|
|
5
|
+
export default class Shield360PineconeInstrumentation extends InstrumentationBase {
|
|
6
|
+
constructor(config?: PineconeInstrumentationConfig);
|
|
7
|
+
protected init(): void | InstrumentationModuleDefinition | InstrumentationModuleDefinition[];
|
|
8
|
+
manualPatch(pinecone: any): void;
|
|
9
|
+
protected _patch(moduleExports: any): void;
|
|
10
|
+
protected _unpatch(moduleExports: any): void;
|
|
11
|
+
}
|