@lmnr-ai/lmnr 0.4.21 → 0.4.22
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/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +39 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.js +85 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +85 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/laminar.ts +95 -5
package/dist/cli.js
CHANGED
|
@@ -36,7 +36,7 @@ var require_package = __commonJS({
|
|
|
36
36
|
"package.json"(exports2, module2) {
|
|
37
37
|
module2.exports = {
|
|
38
38
|
name: "@lmnr-ai/lmnr",
|
|
39
|
-
version: "0.4.
|
|
39
|
+
version: "0.4.22",
|
|
40
40
|
description: "TypeScript SDK for Laminar AI",
|
|
41
41
|
main: "dist/index.js",
|
|
42
42
|
types: "dist/index.d.ts",
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../package.json","../src/cli.ts"],"sourcesContent":["{\n \"name\": \"@lmnr-ai/lmnr\",\n \"version\": \"0.4.
|
|
1
|
+
{"version":3,"sources":["../package.json","../src/cli.ts"],"sourcesContent":["{\n \"name\": \"@lmnr-ai/lmnr\",\n \"version\": \"0.4.22\",\n \"description\": \"TypeScript SDK for Laminar AI\",\n \"main\": \"dist/index.js\",\n \"types\": \"dist/index.d.ts\",\n \"scripts\": {\n \"build\": \"tsup src/index.ts src/cli.ts --format esm,cjs --dts\",\n \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\"\n },\n \"bin\": {\n \"lmnr\": \"./dist/cli.js\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/lmnr-ai/lmnr-ts.git\"\n },\n \"keywords\": [\n \"laminar\",\n \"lmnr\",\n \"sdk\",\n \"lmnr.ai\"\n ],\n \"author\": \"founders@lmnr.ai\",\n \"license\": \"Apache-2.0\",\n \"bugs\": {\n \"url\": \"https://github.com/lmnr-ai/lmnr-ts/issues\"\n },\n \"homepage\": \"https://github.com/lmnr-ai/lmnr-ts#README\",\n \"devDependencies\": {\n \"@anthropic-ai/sdk\": \"^0.27.3\",\n \"@aws-sdk/client-bedrock-runtime\": \"^3.679.0\",\n \"@azure/openai\": \"1.0.0-beta.13\",\n \"@google-cloud/aiplatform\": \"^3.29.0\",\n \"@google-cloud/vertexai\": \"^1.7.0\",\n \"@langchain/core\": \"^0.3.2\",\n \"@pinecone-database/pinecone\": \"^3.0.3\",\n \"@qdrant/js-client-rest\": \"^1.11.0\",\n \"@types/argparse\": \"^2.0.16\",\n \"@types/cli-progress\": \"^3.11.6\",\n \"@types/node\": \"^22.5.5\",\n \"@types/semver\": \"^7.5.8\",\n \"@types/uuid\": \"^10.0.0\",\n \"bufferutil\": \"^4.0.8\",\n \"chromadb\": \"^1.9.2\",\n \"cohere-ai\": \"^7.14.0\",\n \"langchain\": \"^0.3.2\",\n \"llamaindex\": \"^0.7.10\",\n \"openai\": \"^4.62.1\",\n \"runnables\": \"link:@langchain/core/runnables\",\n \"tsup\": \"^8.3.0\",\n \"typescript\": \"^5.6.2\",\n \"vectorstores\": \"link:@langchain/core/vectorstores\"\n },\n \"dependencies\": {\n \"@grpc/grpc-js\": \"^1.11.3\",\n \"@opentelemetry/api\": \"^1.9.0\",\n \"@opentelemetry/core\": \"^1.26.0\",\n \"@opentelemetry/exporter-trace-otlp-grpc\": \"^0.53.0\",\n \"@opentelemetry/exporter-trace-otlp-proto\": \"^0.53.0\",\n \"@opentelemetry/instrumentation\": \"^0.53.0\",\n \"@opentelemetry/sdk-node\": \"^0.53.0\",\n \"@opentelemetry/sdk-trace-base\": \"^1.26.0\",\n \"@opentelemetry/sdk-trace-node\": \"^1.26.0\",\n \"@opentelemetry/semantic-conventions\": \"^1.27.0\",\n \"@traceloop/ai-semantic-conventions\": \"^0.11.0\",\n \"@traceloop/instrumentation-anthropic\": \"^0.11.1\",\n \"@traceloop/instrumentation-azure\": \"^0.11.1\",\n \"@traceloop/instrumentation-bedrock\": \"^0.11.1\",\n \"@traceloop/instrumentation-chromadb\": \"^0.11.3\",\n \"@traceloop/instrumentation-cohere\": \"^0.11.1\",\n \"@traceloop/instrumentation-langchain\": \"^0.11.1\",\n \"@traceloop/instrumentation-llamaindex\": \"^0.11.1\",\n \"@traceloop/instrumentation-openai\": \"^0.11.3\",\n \"@traceloop/instrumentation-pinecone\": \"^0.11.1\",\n \"@traceloop/instrumentation-qdrant\": \"^0.11.1\",\n \"@traceloop/instrumentation-vertexai\": \"^0.11.1\",\n \"argparse\": \">=2.0\",\n \"cli-progress\": \">=3.12\",\n \"esbuild\": \">=0.23\",\n \"uuid\": \">=10.0.0\"\n }\n}\n","#!/usr/bin/env node\n\nimport { ArgumentParser } from \"argparse\";\nimport * as esbuild from \"esbuild\";\n\nconst pjson = require('../package.json');\n\nexport function loadModule({\n filename,\n moduleText,\n}: {\n filename: string;\n moduleText: string;\n}) {\n // TODO: Figure out how to remove all ts-ignores\n // TODO: Cleanup by setting the original values of _evaluation and _set_global_evaluation back\n // @ts-ignore\n globalThis._evaluation = undefined; // @ts-ignore\n globalThis._set_global_evaluation = true; // @ts-ignore\n\n // it needs \"require\" to be passed in\n new Function(\"require\", moduleText)(require);\n\n // Return the modified _evals global variable\n // @ts-ignore\n return globalThis._evaluation;\n}\n\nasync function cli() {\n const [, , ...args] = process.argv;\n\n // Use argparse, which is the port of the python library\n const parser = new ArgumentParser({\n prog: \"lmnr\",\n description: \"CLI for Laminar\",\n });\n\n parser.add_argument(\"-v\", \"--version\", { action: \"version\", version: pjson.version });\n\n const subparsers = parser.add_subparsers({\n title: \"subcommands\",\n dest: \"subcommand\",\n });\n\n const parser_eval = subparsers.add_parser(\"eval\", {\n description: \"Run an evaluation\",\n });\n\n parser_eval.add_argument(\"file\", {\n help: \"A file containing the evaluation to run\",\n });\n\n parser_eval.set_defaults({\n func: async (args: any) => {\n // TODO: Add various optimizations, e.g. minify, pure, tree shaking, etc.\n const buildOptions = {\n entryPoints: [args.file],\n outfile: \"tmp_out.js\",\n write: false, // will be loaded in memory as a temp file\n platform: \"node\" as esbuild.Platform,\n bundle: true,\n external: [\"node_modules/*\"],\n };\n\n const result = await esbuild.build(buildOptions);\n\n if (!result.outputFiles) {\n console.error(\"Error when building: No output files found\");\n process.exit(1);\n }\n\n const outputFileText = result.outputFiles[0].text;\n\n const evaluation = loadModule({\n filename: args.file,\n moduleText: outputFileText,\n });\n\n // @ts-ignore\n await evaluation.run();\n }\n });\n\n const parsed = parser.parse_args(args);\n await parsed.func(parsed);\n}\n\ncli();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,iBAAAA,UAAAC,SAAA;AAAA,IAAAA,QAAA;AAAA,MACE,MAAQ;AAAA,MACR,SAAW;AAAA,MACX,aAAe;AAAA,MACf,MAAQ;AAAA,MACR,OAAS;AAAA,MACT,SAAW;AAAA,QACT,OAAS;AAAA,QACT,MAAQ;AAAA,MACV;AAAA,MACA,KAAO;AAAA,QACL,MAAQ;AAAA,MACV;AAAA,MACA,YAAc;AAAA,QACZ,MAAQ;AAAA,QACR,KAAO;AAAA,MACT;AAAA,MACA,UAAY;AAAA,QACV;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MACA,QAAU;AAAA,MACV,SAAW;AAAA,MACX,MAAQ;AAAA,QACN,KAAO;AAAA,MACT;AAAA,MACA,UAAY;AAAA,MACZ,iBAAmB;AAAA,QACjB,qBAAqB;AAAA,QACrB,mCAAmC;AAAA,QACnC,iBAAiB;AAAA,QACjB,4BAA4B;AAAA,QAC5B,0BAA0B;AAAA,QAC1B,mBAAmB;AAAA,QACnB,+BAA+B;AAAA,QAC/B,0BAA0B;AAAA,QAC1B,mBAAmB;AAAA,QACnB,uBAAuB;AAAA,QACvB,eAAe;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QAAQ,WAAW,SAAS,MAAM,QAAQ,CAAC;AAEpF,QAAM,aAAa,OAAO,eAAe;AAAA,IACvC,OAAO;AAAA,IACP,MAAM;AAAA,EACR,CAAC;AAED,QAAM,cAAc,WAAW,WAAW,QAAQ;AAAA,IAChD,aAAa;AAAA,EACf,CAAC;AAED,cAAY,aAAa,QAAQ;AAAA,IAC/B,MAAM;AAAA,EACR,CAAC;AAED,cAAY,aAAa;AAAA,IACvB,MAAM,OAAOC,UAAc;AAEzB,YAAM,eAAe;AAAA,QACnB,aAAa,CAACA,MAAK,IAAI;AAAA,QACvB,SAAS;AAAA,QACT,OAAO;AAAA;AAAA,QACP,UAAU;AAAA,QACV,QAAQ;AAAA,QACR,UAAU,CAAC,gBAAgB;AAAA,MAC7B;AAEA,YAAM,SAAS,MAAc,cAAM,YAAY;AAE/C,UAAI,CAAC,OAAO,aAAa;AACvB,gBAAQ,MAAM,4CAA4C;AAC1D,gBAAQ,KAAK,CAAC;AAAA,MAChB;AAEA,YAAM,iBAAiB,OAAO,YAAY,CAAC,EAAE;AAE7C,YAAM,aAAa,WAAW;AAAA,QAC5B,UAAUA,MAAK;AAAA,QACf,YAAY;AAAA,MACd,CAAC;AAGD,YAAM,WAAW,IAAI;AAAA,IACvB;AAAA,EACF,CAAC;AAED,QAAM,SAAS,OAAO,WAAW,IAAI;AACrC,QAAM,OAAO,KAAK,MAAM;AAC1B;AAEA,IAAI;","names":["exports","module","args"]}
|
package/dist/cli.mjs
CHANGED
|
@@ -15,7 +15,7 @@ var require_package = __commonJS({
|
|
|
15
15
|
"package.json"(exports, module) {
|
|
16
16
|
module.exports = {
|
|
17
17
|
name: "@lmnr-ai/lmnr",
|
|
18
|
-
version: "0.4.
|
|
18
|
+
version: "0.4.22",
|
|
19
19
|
description: "TypeScript SDK for Laminar AI",
|
|
20
20
|
main: "dist/index.js",
|
|
21
21
|
types: "dist/index.d.ts",
|
package/dist/cli.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../package.json","../src/cli.ts"],"sourcesContent":["{\n \"name\": \"@lmnr-ai/lmnr\",\n \"version\": \"0.4.
|
|
1
|
+
{"version":3,"sources":["../package.json","../src/cli.ts"],"sourcesContent":["{\n \"name\": \"@lmnr-ai/lmnr\",\n \"version\": \"0.4.22\",\n \"description\": \"TypeScript SDK for Laminar AI\",\n \"main\": \"dist/index.js\",\n \"types\": \"dist/index.d.ts\",\n \"scripts\": {\n \"build\": \"tsup src/index.ts src/cli.ts --format esm,cjs --dts\",\n \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\"\n },\n \"bin\": {\n \"lmnr\": \"./dist/cli.js\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/lmnr-ai/lmnr-ts.git\"\n },\n \"keywords\": [\n \"laminar\",\n \"lmnr\",\n \"sdk\",\n \"lmnr.ai\"\n ],\n \"author\": \"founders@lmnr.ai\",\n \"license\": \"Apache-2.0\",\n \"bugs\": {\n \"url\": \"https://github.com/lmnr-ai/lmnr-ts/issues\"\n },\n \"homepage\": \"https://github.com/lmnr-ai/lmnr-ts#README\",\n \"devDependencies\": {\n \"@anthropic-ai/sdk\": \"^0.27.3\",\n \"@aws-sdk/client-bedrock-runtime\": \"^3.679.0\",\n \"@azure/openai\": \"1.0.0-beta.13\",\n \"@google-cloud/aiplatform\": \"^3.29.0\",\n \"@google-cloud/vertexai\": \"^1.7.0\",\n \"@langchain/core\": \"^0.3.2\",\n \"@pinecone-database/pinecone\": \"^3.0.3\",\n \"@qdrant/js-client-rest\": \"^1.11.0\",\n \"@types/argparse\": \"^2.0.16\",\n \"@types/cli-progress\": \"^3.11.6\",\n \"@types/node\": \"^22.5.5\",\n \"@types/semver\": \"^7.5.8\",\n \"@types/uuid\": \"^10.0.0\",\n \"bufferutil\": \"^4.0.8\",\n \"chromadb\": \"^1.9.2\",\n \"cohere-ai\": \"^7.14.0\",\n \"langchain\": \"^0.3.2\",\n \"llamaindex\": \"^0.7.10\",\n \"openai\": \"^4.62.1\",\n \"runnables\": \"link:@langchain/core/runnables\",\n \"tsup\": \"^8.3.0\",\n \"typescript\": \"^5.6.2\",\n \"vectorstores\": \"link:@langchain/core/vectorstores\"\n },\n \"dependencies\": {\n \"@grpc/grpc-js\": \"^1.11.3\",\n \"@opentelemetry/api\": \"^1.9.0\",\n \"@opentelemetry/core\": \"^1.26.0\",\n \"@opentelemetry/exporter-trace-otlp-grpc\": \"^0.53.0\",\n \"@opentelemetry/exporter-trace-otlp-proto\": \"^0.53.0\",\n \"@opentelemetry/instrumentation\": \"^0.53.0\",\n \"@opentelemetry/sdk-node\": \"^0.53.0\",\n \"@opentelemetry/sdk-trace-base\": \"^1.26.0\",\n \"@opentelemetry/sdk-trace-node\": \"^1.26.0\",\n \"@opentelemetry/semantic-conventions\": \"^1.27.0\",\n \"@traceloop/ai-semantic-conventions\": \"^0.11.0\",\n \"@traceloop/instrumentation-anthropic\": \"^0.11.1\",\n \"@traceloop/instrumentation-azure\": \"^0.11.1\",\n \"@traceloop/instrumentation-bedrock\": \"^0.11.1\",\n \"@traceloop/instrumentation-chromadb\": \"^0.11.3\",\n \"@traceloop/instrumentation-cohere\": \"^0.11.1\",\n \"@traceloop/instrumentation-langchain\": \"^0.11.1\",\n \"@traceloop/instrumentation-llamaindex\": \"^0.11.1\",\n \"@traceloop/instrumentation-openai\": \"^0.11.3\",\n \"@traceloop/instrumentation-pinecone\": \"^0.11.1\",\n \"@traceloop/instrumentation-qdrant\": \"^0.11.1\",\n \"@traceloop/instrumentation-vertexai\": \"^0.11.1\",\n \"argparse\": \">=2.0\",\n \"cli-progress\": \">=3.12\",\n \"esbuild\": \">=0.23\",\n \"uuid\": \">=10.0.0\"\n }\n}\n","#!/usr/bin/env node\n\nimport { ArgumentParser } from \"argparse\";\nimport * as esbuild from \"esbuild\";\n\nconst pjson = require('../package.json');\n\nexport function loadModule({\n filename,\n moduleText,\n}: {\n filename: string;\n moduleText: string;\n}) {\n // TODO: Figure out how to remove all ts-ignores\n // TODO: Cleanup by setting the original values of _evaluation and _set_global_evaluation back\n // @ts-ignore\n globalThis._evaluation = undefined; // @ts-ignore\n globalThis._set_global_evaluation = true; // @ts-ignore\n\n // it needs \"require\" to be passed in\n new Function(\"require\", moduleText)(require);\n\n // Return the modified _evals global variable\n // @ts-ignore\n return globalThis._evaluation;\n}\n\nasync function cli() {\n const [, , ...args] = process.argv;\n\n // Use argparse, which is the port of the python library\n const parser = new ArgumentParser({\n prog: \"lmnr\",\n description: \"CLI for Laminar\",\n });\n\n parser.add_argument(\"-v\", \"--version\", { action: \"version\", version: pjson.version });\n\n const subparsers = parser.add_subparsers({\n title: \"subcommands\",\n dest: \"subcommand\",\n });\n\n const parser_eval = subparsers.add_parser(\"eval\", {\n description: \"Run an evaluation\",\n });\n\n parser_eval.add_argument(\"file\", {\n help: \"A file containing the evaluation to run\",\n });\n\n parser_eval.set_defaults({\n func: async (args: any) => {\n // TODO: Add various optimizations, e.g. minify, pure, tree shaking, etc.\n const buildOptions = {\n entryPoints: [args.file],\n outfile: \"tmp_out.js\",\n write: false, // will be loaded in memory as a temp file\n platform: \"node\" as esbuild.Platform,\n bundle: true,\n external: [\"node_modules/*\"],\n };\n\n const result = await esbuild.build(buildOptions);\n\n if (!result.outputFiles) {\n console.error(\"Error when building: No output files found\");\n process.exit(1);\n }\n\n const outputFileText = result.outputFiles[0].text;\n\n const evaluation = loadModule({\n filename: args.file,\n moduleText: outputFileText,\n });\n\n // @ts-ignore\n await evaluation.run();\n }\n });\n\n const parsed = parser.parse_args(args);\n await parsed.func(parsed);\n}\n\ncli();\n"],"mappings":";;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA,MACE,MAAQ;AAAA,MACR,SAAW;AAAA,MACX,aAAe;AAAA,MACf,MAAQ;AAAA,MACR,OAAS;AAAA,MACT,SAAW;AAAA,QACT,OAAS;AAAA,QACT,MAAQ;AAAA,MACV;AAAA,MACA,KAAO;AAAA,QACL,MAAQ;AAAA,MACV;AA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B;AAAA,EACF,CAAC;AAED,QAAM,SAAS,OAAO,WAAW,IAAI;AACrC,QAAM,OAAO,KAAK,MAAM;AAC1B;AAEA,IAAI;","names":["args"]}
|
package/dist/index.d.mts
CHANGED
|
@@ -442,6 +442,7 @@ declare class Laminar {
|
|
|
442
442
|
*/
|
|
443
443
|
static event(name: string, value?: AttributeValue, timestamp?: TimeInput): void;
|
|
444
444
|
/**
|
|
445
|
+
* DEPRECATED: use `withSession` and/or `withMetadata` instead.
|
|
445
446
|
* Sets the session information for the current span and returns the
|
|
446
447
|
* context to use for the following spans.
|
|
447
448
|
*
|
|
@@ -461,6 +462,44 @@ declare class Laminar {
|
|
|
461
462
|
sessionId?: string;
|
|
462
463
|
userId?: string;
|
|
463
464
|
}): Context;
|
|
465
|
+
/**
|
|
466
|
+
* Sets the session information for the current span and returns the
|
|
467
|
+
* context to use for the following spans. Returns the result of the
|
|
468
|
+
* function execution, so can be used in an `await` statement.
|
|
469
|
+
*
|
|
470
|
+
* @param sessionId - The session ID to associate with the context.
|
|
471
|
+
* @param fn - Function to execute within the session context.
|
|
472
|
+
* @returns The result of the function execution.
|
|
473
|
+
*
|
|
474
|
+
* @example
|
|
475
|
+
* import { Laminar, observe } from '@lmnr-ai/lmnr';
|
|
476
|
+
* const result = await Laminar.withSession("session1234", async () => {
|
|
477
|
+
* // Your code here
|
|
478
|
+
* });
|
|
479
|
+
*/
|
|
480
|
+
static withSession<T>(sessionId: string, fn: () => T): T;
|
|
481
|
+
/**
|
|
482
|
+
* Sets the metadata for the current span and returns the context to use for
|
|
483
|
+
* the following spans. Returns the result of the function execution, so can
|
|
484
|
+
* be used in an `await` statement.
|
|
485
|
+
*
|
|
486
|
+
* @param metadata - The metadata to associate with the context. Will be sent
|
|
487
|
+
* as attributes, so must be serializable to JSON.
|
|
488
|
+
* @param fn - Function to execute within the metadata context.
|
|
489
|
+
* @returns The result of the function execution.
|
|
490
|
+
*
|
|
491
|
+
* @example
|
|
492
|
+
* import { Laminar } from '@lmnr-ai/lmnr';
|
|
493
|
+
* const result = await Laminar.withMetadata(
|
|
494
|
+
* {
|
|
495
|
+
* "my_metadata_key": "my_metadata_value"
|
|
496
|
+
* },
|
|
497
|
+
* async () => {
|
|
498
|
+
* // Your code here
|
|
499
|
+
* }
|
|
500
|
+
* );
|
|
501
|
+
*/
|
|
502
|
+
static withMetadata<T>(metadata: Record<string, any>, fn: () => T): T;
|
|
464
503
|
/**
|
|
465
504
|
* Set attributes for the current span. Useful for manual
|
|
466
505
|
* instrumentation.
|
package/dist/index.d.ts
CHANGED
|
@@ -442,6 +442,7 @@ declare class Laminar {
|
|
|
442
442
|
*/
|
|
443
443
|
static event(name: string, value?: AttributeValue, timestamp?: TimeInput): void;
|
|
444
444
|
/**
|
|
445
|
+
* DEPRECATED: use `withSession` and/or `withMetadata` instead.
|
|
445
446
|
* Sets the session information for the current span and returns the
|
|
446
447
|
* context to use for the following spans.
|
|
447
448
|
*
|
|
@@ -461,6 +462,44 @@ declare class Laminar {
|
|
|
461
462
|
sessionId?: string;
|
|
462
463
|
userId?: string;
|
|
463
464
|
}): Context;
|
|
465
|
+
/**
|
|
466
|
+
* Sets the session information for the current span and returns the
|
|
467
|
+
* context to use for the following spans. Returns the result of the
|
|
468
|
+
* function execution, so can be used in an `await` statement.
|
|
469
|
+
*
|
|
470
|
+
* @param sessionId - The session ID to associate with the context.
|
|
471
|
+
* @param fn - Function to execute within the session context.
|
|
472
|
+
* @returns The result of the function execution.
|
|
473
|
+
*
|
|
474
|
+
* @example
|
|
475
|
+
* import { Laminar, observe } from '@lmnr-ai/lmnr';
|
|
476
|
+
* const result = await Laminar.withSession("session1234", async () => {
|
|
477
|
+
* // Your code here
|
|
478
|
+
* });
|
|
479
|
+
*/
|
|
480
|
+
static withSession<T>(sessionId: string, fn: () => T): T;
|
|
481
|
+
/**
|
|
482
|
+
* Sets the metadata for the current span and returns the context to use for
|
|
483
|
+
* the following spans. Returns the result of the function execution, so can
|
|
484
|
+
* be used in an `await` statement.
|
|
485
|
+
*
|
|
486
|
+
* @param metadata - The metadata to associate with the context. Will be sent
|
|
487
|
+
* as attributes, so must be serializable to JSON.
|
|
488
|
+
* @param fn - Function to execute within the metadata context.
|
|
489
|
+
* @returns The result of the function execution.
|
|
490
|
+
*
|
|
491
|
+
* @example
|
|
492
|
+
* import { Laminar } from '@lmnr-ai/lmnr';
|
|
493
|
+
* const result = await Laminar.withMetadata(
|
|
494
|
+
* {
|
|
495
|
+
* "my_metadata_key": "my_metadata_value"
|
|
496
|
+
* },
|
|
497
|
+
* async () => {
|
|
498
|
+
* // Your code here
|
|
499
|
+
* }
|
|
500
|
+
* );
|
|
501
|
+
*/
|
|
502
|
+
static withMetadata<T>(metadata: Record<string, any>, fn: () => T): T;
|
|
464
503
|
/**
|
|
465
504
|
* Set attributes for the current span. Useful for manual
|
|
466
505
|
* instrumentation.
|
package/dist/index.js
CHANGED
|
@@ -744,6 +744,7 @@ var Laminar = class {
|
|
|
744
744
|
currentSpan.addEvent(name, event, timestamp);
|
|
745
745
|
}
|
|
746
746
|
/**
|
|
747
|
+
* DEPRECATED: use `withSession` and/or `withMetadata` instead.
|
|
747
748
|
* Sets the session information for the current span and returns the
|
|
748
749
|
* context to use for the following spans.
|
|
749
750
|
*
|
|
@@ -763,21 +764,22 @@ var Laminar = class {
|
|
|
763
764
|
sessionId,
|
|
764
765
|
userId
|
|
765
766
|
}) {
|
|
767
|
+
console.warn("Laminar().contextWithSession() is deprecated. Use withSession() instead.");
|
|
766
768
|
const currentSpan = import_api5.trace.getActiveSpan();
|
|
767
769
|
if (currentSpan !== void 0 && (0, import_api5.isSpanContextValid)(currentSpan.spanContext())) {
|
|
768
770
|
if (sessionId) {
|
|
769
|
-
currentSpan.setAttribute(SESSION_ID, sessionId);
|
|
771
|
+
currentSpan.setAttribute(SESSION_ID, JSON.stringify(sessionId));
|
|
770
772
|
}
|
|
771
773
|
if (userId) {
|
|
772
|
-
currentSpan.setAttribute(USER_ID, userId);
|
|
774
|
+
currentSpan.setAttribute(USER_ID, JSON.stringify(userId));
|
|
773
775
|
}
|
|
774
776
|
}
|
|
775
777
|
let associationProperties = {};
|
|
776
778
|
if (sessionId) {
|
|
777
|
-
associationProperties = { ...associationProperties, "session_id": sessionId };
|
|
779
|
+
associationProperties = { ...associationProperties, "session_id": JSON.stringify(sessionId) };
|
|
778
780
|
}
|
|
779
781
|
if (userId) {
|
|
780
|
-
associationProperties = { ...associationProperties, "user_id": userId };
|
|
782
|
+
associationProperties = { ...associationProperties, "user_id": JSON.stringify(userId) };
|
|
781
783
|
}
|
|
782
784
|
let entityContext = import_api5.context.active();
|
|
783
785
|
const currentAssociationProperties = entityContext.getValue(ASSOCIATION_PROPERTIES_KEY);
|
|
@@ -789,6 +791,84 @@ var Laminar = class {
|
|
|
789
791
|
}
|
|
790
792
|
return entityContext;
|
|
791
793
|
}
|
|
794
|
+
/**
|
|
795
|
+
* Sets the session information for the current span and returns the
|
|
796
|
+
* context to use for the following spans. Returns the result of the
|
|
797
|
+
* function execution, so can be used in an `await` statement.
|
|
798
|
+
*
|
|
799
|
+
* @param sessionId - The session ID to associate with the context.
|
|
800
|
+
* @param fn - Function to execute within the session context.
|
|
801
|
+
* @returns The result of the function execution.
|
|
802
|
+
*
|
|
803
|
+
* @example
|
|
804
|
+
* import { Laminar, observe } from '@lmnr-ai/lmnr';
|
|
805
|
+
* const result = await Laminar.withSession("session1234", async () => {
|
|
806
|
+
* // Your code here
|
|
807
|
+
* });
|
|
808
|
+
*/
|
|
809
|
+
static withSession(sessionId, fn) {
|
|
810
|
+
const currentSpan = import_api5.trace.getActiveSpan();
|
|
811
|
+
if (currentSpan !== void 0 && (0, import_api5.isSpanContextValid)(currentSpan.spanContext())) {
|
|
812
|
+
if (sessionId) {
|
|
813
|
+
currentSpan.setAttribute(SESSION_ID, JSON.stringify(sessionId));
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
let associationProperties = {};
|
|
817
|
+
if (sessionId) {
|
|
818
|
+
associationProperties = { ...associationProperties, "session_id": JSON.stringify(sessionId) };
|
|
819
|
+
}
|
|
820
|
+
let entityContext = import_api5.context.active();
|
|
821
|
+
const currentAssociationProperties = entityContext.getValue(ASSOCIATION_PROPERTIES_KEY);
|
|
822
|
+
if (associationProperties && Object.keys(associationProperties).length > 0) {
|
|
823
|
+
entityContext = entityContext.setValue(
|
|
824
|
+
ASSOCIATION_PROPERTIES_KEY,
|
|
825
|
+
{ ...currentAssociationProperties != null ? currentAssociationProperties : {}, ...associationProperties }
|
|
826
|
+
);
|
|
827
|
+
}
|
|
828
|
+
return import_api5.context.with(entityContext, fn);
|
|
829
|
+
}
|
|
830
|
+
/**
|
|
831
|
+
* Sets the metadata for the current span and returns the context to use for
|
|
832
|
+
* the following spans. Returns the result of the function execution, so can
|
|
833
|
+
* be used in an `await` statement.
|
|
834
|
+
*
|
|
835
|
+
* @param metadata - The metadata to associate with the context. Will be sent
|
|
836
|
+
* as attributes, so must be serializable to JSON.
|
|
837
|
+
* @param fn - Function to execute within the metadata context.
|
|
838
|
+
* @returns The result of the function execution.
|
|
839
|
+
*
|
|
840
|
+
* @example
|
|
841
|
+
* import { Laminar } from '@lmnr-ai/lmnr';
|
|
842
|
+
* const result = await Laminar.withMetadata(
|
|
843
|
+
* {
|
|
844
|
+
* "my_metadata_key": "my_metadata_value"
|
|
845
|
+
* },
|
|
846
|
+
* async () => {
|
|
847
|
+
* // Your code here
|
|
848
|
+
* }
|
|
849
|
+
* );
|
|
850
|
+
*/
|
|
851
|
+
static withMetadata(metadata, fn) {
|
|
852
|
+
const currentSpan = import_api5.trace.getActiveSpan();
|
|
853
|
+
if (currentSpan !== void 0 && (0, import_api5.isSpanContextValid)(currentSpan.spanContext())) {
|
|
854
|
+
for (const [key, value] of Object.entries(metadata)) {
|
|
855
|
+
currentSpan.setAttribute(`${ASSOCIATION_PROPERTIES}.metadata.${key}`, JSON.stringify(value));
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
let metadataAttributes = {};
|
|
859
|
+
for (const [key, value] of Object.entries(metadata)) {
|
|
860
|
+
metadataAttributes = { ...metadataAttributes, [`metadata.${key}`]: JSON.stringify(value) };
|
|
861
|
+
}
|
|
862
|
+
let entityContext = import_api5.context.active();
|
|
863
|
+
const currentAssociationProperties = entityContext.getValue(ASSOCIATION_PROPERTIES_KEY);
|
|
864
|
+
if (metadataAttributes && Object.keys(metadataAttributes).length > 0) {
|
|
865
|
+
entityContext = entityContext.setValue(
|
|
866
|
+
ASSOCIATION_PROPERTIES_KEY,
|
|
867
|
+
{ ...currentAssociationProperties != null ? currentAssociationProperties : {}, ...metadataAttributes }
|
|
868
|
+
);
|
|
869
|
+
}
|
|
870
|
+
return import_api5.context.with(entityContext, fn);
|
|
871
|
+
}
|
|
792
872
|
/**
|
|
793
873
|
* Set attributes for the current span. Useful for manual
|
|
794
874
|
* instrumentation.
|
|
@@ -811,7 +891,7 @@ var Laminar = class {
|
|
|
811
891
|
const currentSpan = import_api5.trace.getActiveSpan();
|
|
812
892
|
if (currentSpan !== void 0 && (0, import_api5.isSpanContextValid)(currentSpan.spanContext())) {
|
|
813
893
|
for (const [key, value] of Object.entries(attributes)) {
|
|
814
|
-
currentSpan.setAttribute(key, value);
|
|
894
|
+
currentSpan.setAttribute(key, JSON.stringify(value));
|
|
815
895
|
}
|
|
816
896
|
}
|
|
817
897
|
}
|