observability-toolkit 1.8.4 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +126 -5
- package/dist/backends/index.d.ts +163 -0
- package/dist/backends/index.d.ts.map +1 -1
- package/dist/backends/index.js +57 -0
- package/dist/backends/index.js.map +1 -1
- package/dist/backends/index.test.js +55 -1
- package/dist/backends/index.test.js.map +1 -1
- package/dist/backends/local-jsonl-boolean-search.test.js +8 -8
- package/dist/backends/local-jsonl-boolean-search.test.js.map +1 -1
- package/dist/backends/local-jsonl-cache.test.d.ts +2 -0
- package/dist/backends/local-jsonl-cache.test.d.ts.map +1 -0
- package/dist/backends/local-jsonl-cache.test.js +295 -0
- package/dist/backends/local-jsonl-cache.test.js.map +1 -0
- package/dist/backends/local-jsonl-circuit-breaker.test.d.ts +2 -0
- package/dist/backends/local-jsonl-circuit-breaker.test.d.ts.map +1 -0
- package/dist/backends/local-jsonl-circuit-breaker.test.js +180 -0
- package/dist/backends/local-jsonl-circuit-breaker.test.js.map +1 -0
- package/dist/backends/local-jsonl-export.test.d.ts +2 -0
- package/dist/backends/local-jsonl-export.test.d.ts.map +1 -0
- package/dist/backends/local-jsonl-export.test.js +704 -0
- package/dist/backends/local-jsonl-export.test.js.map +1 -0
- package/dist/backends/local-jsonl-index.test.d.ts +2 -0
- package/dist/backends/local-jsonl-index.test.d.ts.map +1 -0
- package/dist/backends/local-jsonl-index.test.js +554 -0
- package/dist/backends/local-jsonl-index.test.js.map +1 -0
- package/dist/backends/local-jsonl-logs.test.js +52 -43
- package/dist/backends/local-jsonl-logs.test.js.map +1 -1
- package/dist/backends/local-jsonl-metrics.test.d.ts +2 -0
- package/dist/backends/local-jsonl-metrics.test.d.ts.map +1 -0
- package/dist/backends/local-jsonl-metrics.test.js +876 -0
- package/dist/backends/local-jsonl-metrics.test.js.map +1 -0
- package/dist/backends/local-jsonl-traces.test.js +89 -83
- package/dist/backends/local-jsonl-traces.test.js.map +1 -1
- package/dist/backends/local-jsonl.d.ts +39 -0
- package/dist/backends/local-jsonl.d.ts.map +1 -1
- package/dist/backends/local-jsonl.js +975 -492
- package/dist/backends/local-jsonl.js.map +1 -1
- package/dist/backends/signoz-api-circuit-breaker.test.d.ts +6 -0
- package/dist/backends/signoz-api-circuit-breaker.test.d.ts.map +1 -0
- package/dist/backends/signoz-api-circuit-breaker.test.js +548 -0
- package/dist/backends/signoz-api-circuit-breaker.test.js.map +1 -0
- package/dist/backends/signoz-api-rate-limiter.test.d.ts +6 -0
- package/dist/backends/signoz-api-rate-limiter.test.d.ts.map +1 -0
- package/dist/backends/signoz-api-rate-limiter.test.js +390 -0
- package/dist/backends/signoz-api-rate-limiter.test.js.map +1 -0
- package/dist/backends/signoz-api-ssrf.test.d.ts +6 -0
- package/dist/backends/signoz-api-ssrf.test.d.ts.map +1 -0
- package/dist/backends/signoz-api-ssrf.test.js +216 -0
- package/dist/backends/signoz-api-ssrf.test.js.map +1 -0
- package/dist/backends/signoz-api-test-helpers.d.ts +80 -0
- package/dist/backends/signoz-api-test-helpers.d.ts.map +1 -0
- package/dist/backends/signoz-api-test-helpers.js +79 -0
- package/dist/backends/signoz-api-test-helpers.js.map +1 -0
- package/dist/backends/signoz-api.d.ts +31 -1
- package/dist/backends/signoz-api.d.ts.map +1 -1
- package/dist/backends/signoz-api.js +717 -539
- package/dist/backends/signoz-api.js.map +1 -1
- package/dist/backends/signoz-api.test.d.ts +9 -0
- package/dist/backends/signoz-api.test.d.ts.map +1 -1
- package/dist/backends/signoz-api.test.js +20 -1032
- package/dist/backends/signoz-api.test.js.map +1 -1
- package/dist/lib/agent-as-judge.d.ts +388 -0
- package/dist/lib/agent-as-judge.d.ts.map +1 -0
- package/dist/lib/agent-as-judge.js +740 -0
- package/dist/lib/agent-as-judge.js.map +1 -0
- package/dist/lib/agent-as-judge.test.d.ts +5 -0
- package/dist/lib/agent-as-judge.test.d.ts.map +1 -0
- package/dist/lib/agent-as-judge.test.js +816 -0
- package/dist/lib/agent-as-judge.test.js.map +1 -0
- package/dist/lib/cache.d.ts +61 -2
- package/dist/lib/cache.d.ts.map +1 -1
- package/dist/lib/cache.js +54 -3
- package/dist/lib/cache.js.map +1 -1
- package/dist/lib/circuit-breaker.d.ts +101 -0
- package/dist/lib/circuit-breaker.d.ts.map +1 -0
- package/dist/lib/circuit-breaker.js +158 -0
- package/dist/lib/circuit-breaker.js.map +1 -0
- package/dist/lib/circuit-breaker.test.d.ts +2 -0
- package/dist/lib/circuit-breaker.test.d.ts.map +1 -0
- package/dist/lib/circuit-breaker.test.js +263 -0
- package/dist/lib/circuit-breaker.test.js.map +1 -0
- package/dist/lib/confident-export.d.ts +101 -0
- package/dist/lib/confident-export.d.ts.map +1 -0
- package/dist/lib/confident-export.js +393 -0
- package/dist/lib/confident-export.js.map +1 -0
- package/dist/lib/confident-export.test.d.ts +7 -0
- package/dist/lib/confident-export.test.d.ts.map +1 -0
- package/dist/lib/confident-export.test.js +835 -0
- package/dist/lib/confident-export.test.js.map +1 -0
- package/dist/lib/constants-symlink.test.d.ts +12 -0
- package/dist/lib/constants-symlink.test.d.ts.map +1 -0
- package/dist/lib/constants-symlink.test.js +357 -0
- package/dist/lib/constants-symlink.test.js.map +1 -0
- package/dist/lib/constants.d.ts +75 -0
- package/dist/lib/constants.d.ts.map +1 -1
- package/dist/lib/constants.js +104 -1
- package/dist/lib/constants.js.map +1 -1
- package/dist/lib/datadog-export.d.ts +156 -0
- package/dist/lib/datadog-export.d.ts.map +1 -0
- package/dist/lib/datadog-export.js +464 -0
- package/dist/lib/datadog-export.js.map +1 -0
- package/dist/lib/datadog-export.test.d.ts +14 -0
- package/dist/lib/datadog-export.test.d.ts.map +1 -0
- package/dist/lib/datadog-export.test.js +890 -0
- package/dist/lib/datadog-export.test.js.map +1 -0
- package/dist/lib/edge-cases.test.js +17 -17
- package/dist/lib/edge-cases.test.js.map +1 -1
- package/dist/lib/error-sanitizer.d.ts.map +1 -1
- package/dist/lib/error-sanitizer.js +29 -3
- package/dist/lib/error-sanitizer.js.map +1 -1
- package/dist/lib/error-sanitizer.test.js +159 -0
- package/dist/lib/error-sanitizer.test.js.map +1 -1
- package/dist/lib/error-types.d.ts +54 -0
- package/dist/lib/error-types.d.ts.map +1 -0
- package/dist/lib/error-types.js +154 -0
- package/dist/lib/error-types.js.map +1 -0
- package/dist/lib/error-types.test.d.ts +2 -0
- package/dist/lib/error-types.test.d.ts.map +1 -0
- package/dist/lib/error-types.test.js +196 -0
- package/dist/lib/error-types.test.js.map +1 -0
- package/dist/lib/evaluation-hooks.d.ts +49 -0
- package/dist/lib/evaluation-hooks.d.ts.map +1 -0
- package/dist/lib/evaluation-hooks.js +488 -0
- package/dist/lib/evaluation-hooks.js.map +1 -0
- package/dist/lib/evaluation-hooks.test.d.ts +8 -0
- package/dist/lib/evaluation-hooks.test.d.ts.map +1 -0
- package/dist/lib/evaluation-hooks.test.js +624 -0
- package/dist/lib/evaluation-hooks.test.js.map +1 -0
- package/dist/lib/export-utils.d.ts +99 -0
- package/dist/lib/export-utils.d.ts.map +1 -0
- package/dist/lib/export-utils.js +238 -0
- package/dist/lib/export-utils.js.map +1 -0
- package/dist/lib/export-utils.test.d.ts +5 -0
- package/dist/lib/export-utils.test.d.ts.map +1 -0
- package/dist/lib/export-utils.test.js +193 -0
- package/dist/lib/export-utils.test.js.map +1 -0
- package/dist/lib/file-utils.d.ts +17 -2
- package/dist/lib/file-utils.d.ts.map +1 -1
- package/dist/lib/file-utils.js +24 -5
- package/dist/lib/file-utils.js.map +1 -1
- package/dist/lib/file-utils.test.js +30 -0
- package/dist/lib/file-utils.test.js.map +1 -1
- package/dist/lib/histogram.d.ts +119 -0
- package/dist/lib/histogram.d.ts.map +1 -0
- package/dist/lib/histogram.js +202 -0
- package/dist/lib/histogram.js.map +1 -0
- package/dist/lib/histogram.test.d.ts +5 -0
- package/dist/lib/histogram.test.d.ts.map +1 -0
- package/dist/lib/histogram.test.js +381 -0
- package/dist/lib/histogram.test.js.map +1 -0
- package/dist/lib/indexer.test.js +27 -27
- package/dist/lib/indexer.test.js.map +1 -1
- package/dist/lib/input-validator.d.ts +12 -0
- package/dist/lib/input-validator.d.ts.map +1 -1
- package/dist/lib/input-validator.fuzz.test.d.ts +12 -0
- package/dist/lib/input-validator.fuzz.test.d.ts.map +1 -0
- package/dist/lib/input-validator.fuzz.test.js +290 -0
- package/dist/lib/input-validator.fuzz.test.js.map +1 -0
- package/dist/lib/input-validator.js +57 -3
- package/dist/lib/input-validator.js.map +1 -1
- package/dist/lib/input-validator.test.js +129 -1
- package/dist/lib/input-validator.test.js.map +1 -1
- package/dist/lib/instrumentation.d.ts +153 -0
- package/dist/lib/instrumentation.d.ts.map +1 -0
- package/dist/lib/instrumentation.integration.test.d.ts +2 -0
- package/dist/lib/instrumentation.integration.test.d.ts.map +1 -0
- package/dist/lib/instrumentation.integration.test.js +589 -0
- package/dist/lib/instrumentation.integration.test.js.map +1 -0
- package/dist/lib/instrumentation.js +520 -0
- package/dist/lib/instrumentation.js.map +1 -0
- package/dist/lib/instrumentation.test.d.ts +2 -0
- package/dist/lib/instrumentation.test.d.ts.map +1 -0
- package/dist/lib/instrumentation.test.js +821 -0
- package/dist/lib/instrumentation.test.js.map +1 -0
- package/dist/lib/langfuse-export.d.ts +125 -0
- package/dist/lib/langfuse-export.d.ts.map +1 -0
- package/dist/lib/langfuse-export.js +367 -0
- package/dist/lib/langfuse-export.js.map +1 -0
- package/dist/lib/langfuse-export.test.d.ts +7 -0
- package/dist/lib/langfuse-export.test.d.ts.map +1 -0
- package/dist/lib/langfuse-export.test.js +1007 -0
- package/dist/lib/langfuse-export.test.js.map +1 -0
- package/dist/lib/llm-as-judge.d.ts +657 -0
- package/dist/lib/llm-as-judge.d.ts.map +1 -0
- package/dist/lib/llm-as-judge.js +1397 -0
- package/dist/lib/llm-as-judge.js.map +1 -0
- package/dist/lib/llm-as-judge.test.d.ts +2 -0
- package/dist/lib/llm-as-judge.test.d.ts.map +1 -0
- package/dist/lib/llm-as-judge.test.js +2409 -0
- package/dist/lib/llm-as-judge.test.js.map +1 -0
- package/dist/lib/logger.d.ts +46 -0
- package/dist/lib/logger.d.ts.map +1 -0
- package/dist/lib/logger.js +81 -0
- package/dist/lib/logger.js.map +1 -0
- package/dist/lib/logger.test.d.ts +2 -0
- package/dist/lib/logger.test.d.ts.map +1 -0
- package/dist/lib/logger.test.js +122 -0
- package/dist/lib/logger.test.js.map +1 -0
- package/dist/lib/metrics.d.ts +62 -0
- package/dist/lib/metrics.d.ts.map +1 -0
- package/dist/lib/metrics.js +166 -0
- package/dist/lib/metrics.js.map +1 -0
- package/dist/lib/metrics.test.d.ts +5 -0
- package/dist/lib/metrics.test.d.ts.map +1 -0
- package/dist/lib/metrics.test.js +189 -0
- package/dist/lib/metrics.test.js.map +1 -0
- package/dist/lib/parse-stats.d.ts +119 -0
- package/dist/lib/parse-stats.d.ts.map +1 -0
- package/dist/lib/parse-stats.js +206 -0
- package/dist/lib/parse-stats.js.map +1 -0
- package/dist/lib/parse-stats.test.d.ts +5 -0
- package/dist/lib/parse-stats.test.d.ts.map +1 -0
- package/dist/lib/parse-stats.test.js +283 -0
- package/dist/lib/parse-stats.test.js.map +1 -0
- package/dist/lib/phoenix-export.d.ts +109 -0
- package/dist/lib/phoenix-export.d.ts.map +1 -0
- package/dist/lib/phoenix-export.js +429 -0
- package/dist/lib/phoenix-export.js.map +1 -0
- package/dist/lib/phoenix-export.test.d.ts +11 -0
- package/dist/lib/phoenix-export.test.d.ts.map +1 -0
- package/dist/lib/phoenix-export.test.js +725 -0
- package/dist/lib/phoenix-export.test.js.map +1 -0
- package/dist/lib/server-utils.d.ts +14 -1
- package/dist/lib/server-utils.d.ts.map +1 -1
- package/dist/lib/server-utils.js +43 -3
- package/dist/lib/server-utils.js.map +1 -1
- package/dist/lib/shared-schemas.d.ts +28 -0
- package/dist/lib/shared-schemas.d.ts.map +1 -1
- package/dist/lib/shared-schemas.js +33 -4
- package/dist/lib/shared-schemas.js.map +1 -1
- package/dist/lib/toon-encoder.d.ts +7 -2
- package/dist/lib/toon-encoder.d.ts.map +1 -1
- package/dist/lib/toon-encoder.js +21 -6
- package/dist/lib/toon-encoder.js.map +1 -1
- package/dist/lib/toon-encoder.test.d.ts +5 -0
- package/dist/lib/toon-encoder.test.d.ts.map +1 -0
- package/dist/lib/toon-encoder.test.js +85 -0
- package/dist/lib/toon-encoder.test.js.map +1 -0
- package/dist/lib/verification-events.d.ts +100 -0
- package/dist/lib/verification-events.d.ts.map +1 -0
- package/dist/lib/verification-events.js +162 -0
- package/dist/lib/verification-events.js.map +1 -0
- package/dist/lib/verification-events.test.d.ts +5 -0
- package/dist/lib/verification-events.test.d.ts.map +1 -0
- package/dist/lib/verification-events.test.js +193 -0
- package/dist/lib/verification-events.test.js.map +1 -0
- package/dist/server.d.ts +5 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +79 -21
- package/dist/server.js.map +1 -1
- package/dist/server.test.js +30 -0
- package/dist/server.test.js.map +1 -1
- package/dist/test-helpers/env-utils.d.ts +22 -0
- package/dist/test-helpers/env-utils.d.ts.map +1 -1
- package/dist/test-helpers/env-utils.js +38 -0
- package/dist/test-helpers/env-utils.js.map +1 -1
- package/dist/test-helpers/fuzz-generators.d.ts +58 -0
- package/dist/test-helpers/fuzz-generators.d.ts.map +1 -0
- package/dist/test-helpers/fuzz-generators.js +216 -0
- package/dist/test-helpers/fuzz-generators.js.map +1 -0
- package/dist/test-helpers/index.d.ts +1 -0
- package/dist/test-helpers/index.d.ts.map +1 -1
- package/dist/test-helpers/index.js +2 -0
- package/dist/test-helpers/index.js.map +1 -1
- package/dist/test-helpers/memfs-utils.d.ts +181 -0
- package/dist/test-helpers/memfs-utils.d.ts.map +1 -0
- package/dist/test-helpers/memfs-utils.js +292 -0
- package/dist/test-helpers/memfs-utils.js.map +1 -0
- package/dist/test-helpers/memfs-utils.test.d.ts +5 -0
- package/dist/test-helpers/memfs-utils.test.d.ts.map +1 -0
- package/dist/test-helpers/memfs-utils.test.js +338 -0
- package/dist/test-helpers/memfs-utils.test.js.map +1 -0
- package/dist/test-helpers/race-condition-helpers.d.ts +85 -0
- package/dist/test-helpers/race-condition-helpers.d.ts.map +1 -0
- package/dist/test-helpers/race-condition-helpers.js +279 -0
- package/dist/test-helpers/race-condition-helpers.js.map +1 -0
- package/dist/test-helpers/test-data-builders.d.ts +40 -3
- package/dist/test-helpers/test-data-builders.d.ts.map +1 -1
- package/dist/test-helpers/test-data-builders.js +54 -5
- package/dist/test-helpers/test-data-builders.js.map +1 -1
- package/dist/test-helpers/tool-validators.d.ts.map +1 -1
- package/dist/test-helpers/tool-validators.js +16 -1
- package/dist/test-helpers/tool-validators.js.map +1 -1
- package/dist/tools/context-stats.d.ts.map +1 -1
- package/dist/tools/context-stats.js +6 -8
- package/dist/tools/context-stats.js.map +1 -1
- package/dist/tools/export-confident.d.ts +145 -0
- package/dist/tools/export-confident.d.ts.map +1 -0
- package/dist/tools/export-confident.js +134 -0
- package/dist/tools/export-confident.js.map +1 -0
- package/dist/tools/export-confident.test.d.ts +7 -0
- package/dist/tools/export-confident.test.d.ts.map +1 -0
- package/dist/tools/export-confident.test.js +332 -0
- package/dist/tools/export-confident.test.js.map +1 -0
- package/dist/tools/export-datadog.d.ts +160 -0
- package/dist/tools/export-datadog.d.ts.map +1 -0
- package/dist/tools/export-datadog.js +160 -0
- package/dist/tools/export-datadog.js.map +1 -0
- package/dist/tools/export-datadog.test.d.ts +8 -0
- package/dist/tools/export-datadog.test.d.ts.map +1 -0
- package/dist/tools/export-datadog.test.js +419 -0
- package/dist/tools/export-datadog.test.js.map +1 -0
- package/dist/tools/export-langfuse.d.ts +137 -0
- package/dist/tools/export-langfuse.d.ts.map +1 -0
- package/dist/tools/export-langfuse.js +131 -0
- package/dist/tools/export-langfuse.js.map +1 -0
- package/dist/tools/export-langfuse.test.d.ts +7 -0
- package/dist/tools/export-langfuse.test.d.ts.map +1 -0
- package/dist/tools/export-langfuse.test.js +303 -0
- package/dist/tools/export-langfuse.test.js.map +1 -0
- package/dist/tools/export-phoenix.d.ts +145 -0
- package/dist/tools/export-phoenix.d.ts.map +1 -0
- package/dist/tools/export-phoenix.js +135 -0
- package/dist/tools/export-phoenix.js.map +1 -0
- package/dist/tools/export-phoenix.test.d.ts +7 -0
- package/dist/tools/export-phoenix.test.d.ts.map +1 -0
- package/dist/tools/export-phoenix.test.js +316 -0
- package/dist/tools/export-phoenix.test.js.map +1 -0
- package/dist/tools/health-check.d.ts +26 -0
- package/dist/tools/health-check.d.ts.map +1 -1
- package/dist/tools/health-check.js +36 -7
- package/dist/tools/health-check.js.map +1 -1
- package/dist/tools/index.d.ts +6 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +6 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/inject-evaluations.d.ts +1315 -0
- package/dist/tools/inject-evaluations.d.ts.map +1 -0
- package/dist/tools/inject-evaluations.js +121 -0
- package/dist/tools/inject-evaluations.js.map +1 -0
- package/dist/tools/inject-evaluations.test.d.ts +5 -0
- package/dist/tools/inject-evaluations.test.d.ts.map +1 -0
- package/dist/tools/inject-evaluations.test.js +359 -0
- package/dist/tools/inject-evaluations.test.js.map +1 -0
- package/dist/tools/query-evaluations.d.ts +25 -4
- package/dist/tools/query-evaluations.d.ts.map +1 -1
- package/dist/tools/query-evaluations.js +26 -2
- package/dist/tools/query-evaluations.js.map +1 -1
- package/dist/tools/query-evaluations.test.js +53 -46
- package/dist/tools/query-evaluations.test.js.map +1 -1
- package/dist/tools/query-llm-events.js +2 -2
- package/dist/tools/query-llm-events.js.map +1 -1
- package/dist/tools/query-llm-events.test.js +6 -3
- package/dist/tools/query-llm-events.test.js.map +1 -1
- package/dist/tools/query-logs.d.ts +8 -8
- package/dist/tools/query-logs.js +3 -3
- package/dist/tools/query-logs.js.map +1 -1
- package/dist/tools/query-metrics.d.ts +4 -4
- package/dist/tools/query-metrics.js +2 -2
- package/dist/tools/query-metrics.js.map +1 -1
- package/dist/tools/query-traces.d.ts +8 -8
- package/dist/tools/query-verifications.d.ts +111 -0
- package/dist/tools/query-verifications.d.ts.map +1 -0
- package/dist/tools/query-verifications.js +101 -0
- package/dist/tools/query-verifications.js.map +1 -0
- package/dist/tools/query-verifications.test.d.ts +5 -0
- package/dist/tools/query-verifications.test.d.ts.map +1 -0
- package/dist/tools/query-verifications.test.js +156 -0
- package/dist/tools/query-verifications.test.js.map +1 -0
- package/dist/types/evaluation-hooks.d.ts +176 -0
- package/dist/types/evaluation-hooks.d.ts.map +1 -0
- package/dist/types/evaluation-hooks.js +49 -0
- package/dist/types/evaluation-hooks.js.map +1 -0
- package/package.json +11 -2
|
@@ -2,7 +2,8 @@ import { describe, it, before, after, beforeEach } from 'node:test';
|
|
|
2
2
|
import * as assert from 'node:assert';
|
|
3
3
|
import * as path from 'path';
|
|
4
4
|
import { LocalJsonlBackend } from './local-jsonl.js';
|
|
5
|
-
import { getSharedTempDir, clearTempDir, removeSharedTempDir,
|
|
5
|
+
import { getSharedTempDir, clearTempDir, removeSharedTempDir, writeJsonlFileAsync, getTestDate } from '../test-helpers/file-utils.js';
|
|
6
|
+
import { createMockSpan, createMockSpans, createDbSpan, resetBuilderCounters, } from '../test-helpers/test-data-builders.js';
|
|
6
7
|
describe('LocalJsonlBackend', () => {
|
|
7
8
|
let tempDir;
|
|
8
9
|
let backend;
|
|
@@ -30,7 +31,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
30
31
|
attributes: { 'custom.attr': 'value1' },
|
|
31
32
|
},
|
|
32
33
|
];
|
|
33
|
-
|
|
34
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
34
35
|
const results = await backend.queryTraces({});
|
|
35
36
|
assert.strictEqual(results.length, 1);
|
|
36
37
|
assert.strictEqual(results[0].traceId, 'trace1');
|
|
@@ -42,24 +43,28 @@ describe('LocalJsonlBackend', () => {
|
|
|
42
43
|
});
|
|
43
44
|
it('should filter spans by traceId', async () => {
|
|
44
45
|
const today = getTestDate();
|
|
46
|
+
resetBuilderCounters();
|
|
47
|
+
// Use createMockSpan with explicit traceId overrides
|
|
45
48
|
const mockSpans = [
|
|
46
|
-
{ traceId: 'trace1', spanId: 'span1', name: 'op1'
|
|
47
|
-
{ traceId: 'trace2', spanId: 'span2', name: 'op2'
|
|
48
|
-
{ traceId: 'trace1', spanId: 'span3', name: 'op3'
|
|
49
|
+
createMockSpan({ traceId: 'trace1', spanId: 'span1', name: 'op1' }),
|
|
50
|
+
createMockSpan({ traceId: 'trace2', spanId: 'span2', name: 'op2' }),
|
|
51
|
+
createMockSpan({ traceId: 'trace1', spanId: 'span3', name: 'op3' }),
|
|
49
52
|
];
|
|
50
|
-
|
|
53
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
51
54
|
const results = await backend.queryTraces({ traceId: 'trace1' });
|
|
52
55
|
assert.strictEqual(results.length, 2);
|
|
53
56
|
assert.ok(results.every(s => s.traceId === 'trace1'));
|
|
54
57
|
});
|
|
55
58
|
it('should filter spans by spanName substring', async () => {
|
|
56
59
|
const today = getTestDate();
|
|
60
|
+
resetBuilderCounters();
|
|
61
|
+
// Use createMockSpan for simple spans with specific names
|
|
57
62
|
const mockSpans = [
|
|
58
|
-
{ traceId: 'trace1',
|
|
59
|
-
{ traceId: 'trace1',
|
|
60
|
-
|
|
63
|
+
createMockSpan({ traceId: 'trace1', name: 'user-create' }),
|
|
64
|
+
createMockSpan({ traceId: 'trace1', name: 'user-update' }),
|
|
65
|
+
createDbSpan('query', 'postgres', { traceId: 'trace1' }),
|
|
61
66
|
];
|
|
62
|
-
|
|
67
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
63
68
|
const results = await backend.queryTraces({ spanName: 'user' });
|
|
64
69
|
assert.strictEqual(results.length, 2);
|
|
65
70
|
assert.ok(results.every(s => s.name.includes('user')));
|
|
@@ -89,7 +94,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
89
94
|
endTime: [1700000010, 0], // 10s
|
|
90
95
|
},
|
|
91
96
|
];
|
|
92
|
-
|
|
97
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
93
98
|
const results = await backend.queryTraces({ minDurationMs: 1000, maxDurationMs: 5000 });
|
|
94
99
|
assert.strictEqual(results.length, 1);
|
|
95
100
|
assert.strictEqual(results[0].name, 'medium-op');
|
|
@@ -112,20 +117,21 @@ describe('LocalJsonlBackend', () => {
|
|
|
112
117
|
resource: { serviceName: 'service-b' },
|
|
113
118
|
},
|
|
114
119
|
];
|
|
115
|
-
|
|
120
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
116
121
|
const results = await backend.queryTraces({ serviceName: 'service-a' });
|
|
117
122
|
assert.strictEqual(results.length, 1);
|
|
118
123
|
assert.strictEqual(results[0].attributes?.['service.name'], 'service-a');
|
|
119
124
|
});
|
|
120
125
|
it('should apply limit and offset to results', async () => {
|
|
121
126
|
const today = getTestDate();
|
|
122
|
-
|
|
127
|
+
resetBuilderCounters();
|
|
128
|
+
// Use createMockSpans with dynamic overrides for indexed data
|
|
129
|
+
const mockSpans = createMockSpans(150, (i) => ({
|
|
123
130
|
traceId: `trace${i}`,
|
|
124
131
|
spanId: `span${i}`,
|
|
125
132
|
name: `op${i}`,
|
|
126
|
-
startTime: [1700000000, 0],
|
|
127
133
|
}));
|
|
128
|
-
|
|
134
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
129
135
|
const results = await backend.queryTraces({ limit: 50, offset: 25 });
|
|
130
136
|
assert.strictEqual(results.length, 50);
|
|
131
137
|
assert.strictEqual(results[0].traceId, 'trace25');
|
|
@@ -138,7 +144,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
138
144
|
{ spanId: 'span3', name: 'op3', startTime: [1700000000, 0] }, // missing traceId
|
|
139
145
|
{ traceId: 'trace4', name: 'op4', startTime: [1700000000, 0] }, // missing spanId
|
|
140
146
|
];
|
|
141
|
-
|
|
147
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
142
148
|
const results = await backend.queryTraces({});
|
|
143
149
|
assert.strictEqual(results.length, 1);
|
|
144
150
|
assert.strictEqual(results[0].traceId, 'trace1');
|
|
@@ -154,7 +160,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
154
160
|
duration: [2, 500000000], // 2.5 seconds
|
|
155
161
|
},
|
|
156
162
|
];
|
|
157
|
-
|
|
163
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
158
164
|
const results = await backend.queryTraces({});
|
|
159
165
|
assert.strictEqual(results.length, 1);
|
|
160
166
|
assert.strictEqual(results[0].durationMs, 2500);
|
|
@@ -166,7 +172,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
166
172
|
{ traceId: 'trace2', spanId: 'span2', name: 'op2', kind: 1, startTime: [1700000000, 0] },
|
|
167
173
|
{ traceId: 'trace3', spanId: 'span3', name: 'op3', kind: 2, startTime: [1700000000, 0] },
|
|
168
174
|
];
|
|
169
|
-
|
|
175
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
170
176
|
const results = await backend.queryTraces({});
|
|
171
177
|
assert.strictEqual(results[0].kind, 'INTERNAL');
|
|
172
178
|
assert.strictEqual(results[1].kind, 'SERVER');
|
|
@@ -179,7 +185,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
179
185
|
{ traceId: 'trace2', spanId: 'span2', name: 'op2', startTime: [1700000000, 0], status: { code: 1 } },
|
|
180
186
|
{ traceId: 'trace3', spanId: 'span3', name: 'op3', startTime: [1700000000, 0], status: { code: 2, message: 'Test error' } },
|
|
181
187
|
];
|
|
182
|
-
|
|
188
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
183
189
|
const results = await backend.queryTraces({});
|
|
184
190
|
assert.strictEqual(results[0].statusCode, 'UNSET');
|
|
185
191
|
assert.strictEqual(results[0].status?.code, 0);
|
|
@@ -194,7 +200,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
194
200
|
const mockSpans = [
|
|
195
201
|
{ traceId: 'trace1', spanId: 'span1', name: 'op1', startTime: [1700000000, 0] },
|
|
196
202
|
];
|
|
197
|
-
|
|
203
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
198
204
|
const results = await backend.queryTraces({});
|
|
199
205
|
assert.strictEqual(results[0].statusCode, undefined);
|
|
200
206
|
assert.strictEqual(results[0].status, undefined);
|
|
@@ -229,7 +235,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
229
235
|
startTime: [1700000000, 0],
|
|
230
236
|
},
|
|
231
237
|
];
|
|
232
|
-
|
|
238
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
233
239
|
const results = await backend.queryTraces({});
|
|
234
240
|
assert.strictEqual(results.length, 3);
|
|
235
241
|
// First span: full scope
|
|
@@ -279,7 +285,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
279
285
|
startTime: [1700000000, 0],
|
|
280
286
|
},
|
|
281
287
|
];
|
|
282
|
-
|
|
288
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
283
289
|
const results = await backend.queryTraces({});
|
|
284
290
|
assert.strictEqual(results.length, 3);
|
|
285
291
|
// First span: multiple links
|
|
@@ -322,7 +328,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
322
328
|
],
|
|
323
329
|
},
|
|
324
330
|
];
|
|
325
|
-
|
|
331
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
326
332
|
const results = await backend.queryTraces({});
|
|
327
333
|
assert.strictEqual(results.length, 1);
|
|
328
334
|
// Only the valid link should be included
|
|
@@ -344,7 +350,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
344
350
|
],
|
|
345
351
|
},
|
|
346
352
|
];
|
|
347
|
-
|
|
353
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
348
354
|
const results = await backend.queryTraces({});
|
|
349
355
|
assert.strictEqual(results.length, 1);
|
|
350
356
|
assert.strictEqual(results[0].links, undefined);
|
|
@@ -379,7 +385,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
379
385
|
attributes: { 'hook.name': 'post-tool', 'mcp.server': 'webresearch' },
|
|
380
386
|
},
|
|
381
387
|
];
|
|
382
|
-
|
|
388
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
383
389
|
const results = await backend.queryTraces({
|
|
384
390
|
attributeFilter: { 'hook.name': 'session-start' },
|
|
385
391
|
});
|
|
@@ -411,7 +417,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
411
417
|
attributes: { 'mcp.server': 'webresearch', 'mcp.success': true },
|
|
412
418
|
},
|
|
413
419
|
];
|
|
414
|
-
|
|
420
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
415
421
|
const results = await backend.queryTraces({
|
|
416
422
|
attributeFilter: { 'mcp.server': 'signoz', 'mcp.success': true },
|
|
417
423
|
});
|
|
@@ -436,7 +442,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
436
442
|
attributes: { 'http.status_code': 500 },
|
|
437
443
|
},
|
|
438
444
|
];
|
|
439
|
-
|
|
445
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
440
446
|
const results = await backend.queryTraces({
|
|
441
447
|
attributeFilter: { 'http.status_code': 200 },
|
|
442
448
|
});
|
|
@@ -461,7 +467,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
461
467
|
attributes: { 'agent.is_background': false },
|
|
462
468
|
},
|
|
463
469
|
];
|
|
464
|
-
|
|
470
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
465
471
|
const results = await backend.queryTraces({
|
|
466
472
|
attributeFilter: { 'agent.is_background': false },
|
|
467
473
|
});
|
|
@@ -479,7 +485,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
479
485
|
attributes: { 'hook.name': 'session-start' },
|
|
480
486
|
},
|
|
481
487
|
];
|
|
482
|
-
|
|
488
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
483
489
|
const results = await backend.queryTraces({
|
|
484
490
|
attributeFilter: { 'hook.name': 'nonexistent' },
|
|
485
491
|
});
|
|
@@ -513,7 +519,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
513
519
|
attributes: { 'mcp.server': 'webresearch' },
|
|
514
520
|
},
|
|
515
521
|
];
|
|
516
|
-
|
|
522
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
517
523
|
const results = await backend.queryTraces({
|
|
518
524
|
spanName: 'mcp',
|
|
519
525
|
minDurationMs: 1000,
|
|
@@ -529,7 +535,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
529
535
|
{ traceId: 'trace2', spanId: 'span2', name: 'db-query', startTime: [1700000000, 0] },
|
|
530
536
|
{ traceId: 'trace3', spanId: 'span3', name: 'http-response', startTime: [1700000000, 0] },
|
|
531
537
|
];
|
|
532
|
-
|
|
538
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
533
539
|
const results = await backend.queryTraces({ excludeSpanName: 'http' });
|
|
534
540
|
assert.strictEqual(results.length, 1);
|
|
535
541
|
assert.strictEqual(results[0].name, 'db-query');
|
|
@@ -542,7 +548,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
542
548
|
{ traceId: 'trace3', spanId: 'span3', name: 'mcp-call', startTime: [1700000000, 0] },
|
|
543
549
|
{ traceId: 'trace4', spanId: 'span4', name: 'hook:pre-tool', startTime: [1700000000, 0] },
|
|
544
550
|
];
|
|
545
|
-
|
|
551
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
546
552
|
// Match spans starting with 'hook:session'
|
|
547
553
|
const results = await backend.queryTraces({ spanNameRegex: '^hook:session' });
|
|
548
554
|
assert.strictEqual(results.length, 2);
|
|
@@ -557,7 +563,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
557
563
|
{ traceId: 'trace3', spanId: 'span3', name: 'api-v1-orders-post', startTime: [1700000000, 0] },
|
|
558
564
|
{ traceId: 'trace4', spanId: 'span4', name: 'internal-process', startTime: [1700000000, 0] },
|
|
559
565
|
];
|
|
560
|
-
|
|
566
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
561
567
|
// Match spans with api-v[12]-.*-get pattern
|
|
562
568
|
const results = await backend.queryTraces({ spanNameRegex: 'api-v[12]-.*-get' });
|
|
563
569
|
assert.strictEqual(results.length, 2);
|
|
@@ -569,7 +575,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
569
575
|
const mockSpans = [
|
|
570
576
|
{ traceId: 'trace1', spanId: 'span1', name: 'test-span', startTime: [1700000000, 0] },
|
|
571
577
|
];
|
|
572
|
-
|
|
578
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
573
579
|
// Invalid regex pattern - should be skipped (all spans returned)
|
|
574
580
|
const results = await backend.queryTraces({ spanNameRegex: '[invalid(' });
|
|
575
581
|
// Invalid regex is skipped, so all spans should be returned
|
|
@@ -584,7 +590,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
584
590
|
{ traceId: 'trace3', spanId: 'span3', name: 'hook:session-start', startTime: [1700000000, 0] },
|
|
585
591
|
{ traceId: 'trace4', spanId: 'span4', name: 'mcp-call', startTime: [1700000000, 0] },
|
|
586
592
|
];
|
|
587
|
-
|
|
593
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
588
594
|
// spanName filters first (substring), then regex narrows down
|
|
589
595
|
const results = await backend.queryTraces({
|
|
590
596
|
spanName: 'hook',
|
|
@@ -601,7 +607,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
601
607
|
{ traceId: 'trace2', spanId: 'span2', name: 'hook:mcp-post-tool', startTime: [1700000000, 0] },
|
|
602
608
|
{ traceId: 'trace3', spanId: 'span3', name: 'hook:session-start', startTime: [1700000000, 0] },
|
|
603
609
|
];
|
|
604
|
-
|
|
610
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
605
611
|
// Regex matches all hook:mcp-*, exclude post-tool
|
|
606
612
|
const results = await backend.queryTraces({
|
|
607
613
|
spanNameRegex: '^hook:mcp-',
|
|
@@ -635,7 +641,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
635
641
|
attributes: { 'db.system': 'postgres' }, // missing both
|
|
636
642
|
},
|
|
637
643
|
];
|
|
638
|
-
|
|
644
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
639
645
|
const results = await backend.queryTraces({
|
|
640
646
|
attributeExists: ['http.method', 'http.status_code'],
|
|
641
647
|
});
|
|
@@ -667,7 +673,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
667
673
|
attributes: { 'http.method': 'GET', 'error.type': 'network' },
|
|
668
674
|
},
|
|
669
675
|
];
|
|
670
|
-
|
|
676
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
671
677
|
const results = await backend.queryTraces({
|
|
672
678
|
attributeNotExists: ['error.message', 'error.type'],
|
|
673
679
|
});
|
|
@@ -681,7 +687,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
681
687
|
{ traceId: 'trace2', spanId: 'span2', name: 'http-request-internal', startTime: [1700000000, 0] },
|
|
682
688
|
{ traceId: 'trace3', spanId: 'span3', name: 'db-query', startTime: [1700000000, 0] },
|
|
683
689
|
];
|
|
684
|
-
|
|
690
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
685
691
|
const results = await backend.queryTraces({
|
|
686
692
|
spanName: 'http',
|
|
687
693
|
excludeSpanName: 'internal',
|
|
@@ -714,7 +720,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
714
720
|
attributes: { 'http.method': 'GET' }, // missing status_code
|
|
715
721
|
},
|
|
716
722
|
];
|
|
717
|
-
|
|
723
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
718
724
|
const results = await backend.queryTraces({
|
|
719
725
|
attributeFilter: { 'http.method': 'GET' },
|
|
720
726
|
attributeExists: ['http.status_code'],
|
|
@@ -747,7 +753,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
747
753
|
attributes: { 'http.status_code': 300 },
|
|
748
754
|
},
|
|
749
755
|
];
|
|
750
|
-
|
|
756
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
751
757
|
const results = await backend.queryTraces({
|
|
752
758
|
numericFilter: [{ attribute: 'http.status_code', operator: 'gt', value: 299 }],
|
|
753
759
|
});
|
|
@@ -773,7 +779,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
773
779
|
attributes: { 'http.status_code': 300 },
|
|
774
780
|
},
|
|
775
781
|
];
|
|
776
|
-
|
|
782
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
777
783
|
const results = await backend.queryTraces({
|
|
778
784
|
numericFilter: [{ attribute: 'http.status_code', operator: 'gte', value: 300 }],
|
|
779
785
|
});
|
|
@@ -798,7 +804,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
798
804
|
attributes: { 'http.status_code': 500 },
|
|
799
805
|
},
|
|
800
806
|
];
|
|
801
|
-
|
|
807
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
802
808
|
const results = await backend.queryTraces({
|
|
803
809
|
numericFilter: [{ attribute: 'http.status_code', operator: 'lt', value: 300 }],
|
|
804
810
|
});
|
|
@@ -823,7 +829,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
823
829
|
attributes: { 'http.status_code': 300 },
|
|
824
830
|
},
|
|
825
831
|
];
|
|
826
|
-
|
|
832
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
827
833
|
const results = await backend.queryTraces({
|
|
828
834
|
numericFilter: [{ attribute: 'http.status_code', operator: 'lte', value: 200 }],
|
|
829
835
|
});
|
|
@@ -848,7 +854,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
848
854
|
attributes: { 'http.status_code': 500 },
|
|
849
855
|
},
|
|
850
856
|
];
|
|
851
|
-
|
|
857
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
852
858
|
const results = await backend.queryTraces({
|
|
853
859
|
numericFilter: [{ attribute: 'http.status_code', operator: 'eq', value: 200 }],
|
|
854
860
|
});
|
|
@@ -880,7 +886,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
880
886
|
attributes: { 'http.status_code': 500, 'http.response_size': 100 },
|
|
881
887
|
},
|
|
882
888
|
];
|
|
883
|
-
|
|
889
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
884
890
|
const results = await backend.queryTraces({
|
|
885
891
|
numericFilter: [
|
|
886
892
|
{ attribute: 'http.status_code', operator: 'lt', value: 300 },
|
|
@@ -908,7 +914,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
908
914
|
attributes: { 'other.attr': 'value' }, // missing http.status_code
|
|
909
915
|
},
|
|
910
916
|
];
|
|
911
|
-
|
|
917
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
912
918
|
const results = await backend.queryTraces({
|
|
913
919
|
numericFilter: [{ attribute: 'http.status_code', operator: 'gte', value: 100 }],
|
|
914
920
|
});
|
|
@@ -933,7 +939,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
933
939
|
attributes: { 'http.status_code': '200' }, // string, not number
|
|
934
940
|
},
|
|
935
941
|
];
|
|
936
|
-
|
|
942
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
937
943
|
const results = await backend.queryTraces({
|
|
938
944
|
numericFilter: [{ attribute: 'http.status_code', operator: 'eq', value: 200 }],
|
|
939
945
|
});
|
|
@@ -965,7 +971,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
965
971
|
attributes: { 'http.status_code': 200, 'http.method': 'GET' },
|
|
966
972
|
},
|
|
967
973
|
];
|
|
968
|
-
|
|
974
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
969
975
|
const results = await backend.queryTraces({
|
|
970
976
|
attributeFilter: { 'http.method': 'GET' },
|
|
971
977
|
numericFilter: [{ attribute: 'http.status_code', operator: 'gte', value: 400 }],
|
|
@@ -981,7 +987,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
981
987
|
{ traceId: 'trace1', spanId: 'span1', name: 'op1', startTime: [1700000000, 0] },
|
|
982
988
|
{ traceId: 'trace2', spanId: 'span2', name: 'op2', startTime: [1700000001, 0] },
|
|
983
989
|
];
|
|
984
|
-
|
|
990
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
985
991
|
// Query should complete successfully with timing active
|
|
986
992
|
const results = await backend.queryTraces({});
|
|
987
993
|
assert.strictEqual(results.length, 2);
|
|
@@ -1004,7 +1010,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
1004
1010
|
},
|
|
1005
1011
|
},
|
|
1006
1012
|
];
|
|
1007
|
-
|
|
1013
|
+
await writeJsonlFileAsync(path.join(tempDir, `llm-events-${today}.jsonl`), mockEvents);
|
|
1008
1014
|
const results = await backend.queryLLMEvents({});
|
|
1009
1015
|
assert.strictEqual(results.length, 1);
|
|
1010
1016
|
assert.strictEqual(results[0].name, 'llm.completion');
|
|
@@ -1019,7 +1025,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
1019
1025
|
{ timestamp: '2026-01-28T10:01:00Z', name: 'llm.embedding', attributes: {} },
|
|
1020
1026
|
{ timestamp: '2026-01-28T10:02:00Z', name: 'tool.execution', attributes: {} },
|
|
1021
1027
|
];
|
|
1022
|
-
|
|
1028
|
+
await writeJsonlFileAsync(path.join(tempDir, `llm-events-${today}.jsonl`), mockEvents);
|
|
1023
1029
|
const results = await backend.queryLLMEvents({ eventName: 'llm' });
|
|
1024
1030
|
assert.strictEqual(results.length, 2);
|
|
1025
1031
|
assert.ok(results.every(e => e.name.includes('llm')));
|
|
@@ -1043,7 +1049,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
1043
1049
|
attributes: { model: 'claude-3-opus' }, // alternate attribute name
|
|
1044
1050
|
},
|
|
1045
1051
|
];
|
|
1046
|
-
|
|
1052
|
+
await writeJsonlFileAsync(path.join(tempDir, `llm-events-${today}.jsonl`), mockEvents);
|
|
1047
1053
|
const results = await backend.queryLLMEvents({ model: 'claude-3-opus' });
|
|
1048
1054
|
assert.strictEqual(results.length, 2);
|
|
1049
1055
|
});
|
|
@@ -1066,7 +1072,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
1066
1072
|
attributes: { provider: 'anthropic' }, // alternate attribute name
|
|
1067
1073
|
},
|
|
1068
1074
|
];
|
|
1069
|
-
|
|
1075
|
+
await writeJsonlFileAsync(path.join(tempDir, `llm-events-${today}.jsonl`), mockEvents);
|
|
1070
1076
|
const results = await backend.queryLLMEvents({ provider: 'anthropic' });
|
|
1071
1077
|
assert.strictEqual(results.length, 2);
|
|
1072
1078
|
});
|
|
@@ -1084,7 +1090,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
1084
1090
|
attributes: { prompt: 'Explain quantum computing' },
|
|
1085
1091
|
},
|
|
1086
1092
|
];
|
|
1087
|
-
|
|
1093
|
+
await writeJsonlFileAsync(path.join(tempDir, `llm-events-${today}.jsonl`), mockEvents);
|
|
1088
1094
|
const results = await backend.queryLLMEvents({ search: 'fibonacci' });
|
|
1089
1095
|
assert.strictEqual(results.length, 1);
|
|
1090
1096
|
assert.strictEqual(results[0].attributes.prompt, 'Write a function to calculate fibonacci');
|
|
@@ -1095,7 +1101,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
1095
1101
|
{ timestamp: '2026-01-28T10:00:00Z', name: 'llm.completion.streaming', attributes: {} },
|
|
1096
1102
|
{ timestamp: '2026-01-28T10:01:00Z', name: 'llm.completion', attributes: {} },
|
|
1097
1103
|
];
|
|
1098
|
-
|
|
1104
|
+
await writeJsonlFileAsync(path.join(tempDir, `llm-events-${today}.jsonl`), mockEvents);
|
|
1099
1105
|
const results = await backend.queryLLMEvents({ search: 'streaming' });
|
|
1100
1106
|
assert.strictEqual(results.length, 1);
|
|
1101
1107
|
assert.strictEqual(results[0].name, 'llm.completion.streaming');
|
|
@@ -1107,20 +1113,20 @@ describe('LocalJsonlBackend', () => {
|
|
|
1107
1113
|
name: `event-${i}`,
|
|
1108
1114
|
attributes: { index: i },
|
|
1109
1115
|
}));
|
|
1110
|
-
|
|
1116
|
+
await writeJsonlFileAsync(path.join(tempDir, `llm-events-${today}.jsonl`), mockEvents);
|
|
1111
1117
|
const results = await backend.queryLLMEvents({ limit: 20, offset: 50 });
|
|
1112
1118
|
assert.strictEqual(results.length, 20);
|
|
1113
1119
|
assert.strictEqual(results[0].name, 'event-50');
|
|
1114
1120
|
});
|
|
1115
1121
|
it('should filter events by date range', async () => {
|
|
1116
1122
|
// Create files for multiple dates
|
|
1117
|
-
|
|
1123
|
+
await writeJsonlFileAsync(path.join(tempDir, 'llm-events-2026-01-26.jsonl'), [
|
|
1118
1124
|
{ timestamp: '2026-01-26T10:00:00Z', name: 'event-26', attributes: {} },
|
|
1119
1125
|
]);
|
|
1120
|
-
|
|
1126
|
+
await writeJsonlFileAsync(path.join(tempDir, 'llm-events-2026-01-27.jsonl'), [
|
|
1121
1127
|
{ timestamp: '2026-01-27T10:00:00Z', name: 'event-27', attributes: {} },
|
|
1122
1128
|
]);
|
|
1123
|
-
|
|
1129
|
+
await writeJsonlFileAsync(path.join(tempDir, 'llm-events-2026-01-28.jsonl'), [
|
|
1124
1130
|
{ timestamp: '2026-01-28T10:00:00Z', name: 'event-28', attributes: {} },
|
|
1125
1131
|
]);
|
|
1126
1132
|
const results = await backend.queryLLMEvents({
|
|
@@ -1137,7 +1143,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
1137
1143
|
{ timestamp: '2026-01-28T10:01:00Z', attributes: {} }, // missing name
|
|
1138
1144
|
{ name: 'no-timestamp', attributes: {} }, // missing timestamp
|
|
1139
1145
|
];
|
|
1140
|
-
|
|
1146
|
+
await writeJsonlFileAsync(path.join(tempDir, `llm-events-${today}.jsonl`), mockEvents);
|
|
1141
1147
|
const results = await backend.queryLLMEvents({});
|
|
1142
1148
|
assert.strictEqual(results.length, 1);
|
|
1143
1149
|
assert.strictEqual(results[0].name, 'valid-event');
|
|
@@ -1165,7 +1171,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
1165
1171
|
attributes: { 'gen_ai.request.model': 'claude-3-opus', 'gen_ai.system': 'anthropic' },
|
|
1166
1172
|
},
|
|
1167
1173
|
];
|
|
1168
|
-
|
|
1174
|
+
await writeJsonlFileAsync(path.join(tempDir, `llm-events-${today}.jsonl`), mockEvents);
|
|
1169
1175
|
const results = await backend.queryLLMEvents({
|
|
1170
1176
|
eventName: 'completion',
|
|
1171
1177
|
model: 'claude-3-opus',
|
|
@@ -1198,7 +1204,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
1198
1204
|
attributes: { 'gen_ai.provider.name': 'other-provider' }, // should NOT match
|
|
1199
1205
|
},
|
|
1200
1206
|
];
|
|
1201
|
-
|
|
1207
|
+
await writeJsonlFileAsync(path.join(tempDir, `llm-events-${today}.jsonl`), mockEvents);
|
|
1202
1208
|
const results = await backend.queryLLMEvents({ provider: 'anthropic-new' });
|
|
1203
1209
|
assert.strictEqual(results.length, 3);
|
|
1204
1210
|
});
|
|
@@ -1223,7 +1229,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
1223
1229
|
},
|
|
1224
1230
|
},
|
|
1225
1231
|
];
|
|
1226
|
-
|
|
1232
|
+
await writeJsonlFileAsync(path.join(tempDir, `llm-events-${today}.jsonl`), mockEvents);
|
|
1227
1233
|
const results = await backend.queryLLMEvents({ provider: 'openai' });
|
|
1228
1234
|
assert.strictEqual(results.length, 1);
|
|
1229
1235
|
assert.strictEqual(results[0].attributes?.['gen_ai.request.model'], 'gpt-4o');
|
|
@@ -1256,7 +1262,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
1256
1262
|
},
|
|
1257
1263
|
},
|
|
1258
1264
|
];
|
|
1259
|
-
|
|
1265
|
+
await writeJsonlFileAsync(path.join(tempDir, `llm-events-${today}.jsonl`), mockEvents);
|
|
1260
1266
|
const geminiResults = await backend.queryLLMEvents({ provider: 'gcp.gemini' });
|
|
1261
1267
|
assert.strictEqual(geminiResults.length, 1);
|
|
1262
1268
|
assert.strictEqual(geminiResults[0].attributes?.['gen_ai.request.model'], 'gemini-1.5-pro');
|
|
@@ -1283,7 +1289,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
1283
1289
|
},
|
|
1284
1290
|
},
|
|
1285
1291
|
];
|
|
1286
|
-
|
|
1292
|
+
await writeJsonlFileAsync(path.join(tempDir, `llm-events-${today}.jsonl`), mockEvents);
|
|
1287
1293
|
const results = await backend.queryLLMEvents({ provider: 'mistral_ai' });
|
|
1288
1294
|
assert.strictEqual(results.length, 1);
|
|
1289
1295
|
assert.strictEqual(results[0].attributes?.['gen_ai.request.model'], 'mistral-large');
|
|
@@ -1308,7 +1314,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
1308
1314
|
},
|
|
1309
1315
|
},
|
|
1310
1316
|
];
|
|
1311
|
-
|
|
1317
|
+
await writeJsonlFileAsync(path.join(tempDir, `llm-events-${today}.jsonl`), mockEvents);
|
|
1312
1318
|
const results = await backend.queryLLMEvents({ provider: 'aws.bedrock' });
|
|
1313
1319
|
assert.strictEqual(results.length, 1);
|
|
1314
1320
|
assert.ok(results[0].attributes?.['gen_ai.request.model']?.toString().includes('anthropic.claude'));
|
|
@@ -1333,7 +1339,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
1333
1339
|
},
|
|
1334
1340
|
},
|
|
1335
1341
|
];
|
|
1336
|
-
|
|
1342
|
+
await writeJsonlFileAsync(path.join(tempDir, `llm-events-${today}.jsonl`), mockEvents);
|
|
1337
1343
|
const results = await backend.queryLLMEvents({ provider: 'cohere' });
|
|
1338
1344
|
assert.strictEqual(results.length, 1);
|
|
1339
1345
|
assert.strictEqual(results[0].attributes?.['gen_ai.request.model'], 'command-r-plus');
|
|
@@ -1358,7 +1364,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
1358
1364
|
},
|
|
1359
1365
|
},
|
|
1360
1366
|
];
|
|
1361
|
-
|
|
1367
|
+
await writeJsonlFileAsync(path.join(tempDir, `llm-events-${today}.jsonl`), mockEvents);
|
|
1362
1368
|
const groqResults = await backend.queryLLMEvents({ provider: 'groq' });
|
|
1363
1369
|
assert.strictEqual(groqResults.length, 1);
|
|
1364
1370
|
assert.strictEqual(groqResults[0].attributes?.['gen_ai.request.model'], 'llama-3.3-70b');
|
|
@@ -1385,7 +1391,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
1385
1391
|
},
|
|
1386
1392
|
},
|
|
1387
1393
|
];
|
|
1388
|
-
|
|
1394
|
+
await writeJsonlFileAsync(path.join(tempDir, `llm-events-${today}.jsonl`), mockEvents);
|
|
1389
1395
|
const results = await backend.queryLLMEvents({ provider: 'ollama' });
|
|
1390
1396
|
assert.strictEqual(results.length, 1);
|
|
1391
1397
|
assert.strictEqual(results[0].attributes?.['gen_ai.request.model'], 'llama3:8b');
|
|
@@ -1410,7 +1416,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
1410
1416
|
},
|
|
1411
1417
|
},
|
|
1412
1418
|
];
|
|
1413
|
-
|
|
1419
|
+
await writeJsonlFileAsync(path.join(tempDir, `llm-events-${today}.jsonl`), mockEvents);
|
|
1414
1420
|
const results = await backend.queryLLMEvents({ provider: 'custom-internal-llm' });
|
|
1415
1421
|
assert.strictEqual(results.length, 1);
|
|
1416
1422
|
assert.strictEqual(results[0].attributes?.['gen_ai.request.model'], 'internal-model-v2');
|
|
@@ -1443,7 +1449,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
1443
1449
|
},
|
|
1444
1450
|
},
|
|
1445
1451
|
];
|
|
1446
|
-
|
|
1452
|
+
await writeJsonlFileAsync(path.join(tempDir, `llm-events-${today}.jsonl`), mockEvents);
|
|
1447
1453
|
const results = await backend.queryLLMEvents({ provider: 'openai', model: 'gpt-4o' });
|
|
1448
1454
|
assert.strictEqual(results.length, 1);
|
|
1449
1455
|
assert.strictEqual(results[0].attributes?.['gen_ai.provider.name'], 'openai');
|
|
@@ -1461,7 +1467,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
1461
1467
|
},
|
|
1462
1468
|
},
|
|
1463
1469
|
];
|
|
1464
|
-
|
|
1470
|
+
await writeJsonlFileAsync(path.join(tempDir, `llm-events-${today}.jsonl`), mockEvents);
|
|
1465
1471
|
const results = await backend.queryLLMEvents({ provider: 'nonexistent-provider' });
|
|
1466
1472
|
assert.strictEqual(results.length, 0);
|
|
1467
1473
|
});
|
|
@@ -1484,7 +1490,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
1484
1490
|
attributes: { 'gen_ai.operation.name': 'invoke_agent' },
|
|
1485
1491
|
},
|
|
1486
1492
|
];
|
|
1487
|
-
|
|
1493
|
+
await writeJsonlFileAsync(path.join(tempDir, `llm-events-${today}.jsonl`), mockEvents);
|
|
1488
1494
|
const results = await backend.queryLLMEvents({ operationName: 'chat' });
|
|
1489
1495
|
assert.strictEqual(results.length, 1);
|
|
1490
1496
|
assert.strictEqual(results[0].name, 'llm.chat');
|
|
@@ -1508,7 +1514,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
1508
1514
|
attributes: { 'gen_ai.conversation.id': 'conv-abc123' },
|
|
1509
1515
|
},
|
|
1510
1516
|
];
|
|
1511
|
-
|
|
1517
|
+
await writeJsonlFileAsync(path.join(tempDir, `llm-events-${today}.jsonl`), mockEvents);
|
|
1512
1518
|
const results = await backend.queryLLMEvents({ conversationId: 'conv-abc123' });
|
|
1513
1519
|
assert.strictEqual(results.length, 2);
|
|
1514
1520
|
});
|
|
@@ -1534,7 +1540,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
1534
1540
|
},
|
|
1535
1541
|
},
|
|
1536
1542
|
];
|
|
1537
|
-
|
|
1543
|
+
await writeJsonlFileAsync(path.join(tempDir, `llm-events-${today}.jsonl`), mockEvents);
|
|
1538
1544
|
const results = await backend.queryLLMEvents({
|
|
1539
1545
|
operationName: 'chat',
|
|
1540
1546
|
conversationId: 'conv-abc123',
|
|
@@ -1563,7 +1569,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
1563
1569
|
attributes: { 'gen_ai.agent.id': 'agent-002' },
|
|
1564
1570
|
},
|
|
1565
1571
|
];
|
|
1566
|
-
|
|
1572
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
1567
1573
|
const results = await backend.queryTraces({ agentId: 'agent-001' });
|
|
1568
1574
|
assert.strictEqual(results.length, 1);
|
|
1569
1575
|
assert.strictEqual(results[0].attributes?.['gen_ai.agent.id'], 'agent-001');
|
|
@@ -1586,7 +1592,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
1586
1592
|
attributes: { 'gen_ai.agent.name': 'Plan' },
|
|
1587
1593
|
},
|
|
1588
1594
|
];
|
|
1589
|
-
|
|
1595
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
1590
1596
|
const results = await backend.queryTraces({ agentName: 'Explore' });
|
|
1591
1597
|
assert.strictEqual(results.length, 1);
|
|
1592
1598
|
assert.strictEqual(results[0].attributes?.['gen_ai.agent.name'], 'Explore');
|
|
@@ -1609,7 +1615,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
1609
1615
|
attributes: { 'gen_ai.tool.name': 'Write' },
|
|
1610
1616
|
},
|
|
1611
1617
|
];
|
|
1612
|
-
|
|
1618
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
1613
1619
|
const results = await backend.queryTraces({ toolName: 'Read' });
|
|
1614
1620
|
assert.strictEqual(results.length, 1);
|
|
1615
1621
|
assert.strictEqual(results[0].attributes?.['gen_ai.tool.name'], 'Read');
|
|
@@ -1632,7 +1638,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
1632
1638
|
attributes: { 'gen_ai.tool.call.id': 'toolu_xyz789' },
|
|
1633
1639
|
},
|
|
1634
1640
|
];
|
|
1635
|
-
|
|
1641
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
1636
1642
|
const results = await backend.queryTraces({ toolCallId: 'toolu_abc123' });
|
|
1637
1643
|
assert.strictEqual(results.length, 1);
|
|
1638
1644
|
assert.strictEqual(results[0].attributes?.['gen_ai.tool.call.id'], 'toolu_abc123');
|
|
@@ -1655,7 +1661,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
1655
1661
|
attributes: { 'gen_ai.tool.type': 'mcp' },
|
|
1656
1662
|
},
|
|
1657
1663
|
];
|
|
1658
|
-
|
|
1664
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
1659
1665
|
const results = await backend.queryTraces({ toolType: 'function' });
|
|
1660
1666
|
assert.strictEqual(results.length, 1);
|
|
1661
1667
|
assert.strictEqual(results[0].attributes?.['gen_ai.tool.type'], 'function');
|
|
@@ -1678,7 +1684,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
1678
1684
|
attributes: { 'gen_ai.operation.name': 'execute_tool' },
|
|
1679
1685
|
},
|
|
1680
1686
|
];
|
|
1681
|
-
|
|
1687
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
1682
1688
|
const results = await backend.queryTraces({ operationName: 'chat' });
|
|
1683
1689
|
assert.strictEqual(results.length, 1);
|
|
1684
1690
|
assert.strictEqual(results[0].attributes?.['gen_ai.operation.name'], 'chat');
|
|
@@ -1709,7 +1715,7 @@ describe('LocalJsonlBackend', () => {
|
|
|
1709
1715
|
},
|
|
1710
1716
|
},
|
|
1711
1717
|
];
|
|
1712
|
-
|
|
1718
|
+
await writeJsonlFileAsync(path.join(tempDir, `traces-${today}.jsonl`), mockSpans);
|
|
1713
1719
|
const results = await backend.queryTraces({
|
|
1714
1720
|
agentName: 'Explore',
|
|
1715
1721
|
toolName: 'Grep',
|