@lmnr-ai/lmnr 0.5.2 → 0.6.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.
package/README.md CHANGED
@@ -18,12 +18,9 @@ npm install @lmnr-ai/lmnr
18
18
  And then in the code
19
19
 
20
20
  ```typescript
21
- # Only if you are using Next.js
22
- export NEXT_OTEL_FETCH_DISABLED=1
21
+ import { Laminar } from '@lmnr-ai/lmnr'
23
22
 
24
- import { Laminar as L } from '@lmnr-ai/lmnr'
25
-
26
- L.initialize({ projectApiKey: '<PROJECT_API_KEY>' })
23
+ Laminar.initialize({ projectApiKey: '<PROJECT_API_KEY>' })
27
24
  ```
28
25
 
29
26
  This will automatically instrument most of the LLM, Vector DB, and related
@@ -31,7 +28,13 @@ calls with OpenTelemetry-compatible instrumentation.
31
28
 
32
29
  [Read docs](https://docs.lmnr.ai) to learn more.
33
30
 
34
- Autoinstrumentations are provided by [OpenLLMetry](https://github.com/traceloop/openllmetry-js), open-source package by TraceLoop.
31
+ Auto-instrumentations are provided by [OpenLLMetry](https://github.com/traceloop/openllmetry-js).
32
+
33
+ ### Where to place Laminar.initialize()
34
+
35
+ Laminar.initialize() must be called
36
+ - once in your application,
37
+ - as early as possible, but after other instrumentation libraries
35
38
 
36
39
  ## Instrumentation
37
40
 
@@ -66,21 +69,33 @@ const poemWriter = async (topic = "turbulence") => {
66
69
  await observe({name: 'poemWriter'}, async () => await poemWriter('laminar flow'))
67
70
  ```
68
71
 
69
- ### Sending events
72
+ ### Sending spans to Laminar from a different tracing library
70
73
 
71
- You can send laminar events using `L.event(name, value)`.
74
+ Many tracing libraries accept `spanProcessors` as an initialization parameter.
72
75
 
73
- Read our [docs](https://docs.lmnr.ai) to learn more about events and examples.
76
+ Laminar exposes `LaminarSpanProcessor` that you could use for these purposes.
74
77
 
75
- ### Example
78
+ Be careful NOT to call `Laminar.initialize` in such setup, to avoid double tracing.
76
79
 
77
- ```javascript
78
- import { Laminar as L } from '@lmnr-ai/lmnr';
79
- // ...
80
- const poem = response.choices[0].message.content;
80
+ #### Example with @vercel/otel
81
81
 
82
- // this will register True or False value with Laminar
83
- L.event('topic alignment', poem.includes(topic))
82
+ For example, in Next.js instrumentation.ts you could do:
83
+
84
+ ```javascript
85
+ import { registerOTel } from '@vercel/otel'
86
+
87
+ export async function register() {
88
+ if (process.env.NEXT_RUNTIME === "nodejs") {
89
+ const { Laminar, LaminarSpanProcessor, initializeLaminarInstrumentations } = await import("@lmnr-ai/lmnr");
90
+ registerOTel({
91
+ serviceName: "my-service",
92
+ spanProcessors: [
93
+ new LaminarSpanProcessor(),
94
+ ],
95
+ instrumentations: initializeLaminarInstrumentations(),
96
+ });
97
+ }
98
+ }
84
99
  ```
85
100
 
86
101
  ## Evaluations