autotel-genai 0.3.12 → 0.4.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/dist/agent/index.d.cts +1 -1
- package/dist/agent/index.d.ts +1 -1
- package/dist/ai-sdk-bridge.d.cts +2 -2
- package/dist/ai-sdk-bridge.d.ts +2 -2
- package/dist/{attributes-BeU1n3Xb.d.cts → attributes-C7k871NW.d.cts} +1 -1
- package/dist/{attributes-CLmcQcNP.d.ts → attributes-jUO1pbUc.d.ts} +1 -1
- package/dist/{events-BKns22B0.d.ts → events-CXHe4AL7.d.ts} +1 -1
- package/dist/{events-D2-Y94tX.d.cts → events-Diz0gxop.d.cts} +1 -1
- package/dist/events.d.cts +1 -1
- package/dist/events.d.ts +1 -1
- package/dist/{index-D-6RBbqV.d.cts → index-Bgt8apSM.d.cts} +3 -3
- package/dist/{index-DLdEgWWh.d.ts → index-D010Y_xS.d.ts} +1 -1
- package/dist/{index-BIj0iUEx.d.cts → index-Dc450L-d.d.cts} +1 -1
- package/dist/{index-Bdn7khCZ.d.ts → index-Lg3gQ_VO.d.ts} +3 -3
- package/dist/index.cjs +2 -0
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +2 -2
- package/dist/metrics.cjs +85 -2
- package/dist/metrics.d.cts +29 -1
- package/dist/metrics.d.ts +29 -1
- package/dist/metrics.js +84 -3
- package/dist/observer/index.d.cts +1 -1
- package/dist/observer/index.d.ts +1 -1
- package/dist/{semconv-2VyDPIuF.d.cts → semconv-B6zNvJ73.d.cts} +2 -0
- package/dist/{semconv-2VyDPIuF.d.ts → semconv-B6zNvJ73.d.ts} +2 -0
- package/dist/semconv.cjs +3 -1
- package/dist/semconv.d.cts +1 -1
- package/dist/semconv.d.ts +1 -1
- package/dist/semconv.js +3 -1
- package/dist/trace.cjs +84 -1
- package/dist/trace.d.cts +8 -2
- package/dist/trace.d.ts +8 -2
- package/dist/trace.js +85 -2
- package/package.json +3 -3
package/dist/agent/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as AgentToolCallOptions, A as delegateToAgent, B as AgentDecisionMetadata, C as defineAgentToolCall, D as withAgentToolCall, E as withAgentAction, F as AgentActionFactory, G as AgentIdentityRegistry, H as AgentHandler, I as AgentActionMetadata, J as AgentOutcome, K as AgentIdentityStatus, L as AgentActionOptions, M as flattenAgentAttributes, N as setAgentAttributes, O as DelegateToAgentInput, P as createAgentAuditMetadata, Q as AgentToolCallActionMetadata, R as AgentAiMetadata, S as defineAgentAction, T as recordPolicyDecision, U as AgentIdentity, V as AgentEventKind, W as AgentIdentityRecord, X as AgentSessionMetadata, Y as AgentSessionActionMetadata, Z as AgentSessionStatus, _ as ProvisionAgentIdentityInput, a as AgentPlanRiskVerdict, at as PrivacyProfile, b as createAgentIdentityRegistry, c as recordPlanRiskAssessment, ct as ToolCallMetadata, d as CreateSignedEventEnvelopeOptions, dt as canonicalizeForHash, et as AiLifecycleStage, f as createSignedEventEnvelope, ft as hashPayload, g as sanitizeAuditPayload, h as resolvePrivacyProfile, i as AgentPlanClassifierResult, it as PolicyMetadata, j as recordAgentHandoff, k as RecordAgentHandoffMetadata, l as runAgentPlanClassifier, lt as ToolStatus, m as PrivacyProfileInput, n as AgentPlanClassifier, nt as GovernanceMetadata, o as RecordPlanRiskAssessmentOptions, ot as PrivacyProfileName, p as verifyEventEnvelopeHash, pt as AGENT_AUDIT_SCHEMA_VERSION, q as AgentMetadataInput, r as AgentPlanClassifierInput, rt as PolicyDecision, s as heuristicPlanRiskClassifier, st as ScopedToolDefinition, t as AGENT_PLAN_RISK_ATTR, tt as DelegationContext, u as withScopedTool, ut as HashPayloadOptions, v as RevokeAgentIdentityInput, w as recordDecisionBasis, x as withAgentSession, y as RotateAgentIdentityInput, z as AgentAuditEventEnvelope } from "../index-
|
|
1
|
+
import { $ as AgentToolCallOptions, A as delegateToAgent, B as AgentDecisionMetadata, C as defineAgentToolCall, D as withAgentToolCall, E as withAgentAction, F as AgentActionFactory, G as AgentIdentityRegistry, H as AgentHandler, I as AgentActionMetadata, J as AgentOutcome, K as AgentIdentityStatus, L as AgentActionOptions, M as flattenAgentAttributes, N as setAgentAttributes, O as DelegateToAgentInput, P as createAgentAuditMetadata, Q as AgentToolCallActionMetadata, R as AgentAiMetadata, S as defineAgentAction, T as recordPolicyDecision, U as AgentIdentity, V as AgentEventKind, W as AgentIdentityRecord, X as AgentSessionMetadata, Y as AgentSessionActionMetadata, Z as AgentSessionStatus, _ as ProvisionAgentIdentityInput, a as AgentPlanRiskVerdict, at as PrivacyProfile, b as createAgentIdentityRegistry, c as recordPlanRiskAssessment, ct as ToolCallMetadata, d as CreateSignedEventEnvelopeOptions, dt as canonicalizeForHash, et as AiLifecycleStage, f as createSignedEventEnvelope, ft as hashPayload, g as sanitizeAuditPayload, h as resolvePrivacyProfile, i as AgentPlanClassifierResult, it as PolicyMetadata, j as recordAgentHandoff, k as RecordAgentHandoffMetadata, l as runAgentPlanClassifier, lt as ToolStatus, m as PrivacyProfileInput, n as AgentPlanClassifier, nt as GovernanceMetadata, o as RecordPlanRiskAssessmentOptions, ot as PrivacyProfileName, p as verifyEventEnvelopeHash, pt as AGENT_AUDIT_SCHEMA_VERSION, q as AgentMetadataInput, r as AgentPlanClassifierInput, rt as PolicyDecision, s as heuristicPlanRiskClassifier, st as ScopedToolDefinition, t as AGENT_PLAN_RISK_ATTR, tt as DelegationContext, u as withScopedTool, ut as HashPayloadOptions, v as RevokeAgentIdentityInput, w as recordDecisionBasis, x as withAgentSession, y as RotateAgentIdentityInput, z as AgentAuditEventEnvelope } from "../index-Dc450L-d.cjs";
|
|
2
2
|
import { a as TokenUsage, i as ModelPricing } from "../cost-C1FkUNG1.cjs";
|
|
3
3
|
import { C as recordPlanStep, D as agentContextFromSpan, E as AgentContext, S as recordMemoryAccess, T as tryRecordHumanApproval, _ as recordActionRiskClass, a as AgentInputProvenance, b as recordHumanApproval, c as AgentSecurityRecordOptions, d as RecordHumanApprovalInput, f as RecordInputProvenanceInput, g as deriveActionRiskClass, h as RecordRenderOutputInput, i as AgentConsentOutcome, l as RecordActiveScopesInput, m as RecordPlanStepInput, n as ActionRiskHints, o as AgentMemoryOperation, p as RecordMemoryAccessInput, r as AgentActionRiskClass, s as AgentOutputFormat, t as AGENT_SECURITY_ATTR, u as RecordControllerInput, v as recordActiveScopes, w as recordRenderOutput, x as recordInputProvenance, y as recordControllerId } from "../agent-security-BHdP6ZPG.cjs";
|
|
4
4
|
export { AGENT_AUDIT_SCHEMA_VERSION, AGENT_PLAN_RISK_ATTR, AGENT_SECURITY_ATTR, type ActionRiskHints, type AgentActionFactory, type AgentActionMetadata, type AgentActionOptions, type AgentActionRiskClass, type AgentAiMetadata, type AgentAuditEventEnvelope, type AgentConsentOutcome, type AgentContext, type AgentDecisionMetadata, type AgentEventKind, type AgentHandler, type AgentIdentity, type AgentIdentityRecord, type AgentIdentityRegistry, type AgentIdentityStatus, type AgentInputProvenance, type AgentMemoryOperation, type AgentMetadataInput, type AgentOutcome, type AgentOutputFormat, type AgentPlanClassifier, type AgentPlanClassifierInput, type AgentPlanClassifierResult, type AgentPlanRiskVerdict, type AgentSecurityRecordOptions, type AgentSessionActionMetadata, type AgentSessionMetadata, type AgentSessionStatus, type AgentToolCallActionMetadata, type AgentToolCallOptions, type AiLifecycleStage, type CreateSignedEventEnvelopeOptions, type DelegateToAgentInput, type DelegationContext, type GovernanceMetadata, type HashPayloadOptions, type ModelPricing, type PolicyDecision, type PolicyMetadata, type PrivacyProfile, type PrivacyProfileInput, type PrivacyProfileName, type ProvisionAgentIdentityInput, type RecordActiveScopesInput, type RecordAgentHandoffMetadata, type RecordControllerInput, type RecordHumanApprovalInput, type RecordInputProvenanceInput, type RecordMemoryAccessInput, type RecordPlanRiskAssessmentOptions, type RecordPlanStepInput, type RecordRenderOutputInput, type RevokeAgentIdentityInput, type RotateAgentIdentityInput, type ScopedToolDefinition, type TokenUsage, type ToolCallMetadata, type ToolStatus, agentContextFromSpan, canonicalizeForHash, createAgentAuditMetadata, createAgentIdentityRegistry, createSignedEventEnvelope, defineAgentAction, defineAgentToolCall, delegateToAgent, deriveActionRiskClass, flattenAgentAttributes, hashPayload, heuristicPlanRiskClassifier, recordActionRiskClass, recordActiveScopes, recordAgentHandoff, recordControllerId, recordDecisionBasis, recordHumanApproval, recordInputProvenance, recordMemoryAccess, recordPlanRiskAssessment, recordPlanStep, recordPolicyDecision, recordRenderOutput, resolvePrivacyProfile, runAgentPlanClassifier, sanitizeAuditPayload, setAgentAttributes, tryRecordHumanApproval, verifyEventEnvelopeHash, withAgentAction, withAgentSession, withAgentToolCall, withScopedTool };
|
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as AgentToolCallOptions, A as delegateToAgent, B as AgentDecisionMetadata, C as defineAgentToolCall, D as withAgentToolCall, E as withAgentAction, F as AgentActionFactory, G as AgentIdentityRegistry, H as AgentHandler, I as AgentActionMetadata, J as AgentOutcome, K as AgentIdentityStatus, L as AgentActionOptions, M as flattenAgentAttributes, N as setAgentAttributes, O as DelegateToAgentInput, P as createAgentAuditMetadata, Q as AgentToolCallActionMetadata, R as AgentAiMetadata, S as defineAgentAction, T as recordPolicyDecision, U as AgentIdentity, V as AgentEventKind, W as AgentIdentityRecord, X as AgentSessionMetadata, Y as AgentSessionActionMetadata, Z as AgentSessionStatus, _ as ProvisionAgentIdentityInput, a as AgentPlanRiskVerdict, at as PrivacyProfile, b as createAgentIdentityRegistry, c as recordPlanRiskAssessment, ct as ToolCallMetadata, d as CreateSignedEventEnvelopeOptions, dt as canonicalizeForHash, et as AiLifecycleStage, f as createSignedEventEnvelope, ft as hashPayload, g as sanitizeAuditPayload, h as resolvePrivacyProfile, i as AgentPlanClassifierResult, it as PolicyMetadata, j as recordAgentHandoff, k as RecordAgentHandoffMetadata, l as runAgentPlanClassifier, lt as ToolStatus, m as PrivacyProfileInput, n as AgentPlanClassifier, nt as GovernanceMetadata, o as RecordPlanRiskAssessmentOptions, ot as PrivacyProfileName, p as verifyEventEnvelopeHash, pt as AGENT_AUDIT_SCHEMA_VERSION, q as AgentMetadataInput, r as AgentPlanClassifierInput, rt as PolicyDecision, s as heuristicPlanRiskClassifier, st as ScopedToolDefinition, t as AGENT_PLAN_RISK_ATTR, tt as DelegationContext, u as withScopedTool, ut as HashPayloadOptions, v as RevokeAgentIdentityInput, w as recordDecisionBasis, x as withAgentSession, y as RotateAgentIdentityInput, z as AgentAuditEventEnvelope } from "../index-
|
|
1
|
+
import { $ as AgentToolCallOptions, A as delegateToAgent, B as AgentDecisionMetadata, C as defineAgentToolCall, D as withAgentToolCall, E as withAgentAction, F as AgentActionFactory, G as AgentIdentityRegistry, H as AgentHandler, I as AgentActionMetadata, J as AgentOutcome, K as AgentIdentityStatus, L as AgentActionOptions, M as flattenAgentAttributes, N as setAgentAttributes, O as DelegateToAgentInput, P as createAgentAuditMetadata, Q as AgentToolCallActionMetadata, R as AgentAiMetadata, S as defineAgentAction, T as recordPolicyDecision, U as AgentIdentity, V as AgentEventKind, W as AgentIdentityRecord, X as AgentSessionMetadata, Y as AgentSessionActionMetadata, Z as AgentSessionStatus, _ as ProvisionAgentIdentityInput, a as AgentPlanRiskVerdict, at as PrivacyProfile, b as createAgentIdentityRegistry, c as recordPlanRiskAssessment, ct as ToolCallMetadata, d as CreateSignedEventEnvelopeOptions, dt as canonicalizeForHash, et as AiLifecycleStage, f as createSignedEventEnvelope, ft as hashPayload, g as sanitizeAuditPayload, h as resolvePrivacyProfile, i as AgentPlanClassifierResult, it as PolicyMetadata, j as recordAgentHandoff, k as RecordAgentHandoffMetadata, l as runAgentPlanClassifier, lt as ToolStatus, m as PrivacyProfileInput, n as AgentPlanClassifier, nt as GovernanceMetadata, o as RecordPlanRiskAssessmentOptions, ot as PrivacyProfileName, p as verifyEventEnvelopeHash, pt as AGENT_AUDIT_SCHEMA_VERSION, q as AgentMetadataInput, r as AgentPlanClassifierInput, rt as PolicyDecision, s as heuristicPlanRiskClassifier, st as ScopedToolDefinition, t as AGENT_PLAN_RISK_ATTR, tt as DelegationContext, u as withScopedTool, ut as HashPayloadOptions, v as RevokeAgentIdentityInput, w as recordDecisionBasis, x as withAgentSession, y as RotateAgentIdentityInput, z as AgentAuditEventEnvelope } from "../index-D010Y_xS.js";
|
|
2
2
|
import { a as TokenUsage, i as ModelPricing } from "../cost-C1FkUNG1.js";
|
|
3
3
|
import { C as recordPlanStep, D as agentContextFromSpan, E as AgentContext, S as recordMemoryAccess, T as tryRecordHumanApproval, _ as recordActionRiskClass, a as AgentInputProvenance, b as recordHumanApproval, c as AgentSecurityRecordOptions, d as RecordHumanApprovalInput, f as RecordInputProvenanceInput, g as deriveActionRiskClass, h as RecordRenderOutputInput, i as AgentConsentOutcome, l as RecordActiveScopesInput, m as RecordPlanStepInput, n as ActionRiskHints, o as AgentMemoryOperation, p as RecordMemoryAccessInput, r as AgentActionRiskClass, s as AgentOutputFormat, t as AGENT_SECURITY_ATTR, u as RecordControllerInput, v as recordActiveScopes, w as recordRenderOutput, x as recordInputProvenance, y as recordControllerId } from "../agent-security-BHdP6ZPG.js";
|
|
4
4
|
export { AGENT_AUDIT_SCHEMA_VERSION, AGENT_PLAN_RISK_ATTR, AGENT_SECURITY_ATTR, type ActionRiskHints, type AgentActionFactory, type AgentActionMetadata, type AgentActionOptions, type AgentActionRiskClass, type AgentAiMetadata, type AgentAuditEventEnvelope, type AgentConsentOutcome, type AgentContext, type AgentDecisionMetadata, type AgentEventKind, type AgentHandler, type AgentIdentity, type AgentIdentityRecord, type AgentIdentityRegistry, type AgentIdentityStatus, type AgentInputProvenance, type AgentMemoryOperation, type AgentMetadataInput, type AgentOutcome, type AgentOutputFormat, type AgentPlanClassifier, type AgentPlanClassifierInput, type AgentPlanClassifierResult, type AgentPlanRiskVerdict, type AgentSecurityRecordOptions, type AgentSessionActionMetadata, type AgentSessionMetadata, type AgentSessionStatus, type AgentToolCallActionMetadata, type AgentToolCallOptions, type AiLifecycleStage, type CreateSignedEventEnvelopeOptions, type DelegateToAgentInput, type DelegationContext, type GovernanceMetadata, type HashPayloadOptions, type ModelPricing, type PolicyDecision, type PolicyMetadata, type PrivacyProfile, type PrivacyProfileInput, type PrivacyProfileName, type ProvisionAgentIdentityInput, type RecordActiveScopesInput, type RecordAgentHandoffMetadata, type RecordControllerInput, type RecordHumanApprovalInput, type RecordInputProvenanceInput, type RecordMemoryAccessInput, type RecordPlanRiskAssessmentOptions, type RecordPlanStepInput, type RecordRenderOutputInput, type RevokeAgentIdentityInput, type RotateAgentIdentityInput, type ScopedToolDefinition, type TokenUsage, type ToolCallMetadata, type ToolStatus, agentContextFromSpan, canonicalizeForHash, createAgentAuditMetadata, createAgentIdentityRegistry, createSignedEventEnvelope, defineAgentAction, defineAgentToolCall, delegateToAgent, deriveActionRiskClass, flattenAgentAttributes, hashPayload, heuristicPlanRiskClassifier, recordActionRiskClass, recordActiveScopes, recordAgentHandoff, recordControllerId, recordDecisionBasis, recordHumanApproval, recordInputProvenance, recordMemoryAccess, recordPlanRiskAssessment, recordPlanStep, recordPolicyDecision, recordRenderOutput, resolvePrivacyProfile, runAgentPlanClassifier, sanitizeAuditPayload, setAgentAttributes, tryRecordHumanApproval, verifyEventEnvelopeHash, withAgentAction, withAgentSession, withAgentToolCall, withScopedTool };
|
package/dist/ai-sdk-bridge.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as TokenUsage, t as EstimateCostOptions } from "./cost-C1FkUNG1.cjs";
|
|
2
|
-
import { m as GenAiProviderName } from "./semconv-
|
|
3
|
-
import { n as GenAiAttributeMap } from "./attributes-
|
|
2
|
+
import { m as GenAiProviderName } from "./semconv-B6zNvJ73.cjs";
|
|
3
|
+
import { n as GenAiAttributeMap } from "./attributes-C7k871NW.cjs";
|
|
4
4
|
import { TraceContext } from "autotel";
|
|
5
5
|
//#region src/ai-sdk-bridge.d.ts
|
|
6
6
|
/** Legacy AI SDK (`LegacyOpenTelemetry`) attribute keys we understand. */
|
package/dist/ai-sdk-bridge.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as TokenUsage, t as EstimateCostOptions } from "./cost-C1FkUNG1.js";
|
|
2
|
-
import { m as GenAiProviderName } from "./semconv-
|
|
3
|
-
import { n as GenAiAttributeMap } from "./attributes-
|
|
2
|
+
import { m as GenAiProviderName } from "./semconv-B6zNvJ73.js";
|
|
3
|
+
import { n as GenAiAttributeMap } from "./attributes-jUO1pbUc.js";
|
|
4
4
|
import { TraceContext } from "autotel";
|
|
5
5
|
//#region src/ai-sdk-bridge.d.ts
|
|
6
6
|
/** Legacy AI SDK (`LegacyOpenTelemetry`) attribute keys we understand. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as GenAiOperationName, g as GenAiToolType, m as GenAiProviderName, p as GenAiOutputType } from "./semconv-
|
|
1
|
+
import { f as GenAiOperationName, g as GenAiToolType, m as GenAiProviderName, p as GenAiOutputType } from "./semconv-B6zNvJ73.cjs";
|
|
2
2
|
//#region src/attributes.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* OpenTelemetry span attribute value — primitives and homogeneous arrays.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as GenAiOperationName, g as GenAiToolType, m as GenAiProviderName, p as GenAiOutputType } from "./semconv-
|
|
1
|
+
import { f as GenAiOperationName, g as GenAiToolType, m as GenAiProviderName, p as GenAiOutputType } from "./semconv-B6zNvJ73.js";
|
|
2
2
|
//#region src/attributes.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* OpenTelemetry span attribute value — primitives and homogeneous arrays.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as GenAiOperationName, m as GenAiProviderName } from "./semconv-
|
|
1
|
+
import { f as GenAiOperationName, m as GenAiProviderName } from "./semconv-B6zNvJ73.js";
|
|
2
2
|
import { TraceContext } from "autotel";
|
|
3
3
|
//#region src/events.d.ts
|
|
4
4
|
/** Minimal sink: just what these helpers touch on a trace context. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as GenAiOperationName, m as GenAiProviderName } from "./semconv-
|
|
1
|
+
import { f as GenAiOperationName, m as GenAiProviderName } from "./semconv-B6zNvJ73.cjs";
|
|
2
2
|
import { TraceContext } from "autotel";
|
|
3
3
|
//#region src/events.d.ts
|
|
4
4
|
/** Minimal sink: just what these helpers touch on a trace context. */
|
package/dist/events.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as GenAiMessagePart, c as InferenceDetailsEvent, d as recordModelWarnings, f as recordOperationException, i as GenAiMessage, l as recordEvaluationResult, n as EvaluationResultEvent, o as GenAiOperationExceptionEvent, p as setGenAiContent, r as GenAiContentSink, s as GenAiWarning, t as ContentCaptureSettings, u as recordInferenceDetails } from "./events-
|
|
1
|
+
import { a as GenAiMessagePart, c as InferenceDetailsEvent, d as recordModelWarnings, f as recordOperationException, i as GenAiMessage, l as recordEvaluationResult, n as EvaluationResultEvent, o as GenAiOperationExceptionEvent, p as setGenAiContent, r as GenAiContentSink, s as GenAiWarning, t as ContentCaptureSettings, u as recordInferenceDetails } from "./events-Diz0gxop.cjs";
|
|
2
2
|
export { ContentCaptureSettings, EvaluationResultEvent, GenAiContentSink, GenAiMessage, GenAiMessagePart, GenAiOperationExceptionEvent, GenAiWarning, InferenceDetailsEvent, recordEvaluationResult, recordInferenceDetails, recordModelWarnings, recordOperationException, setGenAiContent };
|
package/dist/events.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as GenAiMessagePart, c as InferenceDetailsEvent, d as recordModelWarnings, f as recordOperationException, i as GenAiMessage, l as recordEvaluationResult, n as EvaluationResultEvent, o as GenAiOperationExceptionEvent, p as setGenAiContent, r as GenAiContentSink, s as GenAiWarning, t as ContentCaptureSettings, u as recordInferenceDetails } from "./events-
|
|
1
|
+
import { a as GenAiMessagePart, c as InferenceDetailsEvent, d as recordModelWarnings, f as recordOperationException, i as GenAiMessage, l as recordEvaluationResult, n as EvaluationResultEvent, o as GenAiOperationExceptionEvent, p as setGenAiContent, r as GenAiContentSink, s as GenAiWarning, t as ContentCaptureSettings, u as recordInferenceDetails } from "./events-CXHe4AL7.js";
|
|
2
2
|
export { ContentCaptureSettings, EvaluationResultEvent, GenAiContentSink, GenAiMessage, GenAiMessagePart, GenAiOperationExceptionEvent, GenAiWarning, InferenceDetailsEvent, recordEvaluationResult, recordInferenceDetails, recordModelWarnings, recordOperationException, setGenAiContent };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { a as TokenUsage } from "./cost-C1FkUNG1.cjs";
|
|
2
|
-
import { m as GenAiProviderName } from "./semconv-
|
|
2
|
+
import { m as GenAiProviderName } from "./semconv-B6zNvJ73.cjs";
|
|
3
3
|
import { a as AgentInputProvenance, o as AgentMemoryOperation, s as AgentOutputFormat } from "./agent-security-BHdP6ZPG.cjs";
|
|
4
|
-
import { a as GenAiResponseInput, i as GenAiRequestInput, l as GenAiWorkflowInput, s as GenAiToolInput, t as GenAiAgentInput } from "./attributes-
|
|
5
|
-
import { a as GenAiMessagePart, i as GenAiMessage } from "./events-
|
|
4
|
+
import { a as GenAiResponseInput, i as GenAiRequestInput, l as GenAiWorkflowInput, s as GenAiToolInput, t as GenAiAgentInput } from "./attributes-C7k871NW.cjs";
|
|
5
|
+
import { a as GenAiMessagePart, i as GenAiMessage } from "./events-Diz0gxop.cjs";
|
|
6
6
|
import { Context, Link, Span, TimeInput, Tracer } from "@opentelemetry/api";
|
|
7
7
|
//#region src/observer/types.d.ts
|
|
8
8
|
/** Tool identity (name/type/description/call id) without the content fields. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as TokenUsage, i as ModelPricing } from "./cost-C1FkUNG1.js";
|
|
2
|
-
import { m as GenAiProviderName } from "./semconv-
|
|
2
|
+
import { m as GenAiProviderName } from "./semconv-B6zNvJ73.js";
|
|
3
3
|
import { C as recordPlanStep, E as AgentContext, S as recordMemoryAccess, T as tryRecordHumanApproval, _ as recordActionRiskClass, b as recordHumanApproval, g as deriveActionRiskClass, t as AGENT_SECURITY_ATTR, v as recordActiveScopes, w as recordRenderOutput, x as recordInputProvenance, y as recordControllerId } from "./agent-security-BHdP6ZPG.js";
|
|
4
4
|
import { RequestLogger } from "autotel";
|
|
5
5
|
import { OnMissingContext } from "autotel-audit";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as TokenUsage, i as ModelPricing } from "./cost-C1FkUNG1.cjs";
|
|
2
|
-
import { m as GenAiProviderName } from "./semconv-
|
|
2
|
+
import { m as GenAiProviderName } from "./semconv-B6zNvJ73.cjs";
|
|
3
3
|
import { C as recordPlanStep, E as AgentContext, S as recordMemoryAccess, T as tryRecordHumanApproval, _ as recordActionRiskClass, b as recordHumanApproval, g as deriveActionRiskClass, t as AGENT_SECURITY_ATTR, v as recordActiveScopes, w as recordRenderOutput, x as recordInputProvenance, y as recordControllerId } from "./agent-security-BHdP6ZPG.cjs";
|
|
4
4
|
import { RequestLogger } from "autotel";
|
|
5
5
|
import { OnMissingContext } from "autotel-audit";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { a as TokenUsage } from "./cost-C1FkUNG1.js";
|
|
2
|
-
import { m as GenAiProviderName } from "./semconv-
|
|
2
|
+
import { m as GenAiProviderName } from "./semconv-B6zNvJ73.js";
|
|
3
3
|
import { a as AgentInputProvenance, o as AgentMemoryOperation, s as AgentOutputFormat } from "./agent-security-BHdP6ZPG.js";
|
|
4
|
-
import { a as GenAiResponseInput, i as GenAiRequestInput, l as GenAiWorkflowInput, s as GenAiToolInput, t as GenAiAgentInput } from "./attributes-
|
|
5
|
-
import { a as GenAiMessagePart, i as GenAiMessage } from "./events-
|
|
4
|
+
import { a as GenAiResponseInput, i as GenAiRequestInput, l as GenAiWorkflowInput, s as GenAiToolInput, t as GenAiAgentInput } from "./attributes-jUO1pbUc.js";
|
|
5
|
+
import { a as GenAiMessagePart, i as GenAiMessage } from "./events-CXHe4AL7.js";
|
|
6
6
|
import { Context, Link, Span, TimeInput, Tracer } from "@opentelemetry/api";
|
|
7
7
|
//#region src/observer/types.d.ts
|
|
8
8
|
/** Tool identity (name/type/description/call id) without the content fields. */
|
package/dist/index.cjs
CHANGED
|
@@ -80,6 +80,7 @@ exports.recordAgentHandoff = require_agent.recordAgentHandoff;
|
|
|
80
80
|
exports.recordAiSdkCost = require_ai_sdk_bridge.recordAiSdkCost;
|
|
81
81
|
exports.recordDecisionBasis = require_agent.recordDecisionBasis;
|
|
82
82
|
exports.recordEvaluationResult = require_events.recordEvaluationResult;
|
|
83
|
+
exports.recordGenAiMetrics = require_metrics.recordGenAiMetrics;
|
|
83
84
|
exports.recordGenAiResponse = require_trace.recordGenAiResponse;
|
|
84
85
|
exports.recordGenAiUsage = require_trace.recordGenAiUsage;
|
|
85
86
|
exports.recordInferenceDetails = require_events.recordInferenceDetails;
|
|
@@ -88,6 +89,7 @@ exports.recordModelWarnings = require_events.recordModelWarnings;
|
|
|
88
89
|
exports.recordOperationException = require_events.recordOperationException;
|
|
89
90
|
exports.recordPolicyDecision = require_agent.recordPolicyDecision;
|
|
90
91
|
exports.recordStreamTiming = require_streaming.recordStreamTiming;
|
|
92
|
+
exports.resetGenAiInstruments = require_metrics.resetGenAiInstruments;
|
|
91
93
|
exports.resolvePrivacyProfile = require_agent.resolvePrivacyProfile;
|
|
92
94
|
exports.sanitizeAuditPayload = require_agent.sanitizeAuditPayload;
|
|
93
95
|
exports.setAgentAttributes = require_agent.setAgentAttributes;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { $ as AgentToolCallOptions, A as delegateToAgent, B as AgentDecisionMetadata, C as defineAgentToolCall, D as withAgentToolCall, E as withAgentAction, F as AgentActionFactory, G as AgentIdentityRegistry, H as AgentHandler, I as AgentActionMetadata, J as AgentOutcome, K as AgentIdentityStatus, L as AgentActionOptions, M as flattenAgentAttributes, N as setAgentAttributes, O as DelegateToAgentInput, P as createAgentAuditMetadata, Q as AgentToolCallActionMetadata, R as AgentAiMetadata, S as defineAgentAction, T as recordPolicyDecision, U as AgentIdentity, V as AgentEventKind, W as AgentIdentityRecord, X as AgentSessionMetadata, Y as AgentSessionActionMetadata, Z as AgentSessionStatus, _ as ProvisionAgentIdentityInput, at as PrivacyProfile, b as createAgentIdentityRegistry, ct as ToolCallMetadata, d as CreateSignedEventEnvelopeOptions, dt as canonicalizeForHash, et as AiLifecycleStage, f as createSignedEventEnvelope, ft as hashPayload, g as sanitizeAuditPayload, h as resolvePrivacyProfile, it as PolicyMetadata, j as recordAgentHandoff, k as RecordAgentHandoffMetadata, lt as ToolStatus, m as PrivacyProfileInput, nt as GovernanceMetadata, ot as PrivacyProfileName, p as verifyEventEnvelopeHash, pt as AGENT_AUDIT_SCHEMA_VERSION, q as AgentMetadataInput, rt as PolicyDecision, st as ScopedToolDefinition, tt as DelegationContext, u as withScopedTool, ut as HashPayloadOptions, v as RevokeAgentIdentityInput, w as recordDecisionBasis, x as withAgentSession, y as RotateAgentIdentityInput, z as AgentAuditEventEnvelope } from "./index-
|
|
1
|
+
import { $ as AgentToolCallOptions, A as delegateToAgent, B as AgentDecisionMetadata, C as defineAgentToolCall, D as withAgentToolCall, E as withAgentAction, F as AgentActionFactory, G as AgentIdentityRegistry, H as AgentHandler, I as AgentActionMetadata, J as AgentOutcome, K as AgentIdentityStatus, L as AgentActionOptions, M as flattenAgentAttributes, N as setAgentAttributes, O as DelegateToAgentInput, P as createAgentAuditMetadata, Q as AgentToolCallActionMetadata, R as AgentAiMetadata, S as defineAgentAction, T as recordPolicyDecision, U as AgentIdentity, V as AgentEventKind, W as AgentIdentityRecord, X as AgentSessionMetadata, Y as AgentSessionActionMetadata, Z as AgentSessionStatus, _ as ProvisionAgentIdentityInput, at as PrivacyProfile, b as createAgentIdentityRegistry, ct as ToolCallMetadata, d as CreateSignedEventEnvelopeOptions, dt as canonicalizeForHash, et as AiLifecycleStage, f as createSignedEventEnvelope, ft as hashPayload, g as sanitizeAuditPayload, h as resolvePrivacyProfile, it as PolicyMetadata, j as recordAgentHandoff, k as RecordAgentHandoffMetadata, lt as ToolStatus, m as PrivacyProfileInput, nt as GovernanceMetadata, ot as PrivacyProfileName, p as verifyEventEnvelopeHash, pt as AGENT_AUDIT_SCHEMA_VERSION, q as AgentMetadataInput, rt as PolicyDecision, st as ScopedToolDefinition, tt as DelegationContext, u as withScopedTool, ut as HashPayloadOptions, v as RevokeAgentIdentityInput, w as recordDecisionBasis, x as withAgentSession, y as RotateAgentIdentityInput, z as AgentAuditEventEnvelope } from "./index-Dc450L-d.cjs";
|
|
2
2
|
import { a as TokenUsage, i as ModelPricing, n as GEN_AI_COST_ATTRIBUTE, o as estimateLLMCost, r as MODEL_PRICING, s as recordLLMCost, t as EstimateCostOptions } from "./cost-C1FkUNG1.cjs";
|
|
3
|
-
import { _ as genAiSpanName, a as GEN_AI_METRIC, c as GEN_AI_PROVIDER, d as GenAiAttributeKey, f as GenAiOperationName, g as GenAiToolType, h as GenAiTokenType, i as GEN_AI_GUARD_EVENT, l as GEN_AI_TOKEN_TYPE, m as GenAiProviderName, n as GEN_AI_EVENT, o as GEN_AI_OPERATION, p as GenAiOutputType, r as GEN_AI_EXT_EVENT, s as GEN_AI_OUTPUT_TYPE, t as GEN_AI, u as GEN_AI_TOOL_TYPE } from "./semconv-
|
|
3
|
+
import { _ as genAiSpanName, a as GEN_AI_METRIC, c as GEN_AI_PROVIDER, d as GenAiAttributeKey, f as GenAiOperationName, g as GenAiToolType, h as GenAiTokenType, i as GEN_AI_GUARD_EVENT, l as GEN_AI_TOKEN_TYPE, m as GenAiProviderName, n as GEN_AI_EVENT, o as GEN_AI_OPERATION, p as GenAiOutputType, r as GEN_AI_EXT_EVENT, s as GEN_AI_OUTPUT_TYPE, t as GEN_AI, u as GEN_AI_TOOL_TYPE } from "./semconv-B6zNvJ73.cjs";
|
|
4
4
|
import { E as AgentContext } from "./agent-security-BHdP6ZPG.cjs";
|
|
5
|
-
import { _ as genAiWorkflowAttributes, a as GenAiResponseInput, c as GenAiUsageInput, d as genAiMemoryAttributes, f as genAiRequestAttributes, g as genAiUsageAttributes, h as genAiToolAttributes, i as GenAiRequestInput, l as GenAiWorkflowInput, m as genAiRetrievalAttributes, n as GenAiAttributeMap, o as GenAiRetrievalInput, p as genAiResponseAttributes, r as GenAiMemoryInput, s as GenAiToolInput, t as GenAiAgentInput, u as genAiAgentAttributes } from "./attributes-
|
|
5
|
+
import { _ as genAiWorkflowAttributes, a as GenAiResponseInput, c as GenAiUsageInput, d as genAiMemoryAttributes, f as genAiRequestAttributes, g as genAiUsageAttributes, h as genAiToolAttributes, i as GenAiRequestInput, l as GenAiWorkflowInput, m as genAiRetrievalAttributes, n as GenAiAttributeMap, o as GenAiRetrievalInput, p as genAiResponseAttributes, r as GenAiMemoryInput, s as GenAiToolInput, t as GenAiAgentInput, u as genAiAgentAttributes } from "./attributes-C7k871NW.cjs";
|
|
6
6
|
import { AI_SDK_ATTR, AUTOTEL_ENRICHED_ATTR, AiSdkEnrichContext, AiSdkSpanType, AutotelEnrichOptions, autotelEnrich, estimateAiSdkCost, extractAiSdkModel, extractAiSdkUsage, mapAiSdkAttributes, normalizeAiSdkProvider, recordAiSdkCost } from "./ai-sdk-bridge.cjs";
|
|
7
|
-
import { a as GenAiMessagePart, c as InferenceDetailsEvent, d as recordModelWarnings, f as recordOperationException, i as GenAiMessage, l as recordEvaluationResult, n as EvaluationResultEvent, o as GenAiOperationExceptionEvent, p as setGenAiContent, r as GenAiContentSink, s as GenAiWarning, t as ContentCaptureSettings, u as recordInferenceDetails } from "./events-
|
|
7
|
+
import { a as GenAiMessagePart, c as InferenceDetailsEvent, d as recordModelWarnings, f as recordOperationException, i as GenAiMessage, l as recordEvaluationResult, n as EvaluationResultEvent, o as GenAiOperationExceptionEvent, p as setGenAiContent, r as GenAiContentSink, s as GenAiWarning, t as ContentCaptureSettings, u as recordInferenceDetails } from "./events-Diz0gxop.cjs";
|
|
8
8
|
import { CONTEXT_LIMITS, GenAiBudgetOptions, GenAiGuard, GenAiGuardOptions, GenAiGuardRule, GenAiGuardStep, GuardAction, GuardSink, GuardState, GuardStopBehavior, GuardUsage, GuardViolation, contextBudget, costCeiling, createGenAiBudget, createGenAiGuard, errorLoop, maxDuration, maxSteps, maxToolCalls, parseGuardRules, spinLoop, tokenCeiling } from "./guard.cjs";
|
|
9
|
-
import { GEN_AI_COST_USD_BUCKETS, GEN_AI_DURATION_BUCKETS_SECONDS, GEN_AI_TOKEN_USAGE_BUCKETS, GenAiHistogramKind, genAiMetricViews, llmHistogramAdvice } from "./metrics.cjs";
|
|
9
|
+
import { GEN_AI_COST_USD_BUCKETS, GEN_AI_DURATION_BUCKETS_SECONDS, GEN_AI_TOKEN_USAGE_BUCKETS, GenAiHistogramKind, GenAiMetricInput, genAiMetricViews, llmHistogramAdvice, recordGenAiMetrics, resetGenAiInstruments } from "./metrics.cjs";
|
|
10
10
|
import { ChunkIntervalStats, ComputeStreamTimingInput, StreamTimer, StreamTiming, chunkIntervalStats, computeStreamTiming, createStreamTimer, recordStreamTiming } from "./streaming.cjs";
|
|
11
11
|
import { TraceGenAIConfig, recordGenAiResponse, recordGenAiUsage, traceGenAI, traceLLM } from "./trace.cjs";
|
|
12
|
-
import { A as SpanEnd, C as ChatEndEvent, D as GenAiObserverEvent, E as GenAiObserver, F as WorkflowStartEvent, M as ToolEndEvent, N as ToolStartEvent, O as GenAiObserverOptions, P as WorkflowEndEvent, S as AgentStartEvent, T as ChatStreamTiming, _ as ObserveAiSdkOptions, a as subscribeAiTelemetry, b as createGenAiObserver, c as autotelTelemetry, d as promptToGenAiMessages, f as AiSdkResult, g as AiSdkUsage, h as AiSdkToolResult, i as SubscribeAiTelemetryOptions, j as SpanStart, k as GenAiToolIdentity, l as ConvertedPrompt, m as AiSdkToolCall, n as LangChainObserverOptions, o as AutotelTelemetryIntegration, p as AiSdkStep, r as createLangChainObserver, s as AutotelTelemetryOptions, t as LangChainObserverHandler, u as contentToGenAiMessage, v as observeAiSdkResult, w as ChatStartEvent, x as AgentEndEvent, y as SpanRegistry } from "./index-
|
|
13
|
-
export { AGENT_AUDIT_SCHEMA_VERSION, AI_SDK_ATTR, AUTOTEL_ENRICHED_ATTR, type AgentActionFactory, type AgentActionMetadata, type AgentActionOptions, type AgentAiMetadata, type AgentAuditEventEnvelope, type AgentContext, type AgentDecisionMetadata, type AgentEndEvent, type AgentEventKind, type AgentHandler, type AgentIdentity, type AgentIdentityRecord, type AgentIdentityRegistry, type AgentIdentityStatus, type AgentMetadataInput, type AgentOutcome, type AgentSessionActionMetadata, type AgentSessionMetadata, type AgentSessionStatus, type AgentStartEvent, type AgentToolCallActionMetadata, type AgentToolCallOptions, type AiLifecycleStage, type AiSdkEnrichContext, type AiSdkResult, type AiSdkSpanType, type AiSdkStep, type AiSdkToolCall, type AiSdkToolResult, type AiSdkUsage, type AutotelEnrichOptions, type AutotelTelemetryIntegration, type AutotelTelemetryOptions, CONTEXT_LIMITS, type ChatEndEvent, type ChatStartEvent, type ChatStreamTiming, type ChunkIntervalStats, type ComputeStreamTimingInput, type ContentCaptureSettings, type ConvertedPrompt, type CreateSignedEventEnvelopeOptions, type DelegateToAgentInput, type DelegationContext, type EstimateCostOptions, type EvaluationResultEvent, GEN_AI, GEN_AI_COST_ATTRIBUTE, GEN_AI_COST_USD_BUCKETS, GEN_AI_DURATION_BUCKETS_SECONDS, GEN_AI_EVENT, GEN_AI_EXT_EVENT, GEN_AI_GUARD_EVENT, GEN_AI_METRIC, GEN_AI_OPERATION, GEN_AI_OUTPUT_TYPE, GEN_AI_PROVIDER, GEN_AI_TOKEN_TYPE, GEN_AI_TOKEN_USAGE_BUCKETS, GEN_AI_TOOL_TYPE, type GenAiAgentInput, type GenAiAttributeKey, type GenAiAttributeMap, type GenAiBudgetOptions, type GenAiContentSink, type GenAiGuard, type GenAiGuardOptions, type GenAiGuardRule, type GenAiGuardStep, type GenAiHistogramKind, type GenAiMemoryInput, type GenAiMessage, type GenAiMessagePart, type GenAiObserver, type GenAiObserverEvent, type GenAiObserverOptions, type GenAiOperationExceptionEvent, type GenAiOperationName, type GenAiOutputType, type GenAiProviderName, type GenAiRequestInput, type GenAiResponseInput, type GenAiRetrievalInput, type GenAiTokenType, type GenAiToolIdentity, type GenAiToolInput, type GenAiToolType, type GenAiUsageInput, type GenAiWarning, type GenAiWorkflowInput, type GovernanceMetadata, type GuardAction, type GuardSink, type GuardState, type GuardStopBehavior, type GuardUsage, type GuardViolation, type HashPayloadOptions, type InferenceDetailsEvent, type LangChainObserverHandler, type LangChainObserverOptions, MODEL_PRICING, type ModelPricing, type ObserveAiSdkOptions, type PolicyDecision, type PolicyMetadata, type PrivacyProfile, type PrivacyProfileInput, type PrivacyProfileName, type ProvisionAgentIdentityInput, type RecordAgentHandoffMetadata, type RevokeAgentIdentityInput, type RotateAgentIdentityInput, type ScopedToolDefinition, type SpanEnd, SpanRegistry, type SpanStart, type StreamTimer, type StreamTiming, type SubscribeAiTelemetryOptions, type TokenUsage, type ToolCallMetadata, type ToolEndEvent, type ToolStartEvent, type ToolStatus, type TraceGenAIConfig, type WorkflowEndEvent, type WorkflowStartEvent, autotelEnrich, autotelTelemetry, canonicalizeForHash, chunkIntervalStats, computeStreamTiming, contentToGenAiMessage, contextBudget, costCeiling, createAgentAuditMetadata, createAgentIdentityRegistry, createGenAiBudget, createGenAiGuard, createGenAiObserver, createLangChainObserver, createSignedEventEnvelope, createStreamTimer, defineAgentAction, defineAgentToolCall, delegateToAgent, errorLoop, estimateAiSdkCost, estimateLLMCost, extractAiSdkModel, extractAiSdkUsage, flattenAgentAttributes, genAiAgentAttributes, genAiMemoryAttributes, genAiMetricViews, genAiRequestAttributes, genAiResponseAttributes, genAiRetrievalAttributes, genAiSpanName, genAiToolAttributes, genAiUsageAttributes, genAiWorkflowAttributes, hashPayload, llmHistogramAdvice, mapAiSdkAttributes, maxDuration, maxSteps, maxToolCalls, normalizeAiSdkProvider, observeAiSdkResult, parseGuardRules, promptToGenAiMessages, recordAgentHandoff, recordAiSdkCost, recordDecisionBasis, recordEvaluationResult, recordGenAiResponse, recordGenAiUsage, recordInferenceDetails, recordLLMCost, recordModelWarnings, recordOperationException, recordPolicyDecision, recordStreamTiming, resolvePrivacyProfile, sanitizeAuditPayload, setAgentAttributes, setGenAiContent, spinLoop, subscribeAiTelemetry, tokenCeiling, traceGenAI, traceLLM, verifyEventEnvelopeHash, withAgentAction, withAgentSession, withAgentToolCall, withScopedTool };
|
|
12
|
+
import { A as SpanEnd, C as ChatEndEvent, D as GenAiObserverEvent, E as GenAiObserver, F as WorkflowStartEvent, M as ToolEndEvent, N as ToolStartEvent, O as GenAiObserverOptions, P as WorkflowEndEvent, S as AgentStartEvent, T as ChatStreamTiming, _ as ObserveAiSdkOptions, a as subscribeAiTelemetry, b as createGenAiObserver, c as autotelTelemetry, d as promptToGenAiMessages, f as AiSdkResult, g as AiSdkUsage, h as AiSdkToolResult, i as SubscribeAiTelemetryOptions, j as SpanStart, k as GenAiToolIdentity, l as ConvertedPrompt, m as AiSdkToolCall, n as LangChainObserverOptions, o as AutotelTelemetryIntegration, p as AiSdkStep, r as createLangChainObserver, s as AutotelTelemetryOptions, t as LangChainObserverHandler, u as contentToGenAiMessage, v as observeAiSdkResult, w as ChatStartEvent, x as AgentEndEvent, y as SpanRegistry } from "./index-Bgt8apSM.cjs";
|
|
13
|
+
export { AGENT_AUDIT_SCHEMA_VERSION, AI_SDK_ATTR, AUTOTEL_ENRICHED_ATTR, type AgentActionFactory, type AgentActionMetadata, type AgentActionOptions, type AgentAiMetadata, type AgentAuditEventEnvelope, type AgentContext, type AgentDecisionMetadata, type AgentEndEvent, type AgentEventKind, type AgentHandler, type AgentIdentity, type AgentIdentityRecord, type AgentIdentityRegistry, type AgentIdentityStatus, type AgentMetadataInput, type AgentOutcome, type AgentSessionActionMetadata, type AgentSessionMetadata, type AgentSessionStatus, type AgentStartEvent, type AgentToolCallActionMetadata, type AgentToolCallOptions, type AiLifecycleStage, type AiSdkEnrichContext, type AiSdkResult, type AiSdkSpanType, type AiSdkStep, type AiSdkToolCall, type AiSdkToolResult, type AiSdkUsage, type AutotelEnrichOptions, type AutotelTelemetryIntegration, type AutotelTelemetryOptions, CONTEXT_LIMITS, type ChatEndEvent, type ChatStartEvent, type ChatStreamTiming, type ChunkIntervalStats, type ComputeStreamTimingInput, type ContentCaptureSettings, type ConvertedPrompt, type CreateSignedEventEnvelopeOptions, type DelegateToAgentInput, type DelegationContext, type EstimateCostOptions, type EvaluationResultEvent, GEN_AI, GEN_AI_COST_ATTRIBUTE, GEN_AI_COST_USD_BUCKETS, GEN_AI_DURATION_BUCKETS_SECONDS, GEN_AI_EVENT, GEN_AI_EXT_EVENT, GEN_AI_GUARD_EVENT, GEN_AI_METRIC, GEN_AI_OPERATION, GEN_AI_OUTPUT_TYPE, GEN_AI_PROVIDER, GEN_AI_TOKEN_TYPE, GEN_AI_TOKEN_USAGE_BUCKETS, GEN_AI_TOOL_TYPE, type GenAiAgentInput, type GenAiAttributeKey, type GenAiAttributeMap, type GenAiBudgetOptions, type GenAiContentSink, type GenAiGuard, type GenAiGuardOptions, type GenAiGuardRule, type GenAiGuardStep, type GenAiHistogramKind, type GenAiMemoryInput, type GenAiMessage, type GenAiMessagePart, type GenAiMetricInput, type GenAiObserver, type GenAiObserverEvent, type GenAiObserverOptions, type GenAiOperationExceptionEvent, type GenAiOperationName, type GenAiOutputType, type GenAiProviderName, type GenAiRequestInput, type GenAiResponseInput, type GenAiRetrievalInput, type GenAiTokenType, type GenAiToolIdentity, type GenAiToolInput, type GenAiToolType, type GenAiUsageInput, type GenAiWarning, type GenAiWorkflowInput, type GovernanceMetadata, type GuardAction, type GuardSink, type GuardState, type GuardStopBehavior, type GuardUsage, type GuardViolation, type HashPayloadOptions, type InferenceDetailsEvent, type LangChainObserverHandler, type LangChainObserverOptions, MODEL_PRICING, type ModelPricing, type ObserveAiSdkOptions, type PolicyDecision, type PolicyMetadata, type PrivacyProfile, type PrivacyProfileInput, type PrivacyProfileName, type ProvisionAgentIdentityInput, type RecordAgentHandoffMetadata, type RevokeAgentIdentityInput, type RotateAgentIdentityInput, type ScopedToolDefinition, type SpanEnd, SpanRegistry, type SpanStart, type StreamTimer, type StreamTiming, type SubscribeAiTelemetryOptions, type TokenUsage, type ToolCallMetadata, type ToolEndEvent, type ToolStartEvent, type ToolStatus, type TraceGenAIConfig, type WorkflowEndEvent, type WorkflowStartEvent, autotelEnrich, autotelTelemetry, canonicalizeForHash, chunkIntervalStats, computeStreamTiming, contentToGenAiMessage, contextBudget, costCeiling, createAgentAuditMetadata, createAgentIdentityRegistry, createGenAiBudget, createGenAiGuard, createGenAiObserver, createLangChainObserver, createSignedEventEnvelope, createStreamTimer, defineAgentAction, defineAgentToolCall, delegateToAgent, errorLoop, estimateAiSdkCost, estimateLLMCost, extractAiSdkModel, extractAiSdkUsage, flattenAgentAttributes, genAiAgentAttributes, genAiMemoryAttributes, genAiMetricViews, genAiRequestAttributes, genAiResponseAttributes, genAiRetrievalAttributes, genAiSpanName, genAiToolAttributes, genAiUsageAttributes, genAiWorkflowAttributes, hashPayload, llmHistogramAdvice, mapAiSdkAttributes, maxDuration, maxSteps, maxToolCalls, normalizeAiSdkProvider, observeAiSdkResult, parseGuardRules, promptToGenAiMessages, recordAgentHandoff, recordAiSdkCost, recordDecisionBasis, recordEvaluationResult, recordGenAiMetrics, recordGenAiResponse, recordGenAiUsage, recordInferenceDetails, recordLLMCost, recordModelWarnings, recordOperationException, recordPolicyDecision, recordStreamTiming, resetGenAiInstruments, resolvePrivacyProfile, sanitizeAuditPayload, setAgentAttributes, setGenAiContent, spinLoop, subscribeAiTelemetry, tokenCeiling, traceGenAI, traceLLM, verifyEventEnvelopeHash, withAgentAction, withAgentSession, withAgentToolCall, withScopedTool };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { $ as AgentToolCallOptions, A as delegateToAgent, B as AgentDecisionMetadata, C as defineAgentToolCall, D as withAgentToolCall, E as withAgentAction, F as AgentActionFactory, G as AgentIdentityRegistry, H as AgentHandler, I as AgentActionMetadata, J as AgentOutcome, K as AgentIdentityStatus, L as AgentActionOptions, M as flattenAgentAttributes, N as setAgentAttributes, O as DelegateToAgentInput, P as createAgentAuditMetadata, Q as AgentToolCallActionMetadata, R as AgentAiMetadata, S as defineAgentAction, T as recordPolicyDecision, U as AgentIdentity, V as AgentEventKind, W as AgentIdentityRecord, X as AgentSessionMetadata, Y as AgentSessionActionMetadata, Z as AgentSessionStatus, _ as ProvisionAgentIdentityInput, at as PrivacyProfile, b as createAgentIdentityRegistry, ct as ToolCallMetadata, d as CreateSignedEventEnvelopeOptions, dt as canonicalizeForHash, et as AiLifecycleStage, f as createSignedEventEnvelope, ft as hashPayload, g as sanitizeAuditPayload, h as resolvePrivacyProfile, it as PolicyMetadata, j as recordAgentHandoff, k as RecordAgentHandoffMetadata, lt as ToolStatus, m as PrivacyProfileInput, nt as GovernanceMetadata, ot as PrivacyProfileName, p as verifyEventEnvelopeHash, pt as AGENT_AUDIT_SCHEMA_VERSION, q as AgentMetadataInput, rt as PolicyDecision, st as ScopedToolDefinition, tt as DelegationContext, u as withScopedTool, ut as HashPayloadOptions, v as RevokeAgentIdentityInput, w as recordDecisionBasis, x as withAgentSession, y as RotateAgentIdentityInput, z as AgentAuditEventEnvelope } from "./index-
|
|
1
|
+
import { $ as AgentToolCallOptions, A as delegateToAgent, B as AgentDecisionMetadata, C as defineAgentToolCall, D as withAgentToolCall, E as withAgentAction, F as AgentActionFactory, G as AgentIdentityRegistry, H as AgentHandler, I as AgentActionMetadata, J as AgentOutcome, K as AgentIdentityStatus, L as AgentActionOptions, M as flattenAgentAttributes, N as setAgentAttributes, O as DelegateToAgentInput, P as createAgentAuditMetadata, Q as AgentToolCallActionMetadata, R as AgentAiMetadata, S as defineAgentAction, T as recordPolicyDecision, U as AgentIdentity, V as AgentEventKind, W as AgentIdentityRecord, X as AgentSessionMetadata, Y as AgentSessionActionMetadata, Z as AgentSessionStatus, _ as ProvisionAgentIdentityInput, at as PrivacyProfile, b as createAgentIdentityRegistry, ct as ToolCallMetadata, d as CreateSignedEventEnvelopeOptions, dt as canonicalizeForHash, et as AiLifecycleStage, f as createSignedEventEnvelope, ft as hashPayload, g as sanitizeAuditPayload, h as resolvePrivacyProfile, it as PolicyMetadata, j as recordAgentHandoff, k as RecordAgentHandoffMetadata, lt as ToolStatus, m as PrivacyProfileInput, nt as GovernanceMetadata, ot as PrivacyProfileName, p as verifyEventEnvelopeHash, pt as AGENT_AUDIT_SCHEMA_VERSION, q as AgentMetadataInput, rt as PolicyDecision, st as ScopedToolDefinition, tt as DelegationContext, u as withScopedTool, ut as HashPayloadOptions, v as RevokeAgentIdentityInput, w as recordDecisionBasis, x as withAgentSession, y as RotateAgentIdentityInput, z as AgentAuditEventEnvelope } from "./index-D010Y_xS.js";
|
|
2
2
|
import { a as TokenUsage, i as ModelPricing, n as GEN_AI_COST_ATTRIBUTE, o as estimateLLMCost, r as MODEL_PRICING, s as recordLLMCost, t as EstimateCostOptions } from "./cost-C1FkUNG1.js";
|
|
3
|
-
import { _ as genAiSpanName, a as GEN_AI_METRIC, c as GEN_AI_PROVIDER, d as GenAiAttributeKey, f as GenAiOperationName, g as GenAiToolType, h as GenAiTokenType, i as GEN_AI_GUARD_EVENT, l as GEN_AI_TOKEN_TYPE, m as GenAiProviderName, n as GEN_AI_EVENT, o as GEN_AI_OPERATION, p as GenAiOutputType, r as GEN_AI_EXT_EVENT, s as GEN_AI_OUTPUT_TYPE, t as GEN_AI, u as GEN_AI_TOOL_TYPE } from "./semconv-
|
|
3
|
+
import { _ as genAiSpanName, a as GEN_AI_METRIC, c as GEN_AI_PROVIDER, d as GenAiAttributeKey, f as GenAiOperationName, g as GenAiToolType, h as GenAiTokenType, i as GEN_AI_GUARD_EVENT, l as GEN_AI_TOKEN_TYPE, m as GenAiProviderName, n as GEN_AI_EVENT, o as GEN_AI_OPERATION, p as GenAiOutputType, r as GEN_AI_EXT_EVENT, s as GEN_AI_OUTPUT_TYPE, t as GEN_AI, u as GEN_AI_TOOL_TYPE } from "./semconv-B6zNvJ73.js";
|
|
4
4
|
import { E as AgentContext } from "./agent-security-BHdP6ZPG.js";
|
|
5
|
-
import { _ as genAiWorkflowAttributes, a as GenAiResponseInput, c as GenAiUsageInput, d as genAiMemoryAttributes, f as genAiRequestAttributes, g as genAiUsageAttributes, h as genAiToolAttributes, i as GenAiRequestInput, l as GenAiWorkflowInput, m as genAiRetrievalAttributes, n as GenAiAttributeMap, o as GenAiRetrievalInput, p as genAiResponseAttributes, r as GenAiMemoryInput, s as GenAiToolInput, t as GenAiAgentInput, u as genAiAgentAttributes } from "./attributes-
|
|
5
|
+
import { _ as genAiWorkflowAttributes, a as GenAiResponseInput, c as GenAiUsageInput, d as genAiMemoryAttributes, f as genAiRequestAttributes, g as genAiUsageAttributes, h as genAiToolAttributes, i as GenAiRequestInput, l as GenAiWorkflowInput, m as genAiRetrievalAttributes, n as GenAiAttributeMap, o as GenAiRetrievalInput, p as genAiResponseAttributes, r as GenAiMemoryInput, s as GenAiToolInput, t as GenAiAgentInput, u as genAiAgentAttributes } from "./attributes-jUO1pbUc.js";
|
|
6
6
|
import { AI_SDK_ATTR, AUTOTEL_ENRICHED_ATTR, AiSdkEnrichContext, AiSdkSpanType, AutotelEnrichOptions, autotelEnrich, estimateAiSdkCost, extractAiSdkModel, extractAiSdkUsage, mapAiSdkAttributes, normalizeAiSdkProvider, recordAiSdkCost } from "./ai-sdk-bridge.js";
|
|
7
|
-
import { a as GenAiMessagePart, c as InferenceDetailsEvent, d as recordModelWarnings, f as recordOperationException, i as GenAiMessage, l as recordEvaluationResult, n as EvaluationResultEvent, o as GenAiOperationExceptionEvent, p as setGenAiContent, r as GenAiContentSink, s as GenAiWarning, t as ContentCaptureSettings, u as recordInferenceDetails } from "./events-
|
|
7
|
+
import { a as GenAiMessagePart, c as InferenceDetailsEvent, d as recordModelWarnings, f as recordOperationException, i as GenAiMessage, l as recordEvaluationResult, n as EvaluationResultEvent, o as GenAiOperationExceptionEvent, p as setGenAiContent, r as GenAiContentSink, s as GenAiWarning, t as ContentCaptureSettings, u as recordInferenceDetails } from "./events-CXHe4AL7.js";
|
|
8
8
|
import { CONTEXT_LIMITS, GenAiBudgetOptions, GenAiGuard, GenAiGuardOptions, GenAiGuardRule, GenAiGuardStep, GuardAction, GuardSink, GuardState, GuardStopBehavior, GuardUsage, GuardViolation, contextBudget, costCeiling, createGenAiBudget, createGenAiGuard, errorLoop, maxDuration, maxSteps, maxToolCalls, parseGuardRules, spinLoop, tokenCeiling } from "./guard.js";
|
|
9
|
-
import { GEN_AI_COST_USD_BUCKETS, GEN_AI_DURATION_BUCKETS_SECONDS, GEN_AI_TOKEN_USAGE_BUCKETS, GenAiHistogramKind, genAiMetricViews, llmHistogramAdvice } from "./metrics.js";
|
|
9
|
+
import { GEN_AI_COST_USD_BUCKETS, GEN_AI_DURATION_BUCKETS_SECONDS, GEN_AI_TOKEN_USAGE_BUCKETS, GenAiHistogramKind, GenAiMetricInput, genAiMetricViews, llmHistogramAdvice, recordGenAiMetrics, resetGenAiInstruments } from "./metrics.js";
|
|
10
10
|
import { ChunkIntervalStats, ComputeStreamTimingInput, StreamTimer, StreamTiming, chunkIntervalStats, computeStreamTiming, createStreamTimer, recordStreamTiming } from "./streaming.js";
|
|
11
11
|
import { TraceGenAIConfig, recordGenAiResponse, recordGenAiUsage, traceGenAI, traceLLM } from "./trace.js";
|
|
12
|
-
import { A as SpanEnd, C as ChatEndEvent, D as GenAiObserverEvent, E as GenAiObserver, F as WorkflowStartEvent, M as ToolEndEvent, N as ToolStartEvent, O as GenAiObserverOptions, P as WorkflowEndEvent, S as AgentStartEvent, T as ChatStreamTiming, _ as ObserveAiSdkOptions, a as subscribeAiTelemetry, b as createGenAiObserver, c as autotelTelemetry, d as promptToGenAiMessages, f as AiSdkResult, g as AiSdkUsage, h as AiSdkToolResult, i as SubscribeAiTelemetryOptions, j as SpanStart, k as GenAiToolIdentity, l as ConvertedPrompt, m as AiSdkToolCall, n as LangChainObserverOptions, o as AutotelTelemetryIntegration, p as AiSdkStep, r as createLangChainObserver, s as AutotelTelemetryOptions, t as LangChainObserverHandler, u as contentToGenAiMessage, v as observeAiSdkResult, w as ChatStartEvent, x as AgentEndEvent, y as SpanRegistry } from "./index-
|
|
13
|
-
export { AGENT_AUDIT_SCHEMA_VERSION, AI_SDK_ATTR, AUTOTEL_ENRICHED_ATTR, type AgentActionFactory, type AgentActionMetadata, type AgentActionOptions, type AgentAiMetadata, type AgentAuditEventEnvelope, type AgentContext, type AgentDecisionMetadata, type AgentEndEvent, type AgentEventKind, type AgentHandler, type AgentIdentity, type AgentIdentityRecord, type AgentIdentityRegistry, type AgentIdentityStatus, type AgentMetadataInput, type AgentOutcome, type AgentSessionActionMetadata, type AgentSessionMetadata, type AgentSessionStatus, type AgentStartEvent, type AgentToolCallActionMetadata, type AgentToolCallOptions, type AiLifecycleStage, type AiSdkEnrichContext, type AiSdkResult, type AiSdkSpanType, type AiSdkStep, type AiSdkToolCall, type AiSdkToolResult, type AiSdkUsage, type AutotelEnrichOptions, type AutotelTelemetryIntegration, type AutotelTelemetryOptions, CONTEXT_LIMITS, type ChatEndEvent, type ChatStartEvent, type ChatStreamTiming, type ChunkIntervalStats, type ComputeStreamTimingInput, type ContentCaptureSettings, type ConvertedPrompt, type CreateSignedEventEnvelopeOptions, type DelegateToAgentInput, type DelegationContext, type EstimateCostOptions, type EvaluationResultEvent, GEN_AI, GEN_AI_COST_ATTRIBUTE, GEN_AI_COST_USD_BUCKETS, GEN_AI_DURATION_BUCKETS_SECONDS, GEN_AI_EVENT, GEN_AI_EXT_EVENT, GEN_AI_GUARD_EVENT, GEN_AI_METRIC, GEN_AI_OPERATION, GEN_AI_OUTPUT_TYPE, GEN_AI_PROVIDER, GEN_AI_TOKEN_TYPE, GEN_AI_TOKEN_USAGE_BUCKETS, GEN_AI_TOOL_TYPE, type GenAiAgentInput, type GenAiAttributeKey, type GenAiAttributeMap, type GenAiBudgetOptions, type GenAiContentSink, type GenAiGuard, type GenAiGuardOptions, type GenAiGuardRule, type GenAiGuardStep, type GenAiHistogramKind, type GenAiMemoryInput, type GenAiMessage, type GenAiMessagePart, type GenAiObserver, type GenAiObserverEvent, type GenAiObserverOptions, type GenAiOperationExceptionEvent, type GenAiOperationName, type GenAiOutputType, type GenAiProviderName, type GenAiRequestInput, type GenAiResponseInput, type GenAiRetrievalInput, type GenAiTokenType, type GenAiToolIdentity, type GenAiToolInput, type GenAiToolType, type GenAiUsageInput, type GenAiWarning, type GenAiWorkflowInput, type GovernanceMetadata, type GuardAction, type GuardSink, type GuardState, type GuardStopBehavior, type GuardUsage, type GuardViolation, type HashPayloadOptions, type InferenceDetailsEvent, type LangChainObserverHandler, type LangChainObserverOptions, MODEL_PRICING, type ModelPricing, type ObserveAiSdkOptions, type PolicyDecision, type PolicyMetadata, type PrivacyProfile, type PrivacyProfileInput, type PrivacyProfileName, type ProvisionAgentIdentityInput, type RecordAgentHandoffMetadata, type RevokeAgentIdentityInput, type RotateAgentIdentityInput, type ScopedToolDefinition, type SpanEnd, SpanRegistry, type SpanStart, type StreamTimer, type StreamTiming, type SubscribeAiTelemetryOptions, type TokenUsage, type ToolCallMetadata, type ToolEndEvent, type ToolStartEvent, type ToolStatus, type TraceGenAIConfig, type WorkflowEndEvent, type WorkflowStartEvent, autotelEnrich, autotelTelemetry, canonicalizeForHash, chunkIntervalStats, computeStreamTiming, contentToGenAiMessage, contextBudget, costCeiling, createAgentAuditMetadata, createAgentIdentityRegistry, createGenAiBudget, createGenAiGuard, createGenAiObserver, createLangChainObserver, createSignedEventEnvelope, createStreamTimer, defineAgentAction, defineAgentToolCall, delegateToAgent, errorLoop, estimateAiSdkCost, estimateLLMCost, extractAiSdkModel, extractAiSdkUsage, flattenAgentAttributes, genAiAgentAttributes, genAiMemoryAttributes, genAiMetricViews, genAiRequestAttributes, genAiResponseAttributes, genAiRetrievalAttributes, genAiSpanName, genAiToolAttributes, genAiUsageAttributes, genAiWorkflowAttributes, hashPayload, llmHistogramAdvice, mapAiSdkAttributes, maxDuration, maxSteps, maxToolCalls, normalizeAiSdkProvider, observeAiSdkResult, parseGuardRules, promptToGenAiMessages, recordAgentHandoff, recordAiSdkCost, recordDecisionBasis, recordEvaluationResult, recordGenAiResponse, recordGenAiUsage, recordInferenceDetails, recordLLMCost, recordModelWarnings, recordOperationException, recordPolicyDecision, recordStreamTiming, resolvePrivacyProfile, sanitizeAuditPayload, setAgentAttributes, setGenAiContent, spinLoop, subscribeAiTelemetry, tokenCeiling, traceGenAI, traceLLM, verifyEventEnvelopeHash, withAgentAction, withAgentSession, withAgentToolCall, withScopedTool };
|
|
12
|
+
import { A as SpanEnd, C as ChatEndEvent, D as GenAiObserverEvent, E as GenAiObserver, F as WorkflowStartEvent, M as ToolEndEvent, N as ToolStartEvent, O as GenAiObserverOptions, P as WorkflowEndEvent, S as AgentStartEvent, T as ChatStreamTiming, _ as ObserveAiSdkOptions, a as subscribeAiTelemetry, b as createGenAiObserver, c as autotelTelemetry, d as promptToGenAiMessages, f as AiSdkResult, g as AiSdkUsage, h as AiSdkToolResult, i as SubscribeAiTelemetryOptions, j as SpanStart, k as GenAiToolIdentity, l as ConvertedPrompt, m as AiSdkToolCall, n as LangChainObserverOptions, o as AutotelTelemetryIntegration, p as AiSdkStep, r as createLangChainObserver, s as AutotelTelemetryOptions, t as LangChainObserverHandler, u as contentToGenAiMessage, v as observeAiSdkResult, w as ChatStartEvent, x as AgentEndEvent, y as SpanRegistry } from "./index-Lg3gQ_VO.js";
|
|
13
|
+
export { AGENT_AUDIT_SCHEMA_VERSION, AI_SDK_ATTR, AUTOTEL_ENRICHED_ATTR, type AgentActionFactory, type AgentActionMetadata, type AgentActionOptions, type AgentAiMetadata, type AgentAuditEventEnvelope, type AgentContext, type AgentDecisionMetadata, type AgentEndEvent, type AgentEventKind, type AgentHandler, type AgentIdentity, type AgentIdentityRecord, type AgentIdentityRegistry, type AgentIdentityStatus, type AgentMetadataInput, type AgentOutcome, type AgentSessionActionMetadata, type AgentSessionMetadata, type AgentSessionStatus, type AgentStartEvent, type AgentToolCallActionMetadata, type AgentToolCallOptions, type AiLifecycleStage, type AiSdkEnrichContext, type AiSdkResult, type AiSdkSpanType, type AiSdkStep, type AiSdkToolCall, type AiSdkToolResult, type AiSdkUsage, type AutotelEnrichOptions, type AutotelTelemetryIntegration, type AutotelTelemetryOptions, CONTEXT_LIMITS, type ChatEndEvent, type ChatStartEvent, type ChatStreamTiming, type ChunkIntervalStats, type ComputeStreamTimingInput, type ContentCaptureSettings, type ConvertedPrompt, type CreateSignedEventEnvelopeOptions, type DelegateToAgentInput, type DelegationContext, type EstimateCostOptions, type EvaluationResultEvent, GEN_AI, GEN_AI_COST_ATTRIBUTE, GEN_AI_COST_USD_BUCKETS, GEN_AI_DURATION_BUCKETS_SECONDS, GEN_AI_EVENT, GEN_AI_EXT_EVENT, GEN_AI_GUARD_EVENT, GEN_AI_METRIC, GEN_AI_OPERATION, GEN_AI_OUTPUT_TYPE, GEN_AI_PROVIDER, GEN_AI_TOKEN_TYPE, GEN_AI_TOKEN_USAGE_BUCKETS, GEN_AI_TOOL_TYPE, type GenAiAgentInput, type GenAiAttributeKey, type GenAiAttributeMap, type GenAiBudgetOptions, type GenAiContentSink, type GenAiGuard, type GenAiGuardOptions, type GenAiGuardRule, type GenAiGuardStep, type GenAiHistogramKind, type GenAiMemoryInput, type GenAiMessage, type GenAiMessagePart, type GenAiMetricInput, type GenAiObserver, type GenAiObserverEvent, type GenAiObserverOptions, type GenAiOperationExceptionEvent, type GenAiOperationName, type GenAiOutputType, type GenAiProviderName, type GenAiRequestInput, type GenAiResponseInput, type GenAiRetrievalInput, type GenAiTokenType, type GenAiToolIdentity, type GenAiToolInput, type GenAiToolType, type GenAiUsageInput, type GenAiWarning, type GenAiWorkflowInput, type GovernanceMetadata, type GuardAction, type GuardSink, type GuardState, type GuardStopBehavior, type GuardUsage, type GuardViolation, type HashPayloadOptions, type InferenceDetailsEvent, type LangChainObserverHandler, type LangChainObserverOptions, MODEL_PRICING, type ModelPricing, type ObserveAiSdkOptions, type PolicyDecision, type PolicyMetadata, type PrivacyProfile, type PrivacyProfileInput, type PrivacyProfileName, type ProvisionAgentIdentityInput, type RecordAgentHandoffMetadata, type RevokeAgentIdentityInput, type RotateAgentIdentityInput, type ScopedToolDefinition, type SpanEnd, SpanRegistry, type SpanStart, type StreamTimer, type StreamTiming, type SubscribeAiTelemetryOptions, type TokenUsage, type ToolCallMetadata, type ToolEndEvent, type ToolStartEvent, type ToolStatus, type TraceGenAIConfig, type WorkflowEndEvent, type WorkflowStartEvent, autotelEnrich, autotelTelemetry, canonicalizeForHash, chunkIntervalStats, computeStreamTiming, contentToGenAiMessage, contextBudget, costCeiling, createAgentAuditMetadata, createAgentIdentityRegistry, createGenAiBudget, createGenAiGuard, createGenAiObserver, createLangChainObserver, createSignedEventEnvelope, createStreamTimer, defineAgentAction, defineAgentToolCall, delegateToAgent, errorLoop, estimateAiSdkCost, estimateLLMCost, extractAiSdkModel, extractAiSdkUsage, flattenAgentAttributes, genAiAgentAttributes, genAiMemoryAttributes, genAiMetricViews, genAiRequestAttributes, genAiResponseAttributes, genAiRetrievalAttributes, genAiSpanName, genAiToolAttributes, genAiUsageAttributes, genAiWorkflowAttributes, hashPayload, llmHistogramAdvice, mapAiSdkAttributes, maxDuration, maxSteps, maxToolCalls, normalizeAiSdkProvider, observeAiSdkResult, parseGuardRules, promptToGenAiMessages, recordAgentHandoff, recordAiSdkCost, recordDecisionBasis, recordEvaluationResult, recordGenAiMetrics, recordGenAiResponse, recordGenAiUsage, recordInferenceDetails, recordLLMCost, recordModelWarnings, recordOperationException, recordPolicyDecision, recordStreamTiming, resetGenAiInstruments, resolvePrivacyProfile, sanitizeAuditPayload, setAgentAttributes, setGenAiContent, spinLoop, subscribeAiTelemetry, tokenCeiling, traceGenAI, traceLLM, verifyEventEnvelopeHash, withAgentAction, withAgentSession, withAgentToolCall, withScopedTool };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GEN_AI, GEN_AI_EVENT, GEN_AI_EXT_EVENT, GEN_AI_GUARD_EVENT, GEN_AI_METRIC, GEN_AI_OPERATION, GEN_AI_OUTPUT_TYPE, GEN_AI_PROVIDER, GEN_AI_TOKEN_TYPE, GEN_AI_TOOL_TYPE, genAiSpanName } from "./semconv.js";
|
|
2
2
|
import { GEN_AI_COST_ATTRIBUTE, MODEL_PRICING, estimateLLMCost, recordLLMCost } from "./cost.js";
|
|
3
|
-
import { GEN_AI_COST_USD_BUCKETS, GEN_AI_DURATION_BUCKETS_SECONDS, GEN_AI_TOKEN_USAGE_BUCKETS, genAiMetricViews, llmHistogramAdvice } from "./metrics.js";
|
|
3
|
+
import { GEN_AI_COST_USD_BUCKETS, GEN_AI_DURATION_BUCKETS_SECONDS, GEN_AI_TOKEN_USAGE_BUCKETS, genAiMetricViews, llmHistogramAdvice, recordGenAiMetrics, resetGenAiInstruments } from "./metrics.js";
|
|
4
4
|
import { a as genAiRetrievalAttributes, c as genAiWorkflowAttributes, i as genAiResponseAttributes, n as genAiMemoryAttributes, o as genAiToolAttributes, r as genAiRequestAttributes, s as genAiUsageAttributes, t as genAiAgentAttributes } from "./attributes-DCv1cxKZ.js";
|
|
5
5
|
import { recordEvaluationResult, recordInferenceDetails, recordModelWarnings, recordOperationException, setGenAiContent } from "./events.js";
|
|
6
6
|
import { chunkIntervalStats, computeStreamTiming, createStreamTimer, recordStreamTiming } from "./streaming.js";
|
|
@@ -10,4 +10,4 @@ import { AI_SDK_ATTR, AUTOTEL_ENRICHED_ATTR, autotelEnrich, estimateAiSdkCost, e
|
|
|
10
10
|
import { a as promptToGenAiMessages, c as SpanRegistry, i as contentToGenAiMessage, n as subscribeAiTelemetry, o as observeAiSdkResult, r as autotelTelemetry, s as createGenAiObserver, t as createLangChainObserver } from "./observer-Ckha9xGv.js";
|
|
11
11
|
import { C as canonicalizeForHash, S as createAgentAuditMetadata, T as AGENT_AUDIT_SCHEMA_VERSION, _ as recordPolicyDecision, a as withScopedTool, b as flattenAgentAttributes, c as resolvePrivacyProfile, d as withAgentSession, f as delegateToAgent, g as recordDecisionBasis, h as defineAgentToolCall, l as sanitizeAuditPayload, m as defineAgentAction, o as createSignedEventEnvelope, p as recordAgentHandoff, s as verifyEventEnvelopeHash, u as createAgentIdentityRegistry, v as withAgentAction, w as hashPayload, x as setAgentAttributes, y as withAgentToolCall } from "./agent-oCfaqmYw.js";
|
|
12
12
|
|
|
13
|
-
export { AGENT_AUDIT_SCHEMA_VERSION, AI_SDK_ATTR, AUTOTEL_ENRICHED_ATTR, CONTEXT_LIMITS, GEN_AI, GEN_AI_COST_ATTRIBUTE, GEN_AI_COST_USD_BUCKETS, GEN_AI_DURATION_BUCKETS_SECONDS, GEN_AI_EVENT, GEN_AI_EXT_EVENT, GEN_AI_GUARD_EVENT, GEN_AI_METRIC, GEN_AI_OPERATION, GEN_AI_OUTPUT_TYPE, GEN_AI_PROVIDER, GEN_AI_TOKEN_TYPE, GEN_AI_TOKEN_USAGE_BUCKETS, GEN_AI_TOOL_TYPE, MODEL_PRICING, SpanRegistry, autotelEnrich, autotelTelemetry, canonicalizeForHash, chunkIntervalStats, computeStreamTiming, contentToGenAiMessage, contextBudget, costCeiling, createAgentAuditMetadata, createAgentIdentityRegistry, createGenAiBudget, createGenAiGuard, createGenAiObserver, createLangChainObserver, createSignedEventEnvelope, createStreamTimer, defineAgentAction, defineAgentToolCall, delegateToAgent, errorLoop, estimateAiSdkCost, estimateLLMCost, extractAiSdkModel, extractAiSdkUsage, flattenAgentAttributes, genAiAgentAttributes, genAiMemoryAttributes, genAiMetricViews, genAiRequestAttributes, genAiResponseAttributes, genAiRetrievalAttributes, genAiSpanName, genAiToolAttributes, genAiUsageAttributes, genAiWorkflowAttributes, hashPayload, llmHistogramAdvice, mapAiSdkAttributes, maxDuration, maxSteps, maxToolCalls, normalizeAiSdkProvider, observeAiSdkResult, parseGuardRules, promptToGenAiMessages, recordAgentHandoff, recordAiSdkCost, recordDecisionBasis, recordEvaluationResult, recordGenAiResponse, recordGenAiUsage, recordInferenceDetails, recordLLMCost, recordModelWarnings, recordOperationException, recordPolicyDecision, recordStreamTiming, resolvePrivacyProfile, sanitizeAuditPayload, setAgentAttributes, setGenAiContent, spinLoop, subscribeAiTelemetry, tokenCeiling, traceGenAI, traceLLM, verifyEventEnvelopeHash, withAgentAction, withAgentSession, withAgentToolCall, withScopedTool };
|
|
13
|
+
export { AGENT_AUDIT_SCHEMA_VERSION, AI_SDK_ATTR, AUTOTEL_ENRICHED_ATTR, CONTEXT_LIMITS, GEN_AI, GEN_AI_COST_ATTRIBUTE, GEN_AI_COST_USD_BUCKETS, GEN_AI_DURATION_BUCKETS_SECONDS, GEN_AI_EVENT, GEN_AI_EXT_EVENT, GEN_AI_GUARD_EVENT, GEN_AI_METRIC, GEN_AI_OPERATION, GEN_AI_OUTPUT_TYPE, GEN_AI_PROVIDER, GEN_AI_TOKEN_TYPE, GEN_AI_TOKEN_USAGE_BUCKETS, GEN_AI_TOOL_TYPE, MODEL_PRICING, SpanRegistry, autotelEnrich, autotelTelemetry, canonicalizeForHash, chunkIntervalStats, computeStreamTiming, contentToGenAiMessage, contextBudget, costCeiling, createAgentAuditMetadata, createAgentIdentityRegistry, createGenAiBudget, createGenAiGuard, createGenAiObserver, createLangChainObserver, createSignedEventEnvelope, createStreamTimer, defineAgentAction, defineAgentToolCall, delegateToAgent, errorLoop, estimateAiSdkCost, estimateLLMCost, extractAiSdkModel, extractAiSdkUsage, flattenAgentAttributes, genAiAgentAttributes, genAiMemoryAttributes, genAiMetricViews, genAiRequestAttributes, genAiResponseAttributes, genAiRetrievalAttributes, genAiSpanName, genAiToolAttributes, genAiUsageAttributes, genAiWorkflowAttributes, hashPayload, llmHistogramAdvice, mapAiSdkAttributes, maxDuration, maxSteps, maxToolCalls, normalizeAiSdkProvider, observeAiSdkResult, parseGuardRules, promptToGenAiMessages, recordAgentHandoff, recordAiSdkCost, recordDecisionBasis, recordEvaluationResult, recordGenAiMetrics, recordGenAiResponse, recordGenAiUsage, recordInferenceDetails, recordLLMCost, recordModelWarnings, recordOperationException, recordPolicyDecision, recordStreamTiming, resetGenAiInstruments, resolvePrivacyProfile, sanitizeAuditPayload, setAgentAttributes, setGenAiContent, spinLoop, subscribeAiTelemetry, tokenCeiling, traceGenAI, traceLLM, verifyEventEnvelopeHash, withAgentAction, withAgentSession, withAgentToolCall, withScopedTool };
|
package/dist/metrics.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_semconv = require('./semconv.cjs');
|
|
3
|
+
let _opentelemetry_api = require("@opentelemetry/api");
|
|
3
4
|
let _opentelemetry_sdk_metrics = require("@opentelemetry/sdk-metrics");
|
|
4
5
|
|
|
5
6
|
//#region src/metrics.ts
|
|
@@ -34,6 +35,7 @@ let _opentelemetry_sdk_metrics = require("@opentelemetry/sdk-metrics");
|
|
|
34
35
|
* sdk.start();
|
|
35
36
|
* ```
|
|
36
37
|
*/
|
|
38
|
+
const TOKEN_TYPE = require_semconv.GEN_AI.TOKEN_TYPE;
|
|
37
39
|
/**
|
|
38
40
|
* Duration buckets for GenAI operations, in **seconds**. Matches the spec's
|
|
39
41
|
* advice for `gen_ai.client.operation.duration` and the streaming-timing
|
|
@@ -151,7 +153,7 @@ function genAiMetricViews(extra = []) {
|
|
|
151
153
|
kind: "tokens"
|
|
152
154
|
},
|
|
153
155
|
{
|
|
154
|
-
instrumentName:
|
|
156
|
+
instrumentName: require_semconv.GEN_AI_METRIC.COST_USD,
|
|
155
157
|
kind: "cost"
|
|
156
158
|
}
|
|
157
159
|
];
|
|
@@ -163,10 +165,91 @@ function genAiMetricViews(extra = []) {
|
|
|
163
165
|
}
|
|
164
166
|
}));
|
|
165
167
|
}
|
|
168
|
+
let instruments;
|
|
169
|
+
let instrumentsProvider;
|
|
170
|
+
/**
|
|
171
|
+
* Instruments are created on first record and cached against the provider they
|
|
172
|
+
* came from. Keyed on the provider because a `shutdown()` / `init()` cycle —
|
|
173
|
+
* hot reload, a test suite, a serverless container re-initialising — installs a
|
|
174
|
+
* new one, and instruments bound to the old one record into nothing.
|
|
175
|
+
*/
|
|
176
|
+
function getInstruments() {
|
|
177
|
+
const provider = _opentelemetry_api.metrics.getMeterProvider();
|
|
178
|
+
if (!instruments || instrumentsProvider !== provider) {
|
|
179
|
+
instrumentsProvider = provider;
|
|
180
|
+
const meter = provider.getMeter("autotel-genai");
|
|
181
|
+
instruments = {
|
|
182
|
+
duration: meter.createHistogram(require_semconv.GEN_AI_METRIC.OPERATION_DURATION, {
|
|
183
|
+
description: "GenAI operation duration",
|
|
184
|
+
unit: "s",
|
|
185
|
+
...llmHistogramAdvice("duration")
|
|
186
|
+
}),
|
|
187
|
+
tokens: meter.createHistogram(require_semconv.GEN_AI_METRIC.TOKEN_USAGE, {
|
|
188
|
+
description: "Tokens consumed by a GenAI operation",
|
|
189
|
+
unit: "{token}",
|
|
190
|
+
...llmHistogramAdvice("tokens")
|
|
191
|
+
}),
|
|
192
|
+
cost: meter.createHistogram(require_semconv.GEN_AI_METRIC.COST_USD, {
|
|
193
|
+
description: "Estimated USD cost of a GenAI operation",
|
|
194
|
+
unit: "{USD}",
|
|
195
|
+
...llmHistogramAdvice("cost")
|
|
196
|
+
}),
|
|
197
|
+
timeToFirstChunk: meter.createHistogram(require_semconv.GEN_AI_METRIC.TIME_TO_FIRST_CHUNK, {
|
|
198
|
+
description: "Seconds from request start to the first streamed chunk",
|
|
199
|
+
unit: "s",
|
|
200
|
+
...llmHistogramAdvice("duration")
|
|
201
|
+
})
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
return instruments;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Drop the cached instruments so the next record rebuilds them against the
|
|
208
|
+
* current `MeterProvider`.
|
|
209
|
+
*
|
|
210
|
+
* @internal Exported for tests that swap providers between cases. Production
|
|
211
|
+
* code registers one provider in `init()` and never needs this.
|
|
212
|
+
*/
|
|
213
|
+
function resetGenAiInstruments() {
|
|
214
|
+
instruments = undefined;
|
|
215
|
+
instrumentsProvider = undefined;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Record the canonical GenAI metrics for one completed operation.
|
|
219
|
+
*
|
|
220
|
+
* Called by `traceGenAI`; you only need it when instrumenting a GenAI call
|
|
221
|
+
* some other way. Without a registered `MeterProvider` every call is a no-op,
|
|
222
|
+
* so this costs nothing in a traces-only setup.
|
|
223
|
+
*/
|
|
224
|
+
function recordGenAiMetrics(input) {
|
|
225
|
+
const { duration, tokens, cost, timeToFirstChunk } = getInstruments();
|
|
226
|
+
const attributes = input.attributes;
|
|
227
|
+
duration.record(input.durationSeconds, attributes);
|
|
228
|
+
if (input.inputTokens !== undefined) {
|
|
229
|
+
tokens.record(input.inputTokens, {
|
|
230
|
+
...attributes,
|
|
231
|
+
[TOKEN_TYPE]: "input"
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
if (input.outputTokens !== undefined) {
|
|
235
|
+
tokens.record(input.outputTokens, {
|
|
236
|
+
...attributes,
|
|
237
|
+
[TOKEN_TYPE]: "output"
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
if (input.costUsd !== undefined) {
|
|
241
|
+
cost.record(input.costUsd, attributes);
|
|
242
|
+
}
|
|
243
|
+
if (input.timeToFirstChunk !== undefined) {
|
|
244
|
+
timeToFirstChunk.record(input.timeToFirstChunk, attributes);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
166
247
|
|
|
167
248
|
//#endregion
|
|
168
249
|
exports.GEN_AI_COST_USD_BUCKETS = GEN_AI_COST_USD_BUCKETS;
|
|
169
250
|
exports.GEN_AI_DURATION_BUCKETS_SECONDS = GEN_AI_DURATION_BUCKETS_SECONDS;
|
|
170
251
|
exports.GEN_AI_TOKEN_USAGE_BUCKETS = GEN_AI_TOKEN_USAGE_BUCKETS;
|
|
171
252
|
exports.genAiMetricViews = genAiMetricViews;
|
|
172
|
-
exports.llmHistogramAdvice = llmHistogramAdvice;
|
|
253
|
+
exports.llmHistogramAdvice = llmHistogramAdvice;
|
|
254
|
+
exports.recordGenAiMetrics = recordGenAiMetrics;
|
|
255
|
+
exports.resetGenAiInstruments = resetGenAiInstruments;
|
package/dist/metrics.d.cts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Attributes } from "@opentelemetry/api";
|
|
1
2
|
import { ViewOptions } from "@opentelemetry/sdk-metrics";
|
|
2
3
|
//#region src/metrics.d.ts
|
|
3
4
|
/**
|
|
@@ -46,5 +47,32 @@ declare function genAiMetricViews(extra?: {
|
|
|
46
47
|
instrumentName: string;
|
|
47
48
|
kind: GenAiHistogramKind;
|
|
48
49
|
}[]): ViewOptions[];
|
|
50
|
+
/** One completed GenAI operation, as {@link recordGenAiMetrics} needs it. */
|
|
51
|
+
interface GenAiMetricInput {
|
|
52
|
+
/** Wall-clock seconds for the operation. */
|
|
53
|
+
durationSeconds: number;
|
|
54
|
+
/** Attributes shared by every instrument: operation, provider, model. */
|
|
55
|
+
attributes: Attributes;
|
|
56
|
+
inputTokens?: number;
|
|
57
|
+
outputTokens?: number;
|
|
58
|
+
costUsd?: number;
|
|
59
|
+
timeToFirstChunk?: number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Drop the cached instruments so the next record rebuilds them against the
|
|
63
|
+
* current `MeterProvider`.
|
|
64
|
+
*
|
|
65
|
+
* @internal Exported for tests that swap providers between cases. Production
|
|
66
|
+
* code registers one provider in `init()` and never needs this.
|
|
67
|
+
*/
|
|
68
|
+
declare function resetGenAiInstruments(): void;
|
|
69
|
+
/**
|
|
70
|
+
* Record the canonical GenAI metrics for one completed operation.
|
|
71
|
+
*
|
|
72
|
+
* Called by `traceGenAI`; you only need it when instrumenting a GenAI call
|
|
73
|
+
* some other way. Without a registered `MeterProvider` every call is a no-op,
|
|
74
|
+
* so this costs nothing in a traces-only setup.
|
|
75
|
+
*/
|
|
76
|
+
declare function recordGenAiMetrics(input: GenAiMetricInput): void;
|
|
49
77
|
//#endregion
|
|
50
|
-
export { GEN_AI_COST_USD_BUCKETS, GEN_AI_DURATION_BUCKETS_SECONDS, GEN_AI_TOKEN_USAGE_BUCKETS, GenAiHistogramKind, genAiMetricViews, llmHistogramAdvice };
|
|
78
|
+
export { GEN_AI_COST_USD_BUCKETS, GEN_AI_DURATION_BUCKETS_SECONDS, GEN_AI_TOKEN_USAGE_BUCKETS, GenAiHistogramKind, GenAiMetricInput, genAiMetricViews, llmHistogramAdvice, recordGenAiMetrics, resetGenAiInstruments };
|
package/dist/metrics.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Attributes } from "@opentelemetry/api";
|
|
1
2
|
import { ViewOptions } from "@opentelemetry/sdk-metrics";
|
|
2
3
|
//#region src/metrics.d.ts
|
|
3
4
|
/**
|
|
@@ -46,5 +47,32 @@ declare function genAiMetricViews(extra?: {
|
|
|
46
47
|
instrumentName: string;
|
|
47
48
|
kind: GenAiHistogramKind;
|
|
48
49
|
}[]): ViewOptions[];
|
|
50
|
+
/** One completed GenAI operation, as {@link recordGenAiMetrics} needs it. */
|
|
51
|
+
interface GenAiMetricInput {
|
|
52
|
+
/** Wall-clock seconds for the operation. */
|
|
53
|
+
durationSeconds: number;
|
|
54
|
+
/** Attributes shared by every instrument: operation, provider, model. */
|
|
55
|
+
attributes: Attributes;
|
|
56
|
+
inputTokens?: number;
|
|
57
|
+
outputTokens?: number;
|
|
58
|
+
costUsd?: number;
|
|
59
|
+
timeToFirstChunk?: number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Drop the cached instruments so the next record rebuilds them against the
|
|
63
|
+
* current `MeterProvider`.
|
|
64
|
+
*
|
|
65
|
+
* @internal Exported for tests that swap providers between cases. Production
|
|
66
|
+
* code registers one provider in `init()` and never needs this.
|
|
67
|
+
*/
|
|
68
|
+
declare function resetGenAiInstruments(): void;
|
|
69
|
+
/**
|
|
70
|
+
* Record the canonical GenAI metrics for one completed operation.
|
|
71
|
+
*
|
|
72
|
+
* Called by `traceGenAI`; you only need it when instrumenting a GenAI call
|
|
73
|
+
* some other way. Without a registered `MeterProvider` every call is a no-op,
|
|
74
|
+
* so this costs nothing in a traces-only setup.
|
|
75
|
+
*/
|
|
76
|
+
declare function recordGenAiMetrics(input: GenAiMetricInput): void;
|
|
49
77
|
//#endregion
|
|
50
|
-
export { GEN_AI_COST_USD_BUCKETS, GEN_AI_DURATION_BUCKETS_SECONDS, GEN_AI_TOKEN_USAGE_BUCKETS, GenAiHistogramKind, genAiMetricViews, llmHistogramAdvice };
|
|
78
|
+
export { GEN_AI_COST_USD_BUCKETS, GEN_AI_DURATION_BUCKETS_SECONDS, GEN_AI_TOKEN_USAGE_BUCKETS, GenAiHistogramKind, GenAiMetricInput, genAiMetricViews, llmHistogramAdvice, recordGenAiMetrics, resetGenAiInstruments };
|
package/dist/metrics.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { GEN_AI_METRIC } from "./semconv.js";
|
|
1
|
+
import { GEN_AI, GEN_AI_METRIC } from "./semconv.js";
|
|
2
|
+
import { metrics } from "@opentelemetry/api";
|
|
2
3
|
import { AggregationType } from "@opentelemetry/sdk-metrics";
|
|
3
4
|
|
|
4
5
|
//#region src/metrics.ts
|
|
@@ -33,6 +34,7 @@ import { AggregationType } from "@opentelemetry/sdk-metrics";
|
|
|
33
34
|
* sdk.start();
|
|
34
35
|
* ```
|
|
35
36
|
*/
|
|
37
|
+
const TOKEN_TYPE = GEN_AI.TOKEN_TYPE;
|
|
36
38
|
/**
|
|
37
39
|
* Duration buckets for GenAI operations, in **seconds**. Matches the spec's
|
|
38
40
|
* advice for `gen_ai.client.operation.duration` and the streaming-timing
|
|
@@ -150,7 +152,7 @@ function genAiMetricViews(extra = []) {
|
|
|
150
152
|
kind: "tokens"
|
|
151
153
|
},
|
|
152
154
|
{
|
|
153
|
-
instrumentName:
|
|
155
|
+
instrumentName: GEN_AI_METRIC.COST_USD,
|
|
154
156
|
kind: "cost"
|
|
155
157
|
}
|
|
156
158
|
];
|
|
@@ -162,6 +164,85 @@ function genAiMetricViews(extra = []) {
|
|
|
162
164
|
}
|
|
163
165
|
}));
|
|
164
166
|
}
|
|
167
|
+
let instruments;
|
|
168
|
+
let instrumentsProvider;
|
|
169
|
+
/**
|
|
170
|
+
* Instruments are created on first record and cached against the provider they
|
|
171
|
+
* came from. Keyed on the provider because a `shutdown()` / `init()` cycle —
|
|
172
|
+
* hot reload, a test suite, a serverless container re-initialising — installs a
|
|
173
|
+
* new one, and instruments bound to the old one record into nothing.
|
|
174
|
+
*/
|
|
175
|
+
function getInstruments() {
|
|
176
|
+
const provider = metrics.getMeterProvider();
|
|
177
|
+
if (!instruments || instrumentsProvider !== provider) {
|
|
178
|
+
instrumentsProvider = provider;
|
|
179
|
+
const meter = provider.getMeter("autotel-genai");
|
|
180
|
+
instruments = {
|
|
181
|
+
duration: meter.createHistogram(GEN_AI_METRIC.OPERATION_DURATION, {
|
|
182
|
+
description: "GenAI operation duration",
|
|
183
|
+
unit: "s",
|
|
184
|
+
...llmHistogramAdvice("duration")
|
|
185
|
+
}),
|
|
186
|
+
tokens: meter.createHistogram(GEN_AI_METRIC.TOKEN_USAGE, {
|
|
187
|
+
description: "Tokens consumed by a GenAI operation",
|
|
188
|
+
unit: "{token}",
|
|
189
|
+
...llmHistogramAdvice("tokens")
|
|
190
|
+
}),
|
|
191
|
+
cost: meter.createHistogram(GEN_AI_METRIC.COST_USD, {
|
|
192
|
+
description: "Estimated USD cost of a GenAI operation",
|
|
193
|
+
unit: "{USD}",
|
|
194
|
+
...llmHistogramAdvice("cost")
|
|
195
|
+
}),
|
|
196
|
+
timeToFirstChunk: meter.createHistogram(GEN_AI_METRIC.TIME_TO_FIRST_CHUNK, {
|
|
197
|
+
description: "Seconds from request start to the first streamed chunk",
|
|
198
|
+
unit: "s",
|
|
199
|
+
...llmHistogramAdvice("duration")
|
|
200
|
+
})
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
return instruments;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Drop the cached instruments so the next record rebuilds them against the
|
|
207
|
+
* current `MeterProvider`.
|
|
208
|
+
*
|
|
209
|
+
* @internal Exported for tests that swap providers between cases. Production
|
|
210
|
+
* code registers one provider in `init()` and never needs this.
|
|
211
|
+
*/
|
|
212
|
+
function resetGenAiInstruments() {
|
|
213
|
+
instruments = undefined;
|
|
214
|
+
instrumentsProvider = undefined;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Record the canonical GenAI metrics for one completed operation.
|
|
218
|
+
*
|
|
219
|
+
* Called by `traceGenAI`; you only need it when instrumenting a GenAI call
|
|
220
|
+
* some other way. Without a registered `MeterProvider` every call is a no-op,
|
|
221
|
+
* so this costs nothing in a traces-only setup.
|
|
222
|
+
*/
|
|
223
|
+
function recordGenAiMetrics(input) {
|
|
224
|
+
const { duration, tokens, cost, timeToFirstChunk } = getInstruments();
|
|
225
|
+
const attributes = input.attributes;
|
|
226
|
+
duration.record(input.durationSeconds, attributes);
|
|
227
|
+
if (input.inputTokens !== undefined) {
|
|
228
|
+
tokens.record(input.inputTokens, {
|
|
229
|
+
...attributes,
|
|
230
|
+
[TOKEN_TYPE]: "input"
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
if (input.outputTokens !== undefined) {
|
|
234
|
+
tokens.record(input.outputTokens, {
|
|
235
|
+
...attributes,
|
|
236
|
+
[TOKEN_TYPE]: "output"
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
if (input.costUsd !== undefined) {
|
|
240
|
+
cost.record(input.costUsd, attributes);
|
|
241
|
+
}
|
|
242
|
+
if (input.timeToFirstChunk !== undefined) {
|
|
243
|
+
timeToFirstChunk.record(input.timeToFirstChunk, attributes);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
165
246
|
|
|
166
247
|
//#endregion
|
|
167
|
-
export { GEN_AI_COST_USD_BUCKETS, GEN_AI_DURATION_BUCKETS_SECONDS, GEN_AI_TOKEN_USAGE_BUCKETS, genAiMetricViews, llmHistogramAdvice };
|
|
248
|
+
export { GEN_AI_COST_USD_BUCKETS, GEN_AI_DURATION_BUCKETS_SECONDS, GEN_AI_TOKEN_USAGE_BUCKETS, genAiMetricViews, llmHistogramAdvice, recordGenAiMetrics, resetGenAiInstruments };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as SpanEnd, C as ChatEndEvent, D as GenAiObserverEvent, E as GenAiObserver, F as WorkflowStartEvent, M as ToolEndEvent, N as ToolStartEvent, O as GenAiObserverOptions, P as WorkflowEndEvent, S as AgentStartEvent, T as ChatStreamTiming, _ as ObserveAiSdkOptions, a as subscribeAiTelemetry, b as createGenAiObserver, c as autotelTelemetry, d as promptToGenAiMessages, f as AiSdkResult, g as AiSdkUsage, h as AiSdkToolResult, i as SubscribeAiTelemetryOptions, j as SpanStart, k as GenAiToolIdentity, l as ConvertedPrompt, m as AiSdkToolCall, n as LangChainObserverOptions, o as AutotelTelemetryIntegration, p as AiSdkStep, r as createLangChainObserver, s as AutotelTelemetryOptions, t as LangChainObserverHandler, u as contentToGenAiMessage, v as observeAiSdkResult, w as ChatStartEvent, x as AgentEndEvent, y as SpanRegistry } from "../index-
|
|
1
|
+
import { A as SpanEnd, C as ChatEndEvent, D as GenAiObserverEvent, E as GenAiObserver, F as WorkflowStartEvent, M as ToolEndEvent, N as ToolStartEvent, O as GenAiObserverOptions, P as WorkflowEndEvent, S as AgentStartEvent, T as ChatStreamTiming, _ as ObserveAiSdkOptions, a as subscribeAiTelemetry, b as createGenAiObserver, c as autotelTelemetry, d as promptToGenAiMessages, f as AiSdkResult, g as AiSdkUsage, h as AiSdkToolResult, i as SubscribeAiTelemetryOptions, j as SpanStart, k as GenAiToolIdentity, l as ConvertedPrompt, m as AiSdkToolCall, n as LangChainObserverOptions, o as AutotelTelemetryIntegration, p as AiSdkStep, r as createLangChainObserver, s as AutotelTelemetryOptions, t as LangChainObserverHandler, u as contentToGenAiMessage, v as observeAiSdkResult, w as ChatStartEvent, x as AgentEndEvent, y as SpanRegistry } from "../index-Bgt8apSM.cjs";
|
|
2
2
|
export { type AgentEndEvent, type AgentStartEvent, type AiSdkResult, type AiSdkStep, type AiSdkToolCall, type AiSdkToolResult, type AiSdkUsage, type AutotelTelemetryIntegration, type AutotelTelemetryOptions, type ChatEndEvent, type ChatStartEvent, type ChatStreamTiming, type ConvertedPrompt, type GenAiObserver, type GenAiObserverEvent, type GenAiObserverOptions, type GenAiToolIdentity, type LangChainObserverHandler, type LangChainObserverOptions, type ObserveAiSdkOptions, type SpanEnd, SpanRegistry, type SpanStart, type SubscribeAiTelemetryOptions, type ToolEndEvent, type ToolStartEvent, type WorkflowEndEvent, type WorkflowStartEvent, autotelTelemetry, contentToGenAiMessage, createGenAiObserver, createLangChainObserver, observeAiSdkResult, promptToGenAiMessages, subscribeAiTelemetry };
|
package/dist/observer/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as SpanEnd, C as ChatEndEvent, D as GenAiObserverEvent, E as GenAiObserver, F as WorkflowStartEvent, M as ToolEndEvent, N as ToolStartEvent, O as GenAiObserverOptions, P as WorkflowEndEvent, S as AgentStartEvent, T as ChatStreamTiming, _ as ObserveAiSdkOptions, a as subscribeAiTelemetry, b as createGenAiObserver, c as autotelTelemetry, d as promptToGenAiMessages, f as AiSdkResult, g as AiSdkUsage, h as AiSdkToolResult, i as SubscribeAiTelemetryOptions, j as SpanStart, k as GenAiToolIdentity, l as ConvertedPrompt, m as AiSdkToolCall, n as LangChainObserverOptions, o as AutotelTelemetryIntegration, p as AiSdkStep, r as createLangChainObserver, s as AutotelTelemetryOptions, t as LangChainObserverHandler, u as contentToGenAiMessage, v as observeAiSdkResult, w as ChatStartEvent, x as AgentEndEvent, y as SpanRegistry } from "../index-
|
|
1
|
+
import { A as SpanEnd, C as ChatEndEvent, D as GenAiObserverEvent, E as GenAiObserver, F as WorkflowStartEvent, M as ToolEndEvent, N as ToolStartEvent, O as GenAiObserverOptions, P as WorkflowEndEvent, S as AgentStartEvent, T as ChatStreamTiming, _ as ObserveAiSdkOptions, a as subscribeAiTelemetry, b as createGenAiObserver, c as autotelTelemetry, d as promptToGenAiMessages, f as AiSdkResult, g as AiSdkUsage, h as AiSdkToolResult, i as SubscribeAiTelemetryOptions, j as SpanStart, k as GenAiToolIdentity, l as ConvertedPrompt, m as AiSdkToolCall, n as LangChainObserverOptions, o as AutotelTelemetryIntegration, p as AiSdkStep, r as createLangChainObserver, s as AutotelTelemetryOptions, t as LangChainObserverHandler, u as contentToGenAiMessage, v as observeAiSdkResult, w as ChatStartEvent, x as AgentEndEvent, y as SpanRegistry } from "../index-Lg3gQ_VO.js";
|
|
2
2
|
export { type AgentEndEvent, type AgentStartEvent, type AiSdkResult, type AiSdkStep, type AiSdkToolCall, type AiSdkToolResult, type AiSdkUsage, type AutotelTelemetryIntegration, type AutotelTelemetryOptions, type ChatEndEvent, type ChatStartEvent, type ChatStreamTiming, type ConvertedPrompt, type GenAiObserver, type GenAiObserverEvent, type GenAiObserverOptions, type GenAiToolIdentity, type LangChainObserverHandler, type LangChainObserverOptions, type ObserveAiSdkOptions, type SpanEnd, SpanRegistry, type SpanStart, type SubscribeAiTelemetryOptions, type ToolEndEvent, type ToolStartEvent, type WorkflowEndEvent, type WorkflowStartEvent, autotelTelemetry, contentToGenAiMessage, createGenAiObserver, createLangChainObserver, observeAiSdkResult, promptToGenAiMessages, subscribeAiTelemetry };
|
|
@@ -181,6 +181,8 @@ declare const GEN_AI_METRIC: {
|
|
|
181
181
|
readonly TIME_TO_FIRST_CHUNK: "gen_ai.client.operation.time_to_first_chunk";
|
|
182
182
|
readonly TIME_PER_OUTPUT_CHUNK: "gen_ai.client.operation.time_per_output_chunk";
|
|
183
183
|
readonly WORKFLOW_DURATION: "gen_ai.workflow.duration";
|
|
184
|
+
/** Autotel extension — the spec publishes no cost metric. */
|
|
185
|
+
readonly COST_USD: "gen_ai.client.cost.usd";
|
|
184
186
|
};
|
|
185
187
|
/** Canonical event names from the GenAI semantic conventions snapshot. */
|
|
186
188
|
declare const GEN_AI_EVENT: {
|
|
@@ -181,6 +181,8 @@ declare const GEN_AI_METRIC: {
|
|
|
181
181
|
readonly TIME_TO_FIRST_CHUNK: "gen_ai.client.operation.time_to_first_chunk";
|
|
182
182
|
readonly TIME_PER_OUTPUT_CHUNK: "gen_ai.client.operation.time_per_output_chunk";
|
|
183
183
|
readonly WORKFLOW_DURATION: "gen_ai.workflow.duration";
|
|
184
|
+
/** Autotel extension — the spec publishes no cost metric. */
|
|
185
|
+
readonly COST_USD: "gen_ai.client.cost.usd";
|
|
184
186
|
};
|
|
185
187
|
/** Canonical event names from the GenAI semantic conventions snapshot. */
|
|
186
188
|
declare const GEN_AI_EVENT: {
|
package/dist/semconv.cjs
CHANGED
|
@@ -174,7 +174,9 @@ const GEN_AI_METRIC = {
|
|
|
174
174
|
OPERATION_DURATION: "gen_ai.client.operation.duration",
|
|
175
175
|
TIME_TO_FIRST_CHUNK: "gen_ai.client.operation.time_to_first_chunk",
|
|
176
176
|
TIME_PER_OUTPUT_CHUNK: "gen_ai.client.operation.time_per_output_chunk",
|
|
177
|
-
WORKFLOW_DURATION: "gen_ai.workflow.duration"
|
|
177
|
+
WORKFLOW_DURATION: "gen_ai.workflow.duration",
|
|
178
|
+
/** Autotel extension — the spec publishes no cost metric. */
|
|
179
|
+
COST_USD: "gen_ai.client.cost.usd"
|
|
178
180
|
};
|
|
179
181
|
/** Canonical event names from the GenAI semantic conventions snapshot. */
|
|
180
182
|
const GEN_AI_EVENT = {
|
package/dist/semconv.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as genAiSpanName, a as GEN_AI_METRIC, c as GEN_AI_PROVIDER, d as GenAiAttributeKey, f as GenAiOperationName, g as GenAiToolType, h as GenAiTokenType, i as GEN_AI_GUARD_EVENT, l as GEN_AI_TOKEN_TYPE, m as GenAiProviderName, n as GEN_AI_EVENT, o as GEN_AI_OPERATION, p as GenAiOutputType, r as GEN_AI_EXT_EVENT, s as GEN_AI_OUTPUT_TYPE, t as GEN_AI, u as GEN_AI_TOOL_TYPE } from "./semconv-
|
|
1
|
+
import { _ as genAiSpanName, a as GEN_AI_METRIC, c as GEN_AI_PROVIDER, d as GenAiAttributeKey, f as GenAiOperationName, g as GenAiToolType, h as GenAiTokenType, i as GEN_AI_GUARD_EVENT, l as GEN_AI_TOKEN_TYPE, m as GenAiProviderName, n as GEN_AI_EVENT, o as GEN_AI_OPERATION, p as GenAiOutputType, r as GEN_AI_EXT_EVENT, s as GEN_AI_OUTPUT_TYPE, t as GEN_AI, u as GEN_AI_TOOL_TYPE } from "./semconv-B6zNvJ73.cjs";
|
|
2
2
|
export { GEN_AI, GEN_AI_EVENT, GEN_AI_EXT_EVENT, GEN_AI_GUARD_EVENT, GEN_AI_METRIC, GEN_AI_OPERATION, GEN_AI_OUTPUT_TYPE, GEN_AI_PROVIDER, GEN_AI_TOKEN_TYPE, GEN_AI_TOOL_TYPE, GenAiAttributeKey, GenAiOperationName, GenAiOutputType, GenAiProviderName, GenAiTokenType, GenAiToolType, genAiSpanName };
|
package/dist/semconv.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as genAiSpanName, a as GEN_AI_METRIC, c as GEN_AI_PROVIDER, d as GenAiAttributeKey, f as GenAiOperationName, g as GenAiToolType, h as GenAiTokenType, i as GEN_AI_GUARD_EVENT, l as GEN_AI_TOKEN_TYPE, m as GenAiProviderName, n as GEN_AI_EVENT, o as GEN_AI_OPERATION, p as GenAiOutputType, r as GEN_AI_EXT_EVENT, s as GEN_AI_OUTPUT_TYPE, t as GEN_AI, u as GEN_AI_TOOL_TYPE } from "./semconv-
|
|
1
|
+
import { _ as genAiSpanName, a as GEN_AI_METRIC, c as GEN_AI_PROVIDER, d as GenAiAttributeKey, f as GenAiOperationName, g as GenAiToolType, h as GenAiTokenType, i as GEN_AI_GUARD_EVENT, l as GEN_AI_TOKEN_TYPE, m as GenAiProviderName, n as GEN_AI_EVENT, o as GEN_AI_OPERATION, p as GenAiOutputType, r as GEN_AI_EXT_EVENT, s as GEN_AI_OUTPUT_TYPE, t as GEN_AI, u as GEN_AI_TOOL_TYPE } from "./semconv-B6zNvJ73.js";
|
|
2
2
|
export { GEN_AI, GEN_AI_EVENT, GEN_AI_EXT_EVENT, GEN_AI_GUARD_EVENT, GEN_AI_METRIC, GEN_AI_OPERATION, GEN_AI_OUTPUT_TYPE, GEN_AI_PROVIDER, GEN_AI_TOKEN_TYPE, GEN_AI_TOOL_TYPE, GenAiAttributeKey, GenAiOperationName, GenAiOutputType, GenAiProviderName, GenAiTokenType, GenAiToolType, genAiSpanName };
|
package/dist/semconv.js
CHANGED
|
@@ -172,7 +172,9 @@ const GEN_AI_METRIC = {
|
|
|
172
172
|
OPERATION_DURATION: "gen_ai.client.operation.duration",
|
|
173
173
|
TIME_TO_FIRST_CHUNK: "gen_ai.client.operation.time_to_first_chunk",
|
|
174
174
|
TIME_PER_OUTPUT_CHUNK: "gen_ai.client.operation.time_per_output_chunk",
|
|
175
|
-
WORKFLOW_DURATION: "gen_ai.workflow.duration"
|
|
175
|
+
WORKFLOW_DURATION: "gen_ai.workflow.duration",
|
|
176
|
+
/** Autotel extension — the spec publishes no cost metric. */
|
|
177
|
+
COST_USD: "gen_ai.client.cost.usd"
|
|
176
178
|
};
|
|
177
179
|
/** Canonical event names from the GenAI semantic conventions snapshot. */
|
|
178
180
|
const GEN_AI_EVENT = {
|
package/dist/trace.cjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_semconv = require('./semconv.cjs');
|
|
3
3
|
const require_cost = require('./cost.cjs');
|
|
4
|
+
const require_metrics = require('./metrics.cjs');
|
|
4
5
|
const require_attributes = require('./attributes-BSunBoIR.cjs');
|
|
6
|
+
let _opentelemetry_api = require("@opentelemetry/api");
|
|
5
7
|
let autotel = require("autotel");
|
|
6
8
|
|
|
7
9
|
//#region src/trace.ts
|
|
@@ -39,6 +41,50 @@ let autotel = require("autotel");
|
|
|
39
41
|
* });
|
|
40
42
|
* ```
|
|
41
43
|
*/
|
|
44
|
+
/**
|
|
45
|
+
* What the metrics get to read: everything already on the span, overlaid with
|
|
46
|
+
* what the handler wrote through `ctx`.
|
|
47
|
+
*
|
|
48
|
+
* Neither alone is enough. `getActiveTraceContext()` hands out a *new* context
|
|
49
|
+
* object, so the documented ambient pattern
|
|
50
|
+
* (`getActiveTraceContext()?.setAttribute('gen_ai.usage.input_tokens', n)`) —
|
|
51
|
+
* and any helper that resolves the context itself — never passes through `ctx`.
|
|
52
|
+
* The span in turn holds nothing when sampling declined to record, and metrics
|
|
53
|
+
* are not sampled.
|
|
54
|
+
*/
|
|
55
|
+
function observed(seen) {
|
|
56
|
+
const span = _opentelemetry_api.trace.getActiveSpan();
|
|
57
|
+
return {
|
|
58
|
+
...span?.attributes,
|
|
59
|
+
...seen
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Record what is written through `ctx` into `seen`, and return the undo.
|
|
64
|
+
*
|
|
65
|
+
* The context is patched in place rather than wrapped: callers spread it
|
|
66
|
+
* (`logger.info({ ...ctx }, 'llm call')`), and a `Object.create(ctx)` wrapper
|
|
67
|
+
* spreads to nothing but the two overridden setters — no traceId, no spanId.
|
|
68
|
+
*/
|
|
69
|
+
function watchAttributes(ctx, seen) {
|
|
70
|
+
const { setAttribute, setAttributes } = ctx;
|
|
71
|
+
ctx.setAttribute = (key, value) => {
|
|
72
|
+
seen[key] = value;
|
|
73
|
+
setAttribute.call(ctx, key, value);
|
|
74
|
+
};
|
|
75
|
+
ctx.setAttributes = (attributes) => {
|
|
76
|
+
Object.assign(seen, attributes);
|
|
77
|
+
setAttributes.call(ctx, attributes);
|
|
78
|
+
};
|
|
79
|
+
return () => {
|
|
80
|
+
ctx.setAttribute = setAttribute;
|
|
81
|
+
ctx.setAttributes = setAttributes;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/** Narrow an observed attribute to a number, ignoring anything else. */
|
|
85
|
+
function asNumber(value) {
|
|
86
|
+
return typeof value === "number" && Number.isFinite(value) ? value : undefined;
|
|
87
|
+
}
|
|
42
88
|
function defaultSpanIdentifier(config) {
|
|
43
89
|
switch (config.operation) {
|
|
44
90
|
case require_semconv.GEN_AI_OPERATION.RETRIEVAL: {
|
|
@@ -88,11 +134,34 @@ function traceGenAI(config) {
|
|
|
88
134
|
const agentAttributes = config.agent ? require_attributes.genAiAgentAttributes(config.agent, { internal: agentSpanIsInternal }) : {};
|
|
89
135
|
const toolAttributes = config.tool ? require_attributes.genAiToolAttributes(config.tool) : {};
|
|
90
136
|
const workflowAttributes = config.workflow ? require_attributes.genAiWorkflowAttributes(config.workflow) : {};
|
|
137
|
+
const emitMetrics = (watched, startedAt) => {
|
|
138
|
+
if (config.metrics === false) return;
|
|
139
|
+
const seen = observed(watched);
|
|
140
|
+
const attributes = { [require_semconv.GEN_AI.OPERATION_NAME]: operation };
|
|
141
|
+
if (config.provider) attributes[require_semconv.GEN_AI.PROVIDER_NAME] = config.provider;
|
|
142
|
+
if (config.model) attributes[require_semconv.GEN_AI.REQUEST_MODEL] = config.model;
|
|
143
|
+
const responseModel = seen[require_semconv.GEN_AI.RESPONSE_MODEL];
|
|
144
|
+
if (typeof responseModel === "string") {
|
|
145
|
+
attributes[require_semconv.GEN_AI.RESPONSE_MODEL] = responseModel;
|
|
146
|
+
}
|
|
147
|
+
const errorType = seen["error.type"];
|
|
148
|
+
if (typeof errorType === "string") attributes["error.type"] = errorType;
|
|
149
|
+
require_metrics.recordGenAiMetrics({
|
|
150
|
+
durationSeconds: (Date.now() - startedAt) / 1e3,
|
|
151
|
+
attributes,
|
|
152
|
+
inputTokens: asNumber(seen[require_semconv.GEN_AI.USAGE_INPUT_TOKENS]),
|
|
153
|
+
outputTokens: asNumber(seen[require_semconv.GEN_AI.USAGE_OUTPUT_TOKENS]),
|
|
154
|
+
costUsd: asNumber(seen[require_semconv.GEN_AI.USAGE_COST_USD]),
|
|
155
|
+
timeToFirstChunk: asNumber(seen[require_semconv.GEN_AI.RESPONSE_TIME_TO_FIRST_CHUNK])
|
|
156
|
+
});
|
|
157
|
+
};
|
|
91
158
|
return (factory) => {
|
|
92
159
|
if (typeof factory !== "function") {
|
|
93
160
|
throw new TypeError("traceGenAI: expected a factory (ctx) => (...args) => result");
|
|
94
161
|
}
|
|
95
162
|
return (0, autotel.withTracing)({ name: spanName })((ctx) => {
|
|
163
|
+
const seen = {};
|
|
164
|
+
const unwatch = config.metrics === false ? () => {} : watchAttributes(ctx, seen);
|
|
96
165
|
ctx.setAttributes({
|
|
97
166
|
...requestAttributes,
|
|
98
167
|
...agentAttributes,
|
|
@@ -104,7 +173,21 @@ function traceGenAI(config) {
|
|
|
104
173
|
if (typeof handler !== "function") {
|
|
105
174
|
throw new TypeError("traceGenAI: factory must return a function; expected (ctx) => (...args) => result");
|
|
106
175
|
}
|
|
107
|
-
return
|
|
176
|
+
return async function(...args) {
|
|
177
|
+
const startedAt = Date.now();
|
|
178
|
+
try {
|
|
179
|
+
const result = await handler.call(this, ...args);
|
|
180
|
+
emitMetrics(seen, startedAt);
|
|
181
|
+
return result;
|
|
182
|
+
} catch (error) {
|
|
183
|
+
const errorType = error instanceof Error ? error.name || "Error" : "Error";
|
|
184
|
+
ctx.setAttribute("error.type", errorType);
|
|
185
|
+
emitMetrics(seen, startedAt);
|
|
186
|
+
throw error;
|
|
187
|
+
} finally {
|
|
188
|
+
unwatch();
|
|
189
|
+
}
|
|
190
|
+
};
|
|
108
191
|
});
|
|
109
192
|
};
|
|
110
193
|
}
|
package/dist/trace.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as TokenUsage, t as EstimateCostOptions } from "./cost-C1FkUNG1.cjs";
|
|
2
|
-
import { f as GenAiOperationName } from "./semconv-
|
|
3
|
-
import { a as GenAiResponseInput, i as GenAiRequestInput, l as GenAiWorkflowInput, n as GenAiAttributeMap, s as GenAiToolInput, t as GenAiAgentInput } from "./attributes-
|
|
2
|
+
import { f as GenAiOperationName } from "./semconv-B6zNvJ73.cjs";
|
|
3
|
+
import { a as GenAiResponseInput, i as GenAiRequestInput, l as GenAiWorkflowInput, n as GenAiAttributeMap, s as GenAiToolInput, t as GenAiAgentInput } from "./attributes-C7k871NW.cjs";
|
|
4
4
|
import { TraceContext } from "autotel";
|
|
5
5
|
//#region src/trace.d.ts
|
|
6
6
|
/** Configuration for {@link traceGenAI}. */
|
|
@@ -17,6 +17,12 @@ interface TraceGenAIConfig extends GenAiRequestInput {
|
|
|
17
17
|
spanName?: string;
|
|
18
18
|
/** Extra attributes to set on the span (any namespace). */
|
|
19
19
|
attributes?: GenAiAttributeMap;
|
|
20
|
+
/**
|
|
21
|
+
* Record the canonical GenAI metrics alongside the span. On by default, and
|
|
22
|
+
* a no-op without a registered `MeterProvider`. Set `false` when something
|
|
23
|
+
* upstream already emits `gen_ai.client.*` and you would double-count.
|
|
24
|
+
*/
|
|
25
|
+
metrics?: boolean;
|
|
20
26
|
}
|
|
21
27
|
/**
|
|
22
28
|
* Build a traced GenAI factory. Pass a factory `(ctx) => (...args) => result`;
|
package/dist/trace.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as TokenUsage, t as EstimateCostOptions } from "./cost-C1FkUNG1.js";
|
|
2
|
-
import { f as GenAiOperationName } from "./semconv-
|
|
3
|
-
import { a as GenAiResponseInput, i as GenAiRequestInput, l as GenAiWorkflowInput, n as GenAiAttributeMap, s as GenAiToolInput, t as GenAiAgentInput } from "./attributes-
|
|
2
|
+
import { f as GenAiOperationName } from "./semconv-B6zNvJ73.js";
|
|
3
|
+
import { a as GenAiResponseInput, i as GenAiRequestInput, l as GenAiWorkflowInput, n as GenAiAttributeMap, s as GenAiToolInput, t as GenAiAgentInput } from "./attributes-jUO1pbUc.js";
|
|
4
4
|
import { TraceContext } from "autotel";
|
|
5
5
|
//#region src/trace.d.ts
|
|
6
6
|
/** Configuration for {@link traceGenAI}. */
|
|
@@ -17,6 +17,12 @@ interface TraceGenAIConfig extends GenAiRequestInput {
|
|
|
17
17
|
spanName?: string;
|
|
18
18
|
/** Extra attributes to set on the span (any namespace). */
|
|
19
19
|
attributes?: GenAiAttributeMap;
|
|
20
|
+
/**
|
|
21
|
+
* Record the canonical GenAI metrics alongside the span. On by default, and
|
|
22
|
+
* a no-op without a registered `MeterProvider`. Set `false` when something
|
|
23
|
+
* upstream already emits `gen_ai.client.*` and you would double-count.
|
|
24
|
+
*/
|
|
25
|
+
metrics?: boolean;
|
|
20
26
|
}
|
|
21
27
|
/**
|
|
22
28
|
* Build a traced GenAI factory. Pass a factory `(ctx) => (...args) => result`;
|
package/dist/trace.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { GEN_AI_OPERATION, genAiSpanName } from "./semconv.js";
|
|
1
|
+
import { GEN_AI, GEN_AI_OPERATION, genAiSpanName } from "./semconv.js";
|
|
2
2
|
import { estimateLLMCost } from "./cost.js";
|
|
3
|
+
import { recordGenAiMetrics } from "./metrics.js";
|
|
3
4
|
import { c as genAiWorkflowAttributes, i as genAiResponseAttributes, o as genAiToolAttributes, r as genAiRequestAttributes, s as genAiUsageAttributes, t as genAiAgentAttributes } from "./attributes-DCv1cxKZ.js";
|
|
5
|
+
import { trace } from "@opentelemetry/api";
|
|
4
6
|
import { withTracing } from "autotel";
|
|
5
7
|
|
|
6
8
|
//#region src/trace.ts
|
|
@@ -38,6 +40,50 @@ import { withTracing } from "autotel";
|
|
|
38
40
|
* });
|
|
39
41
|
* ```
|
|
40
42
|
*/
|
|
43
|
+
/**
|
|
44
|
+
* What the metrics get to read: everything already on the span, overlaid with
|
|
45
|
+
* what the handler wrote through `ctx`.
|
|
46
|
+
*
|
|
47
|
+
* Neither alone is enough. `getActiveTraceContext()` hands out a *new* context
|
|
48
|
+
* object, so the documented ambient pattern
|
|
49
|
+
* (`getActiveTraceContext()?.setAttribute('gen_ai.usage.input_tokens', n)`) —
|
|
50
|
+
* and any helper that resolves the context itself — never passes through `ctx`.
|
|
51
|
+
* The span in turn holds nothing when sampling declined to record, and metrics
|
|
52
|
+
* are not sampled.
|
|
53
|
+
*/
|
|
54
|
+
function observed(seen) {
|
|
55
|
+
const span = trace.getActiveSpan();
|
|
56
|
+
return {
|
|
57
|
+
...span?.attributes,
|
|
58
|
+
...seen
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Record what is written through `ctx` into `seen`, and return the undo.
|
|
63
|
+
*
|
|
64
|
+
* The context is patched in place rather than wrapped: callers spread it
|
|
65
|
+
* (`logger.info({ ...ctx }, 'llm call')`), and a `Object.create(ctx)` wrapper
|
|
66
|
+
* spreads to nothing but the two overridden setters — no traceId, no spanId.
|
|
67
|
+
*/
|
|
68
|
+
function watchAttributes(ctx, seen) {
|
|
69
|
+
const { setAttribute, setAttributes } = ctx;
|
|
70
|
+
ctx.setAttribute = (key, value) => {
|
|
71
|
+
seen[key] = value;
|
|
72
|
+
setAttribute.call(ctx, key, value);
|
|
73
|
+
};
|
|
74
|
+
ctx.setAttributes = (attributes) => {
|
|
75
|
+
Object.assign(seen, attributes);
|
|
76
|
+
setAttributes.call(ctx, attributes);
|
|
77
|
+
};
|
|
78
|
+
return () => {
|
|
79
|
+
ctx.setAttribute = setAttribute;
|
|
80
|
+
ctx.setAttributes = setAttributes;
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/** Narrow an observed attribute to a number, ignoring anything else. */
|
|
84
|
+
function asNumber(value) {
|
|
85
|
+
return typeof value === "number" && Number.isFinite(value) ? value : undefined;
|
|
86
|
+
}
|
|
41
87
|
function defaultSpanIdentifier(config) {
|
|
42
88
|
switch (config.operation) {
|
|
43
89
|
case GEN_AI_OPERATION.RETRIEVAL: {
|
|
@@ -87,11 +133,34 @@ function traceGenAI(config) {
|
|
|
87
133
|
const agentAttributes = config.agent ? genAiAgentAttributes(config.agent, { internal: agentSpanIsInternal }) : {};
|
|
88
134
|
const toolAttributes = config.tool ? genAiToolAttributes(config.tool) : {};
|
|
89
135
|
const workflowAttributes = config.workflow ? genAiWorkflowAttributes(config.workflow) : {};
|
|
136
|
+
const emitMetrics = (watched, startedAt) => {
|
|
137
|
+
if (config.metrics === false) return;
|
|
138
|
+
const seen = observed(watched);
|
|
139
|
+
const attributes = { [GEN_AI.OPERATION_NAME]: operation };
|
|
140
|
+
if (config.provider) attributes[GEN_AI.PROVIDER_NAME] = config.provider;
|
|
141
|
+
if (config.model) attributes[GEN_AI.REQUEST_MODEL] = config.model;
|
|
142
|
+
const responseModel = seen[GEN_AI.RESPONSE_MODEL];
|
|
143
|
+
if (typeof responseModel === "string") {
|
|
144
|
+
attributes[GEN_AI.RESPONSE_MODEL] = responseModel;
|
|
145
|
+
}
|
|
146
|
+
const errorType = seen["error.type"];
|
|
147
|
+
if (typeof errorType === "string") attributes["error.type"] = errorType;
|
|
148
|
+
recordGenAiMetrics({
|
|
149
|
+
durationSeconds: (Date.now() - startedAt) / 1e3,
|
|
150
|
+
attributes,
|
|
151
|
+
inputTokens: asNumber(seen[GEN_AI.USAGE_INPUT_TOKENS]),
|
|
152
|
+
outputTokens: asNumber(seen[GEN_AI.USAGE_OUTPUT_TOKENS]),
|
|
153
|
+
costUsd: asNumber(seen[GEN_AI.USAGE_COST_USD]),
|
|
154
|
+
timeToFirstChunk: asNumber(seen[GEN_AI.RESPONSE_TIME_TO_FIRST_CHUNK])
|
|
155
|
+
});
|
|
156
|
+
};
|
|
90
157
|
return (factory) => {
|
|
91
158
|
if (typeof factory !== "function") {
|
|
92
159
|
throw new TypeError("traceGenAI: expected a factory (ctx) => (...args) => result");
|
|
93
160
|
}
|
|
94
161
|
return withTracing({ name: spanName })((ctx) => {
|
|
162
|
+
const seen = {};
|
|
163
|
+
const unwatch = config.metrics === false ? () => {} : watchAttributes(ctx, seen);
|
|
95
164
|
ctx.setAttributes({
|
|
96
165
|
...requestAttributes,
|
|
97
166
|
...agentAttributes,
|
|
@@ -103,7 +172,21 @@ function traceGenAI(config) {
|
|
|
103
172
|
if (typeof handler !== "function") {
|
|
104
173
|
throw new TypeError("traceGenAI: factory must return a function; expected (ctx) => (...args) => result");
|
|
105
174
|
}
|
|
106
|
-
return
|
|
175
|
+
return async function(...args) {
|
|
176
|
+
const startedAt = Date.now();
|
|
177
|
+
try {
|
|
178
|
+
const result = await handler.call(this, ...args);
|
|
179
|
+
emitMetrics(seen, startedAt);
|
|
180
|
+
return result;
|
|
181
|
+
} catch (error) {
|
|
182
|
+
const errorType = error instanceof Error ? error.name || "Error" : "Error";
|
|
183
|
+
ctx.setAttribute("error.type", errorType);
|
|
184
|
+
emitMetrics(seen, startedAt);
|
|
185
|
+
throw error;
|
|
186
|
+
} finally {
|
|
187
|
+
unwatch();
|
|
188
|
+
}
|
|
189
|
+
};
|
|
107
190
|
});
|
|
108
191
|
};
|
|
109
192
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "autotel-genai",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Gold-standard OpenTelemetry GenAI semantic-convention instrumentation for LLM calls, tools, and agents — cost, tokens, metrics, events, and agent governance.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -83,8 +83,8 @@
|
|
|
83
83
|
"author": "Jag Reehal <jag@jagreehal.com> (https://jagreehal.com)",
|
|
84
84
|
"license": "Apache-2.0",
|
|
85
85
|
"dependencies": {
|
|
86
|
-
"autotel": "6.
|
|
87
|
-
"autotel-audit": "0.4.
|
|
86
|
+
"autotel": "6.3.0",
|
|
87
|
+
"autotel-audit": "0.4.12"
|
|
88
88
|
},
|
|
89
89
|
"peerDependencies": {
|
|
90
90
|
"@opentelemetry/api": "*",
|