@datacules/agent-identity-otel 0.2.1

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.
Files changed (2) hide show
  1. package/README.md +58 -0
  2. package/package.json +40 -0
package/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # `@datacules/agent-identity-otel`
2
+
3
+ OpenTelemetry-native tracing for [`@datacules/agent-identity`](../../core). Auto-instruments every `resolve()`, `resolveAsync()`, and `resolvePair()` call with OTEL spans — zero changes to your existing routing code.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @datacules/agent-identity-otel @opentelemetry/api
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```typescript
14
+ import { createRouter } from '@datacules/agent-identity';
15
+ import { withOtel } from '@datacules/agent-identity-otel';
16
+ import { trace } from '@opentelemetry/api';
17
+
18
+ const baseRouter = createRouter(credentials, rules, logger);
19
+
20
+ // Wrap with OTEL — one line, zero config changes to your rules or credentials
21
+ const router = withOtel(baseRouter, {
22
+ tracer: trace.getTracer('agent-identity'),
23
+ });
24
+
25
+ // All resolve calls now emit spans automatically
26
+ const resolved = await router.resolveAsync(ctx);
27
+ ```
28
+
29
+ ## Span schema
30
+
31
+ | Span name | When |
32
+ |-----------|------|
33
+ | `agent-identity.resolve` | Synchronous resolve() |
34
+ | `agent-identity.resolve_async` | Async resolveAsync() (includes approval + budget checks) |
35
+ | `agent-identity.resolve_pair` | Migration pair resolvePair() |
36
+
37
+ ## Span attributes
38
+
39
+ | Attribute | Type | Description |
40
+ |-----------|------|-------------|
41
+ | `agent.user_id` | string | Calling user ID |
42
+ | `agent.provider` | string | AI provider |
43
+ | `agent.model` | string | Model name |
44
+ | `agent.action` | string | Action being performed |
45
+ | `credential.resource_id` | string | Target resource |
46
+ | `credential.resource_kind` | string | `shared` or `personal` |
47
+ | `credential.id` | string | Resolved credential ID |
48
+ | `credential.kind` | string | `fixed` or `user-delegated` |
49
+ | `routing.resolved` | boolean | Whether a credential matched |
50
+ | `routing.canary` | boolean | Whether the canary ref was selected |
51
+ | `routing.resolved_for` | string | `userId` or `service` |
52
+ | `trace.id` | string | Agent trace ID |
53
+ | `migration.id` | string | Migration ID (pair spans only) |
54
+ | `migration.phase` | string | Migration phase (pair spans only) |
55
+
56
+ ## Compatible backends
57
+
58
+ Works with any OTEL-compatible backend: Datadog APM, Honeycomb, Jaeger, AWS X-Ray, Google Cloud Trace.
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@datacules/agent-identity-otel",
3
+ "version": "0.2.1",
4
+ "private": false,
5
+ "description": "Zero-config OpenTelemetry tracing wrapper for @datacules/agent-identity",
6
+ "author": "Datacules LLC",
7
+ "license": "MIT",
8
+ "module": "./dist/esm/index.js",
9
+ "types": "./dist/types/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "import": "./dist/esm/index.js",
13
+ "types": "./dist/types/index.d.ts"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "README.md"
19
+ ],
20
+ "scripts": {
21
+ "build": "tsc -p tsconfig.build.json",
22
+ "type-check": "tsc --noEmit",
23
+ "lint": "eslint src --ext .ts"
24
+ },
25
+ "dependencies": {
26
+ "@datacules/agent-identity": "^0.1.0"
27
+ },
28
+ "peerDependencies": {
29
+ "@opentelemetry/api": ">=1.0.0"
30
+ },
31
+ "peerDependenciesMeta": {
32
+ "@opentelemetry/api": {
33
+ "optional": false
34
+ }
35
+ },
36
+ "devDependencies": {
37
+ "@opentelemetry/api": "^1.7.0",
38
+ "typescript": "^5"
39
+ }
40
+ }