@lmnr-ai/lmnr 0.7.11 → 0.7.12

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 CHANGED
@@ -27,7 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  var import_commander = require("commander");
28
28
 
29
29
  // package.json
30
- var version = "0.7.11";
30
+ var version = "0.7.12";
31
31
 
32
32
  // src/utils.ts
33
33
  var import_api = require("@opentelemetry/api");
@@ -143,6 +143,125 @@ var import_api3 = require("@opentelemetry/api");
143
143
  // src/opentelemetry-lib/tracing/context.ts
144
144
  var import_api2 = require("@opentelemetry/api");
145
145
  var import_async_hooks = require("async_hooks");
146
+
147
+ // src/opentelemetry-lib/tracing/compat.ts
148
+ var import_resources = require("@opentelemetry/resources");
149
+ var makeSpanOtelV2Compatible = (span) => {
150
+ if (span.instrumentationScope && !span.instrumentationLibrary) {
151
+ Object.assign(span, {
152
+ instrumentationLibrary: span.instrumentationScope
153
+ });
154
+ } else if (span.instrumentationLibrary && !span.instrumentationScope) {
155
+ Object.assign(span, {
156
+ instrumentationScope: span.instrumentationLibrary
157
+ });
158
+ }
159
+ };
160
+ var getParentSpanId = (span) => span.parentSpanContext?.spanId ?? span.parentSpanId;
161
+
162
+ // src/opentelemetry-lib/tracing/span.ts
163
+ var LaminarSpan = class {
164
+ constructor(span, activated) {
165
+ this._activated = activated ?? false;
166
+ this._span = span;
167
+ this.name = this._span.name;
168
+ this.kind = this._span.kind;
169
+ this.startTime = this._span.startTime;
170
+ this.endTime = this._span.endTime;
171
+ this.status = this._span.status;
172
+ this.attributes = this._span.attributes;
173
+ this.links = this._span.links;
174
+ this.events = this._span.events;
175
+ this.duration = this._span.duration;
176
+ this.ended = this._span.ended;
177
+ this.resource = this._span.resource;
178
+ this.instrumentationLibrary = this._span.instrumentationLibrary;
179
+ this.droppedAttributesCount = this._span.droppedAttributesCount;
180
+ this.droppedEventsCount = this._span.droppedEventsCount;
181
+ this.droppedLinksCount = this._span.droppedLinksCount;
182
+ this.makeOtelV2Compatible();
183
+ LaminarContextManager.addActiveSpan(this.spanContext().spanId);
184
+ }
185
+ spanContext() {
186
+ return this._span.spanContext();
187
+ }
188
+ setAttribute(key, value) {
189
+ this._span.setAttribute(key, value);
190
+ return this;
191
+ }
192
+ setAttributes(attributes) {
193
+ this._span.setAttributes(attributes);
194
+ return this;
195
+ }
196
+ addEvent(name, attributesOrStartTime, startTime) {
197
+ this._span.addEvent(name, attributesOrStartTime, startTime);
198
+ return this;
199
+ }
200
+ addLink(link) {
201
+ this._span.addLink(link);
202
+ return this;
203
+ }
204
+ addLinks(links) {
205
+ this._span.addLinks(links);
206
+ return this;
207
+ }
208
+ setStatus(status) {
209
+ this._span.setStatus(status);
210
+ return this;
211
+ }
212
+ updateName(name) {
213
+ this._span.updateName(name);
214
+ return this;
215
+ }
216
+ end(endTime) {
217
+ if (!this._span.isRecording()) {
218
+ return this._span.end(endTime);
219
+ }
220
+ LaminarContextManager.removeActiveSpan(this.spanContext().spanId);
221
+ if (this._activated) {
222
+ LaminarContextManager.popContext();
223
+ }
224
+ return this._span.end(endTime);
225
+ }
226
+ set activated(activated) {
227
+ this._activated = activated;
228
+ }
229
+ isRecording() {
230
+ return this._span.isRecording();
231
+ }
232
+ recordException(exception, time) {
233
+ return this._span.recordException(exception, time);
234
+ }
235
+ // ================================
236
+ // OTel V2 compatibility
237
+ // ================================
238
+ makeOtelV2Compatible() {
239
+ makeSpanOtelV2Compatible(this._span);
240
+ }
241
+ get instrumentationScope() {
242
+ return this._span.instrumentationLibrary;
243
+ }
244
+ get parentSpanContext() {
245
+ const parentSpanId = this._span.parentSpanId;
246
+ if (!parentSpanId) {
247
+ return void 0;
248
+ }
249
+ return {
250
+ spanId: parentSpanId,
251
+ traceId: this.spanContext().traceId,
252
+ // TODO: somehow get the traceFlags from the parent span
253
+ traceFlags: this.spanContext().traceFlags
254
+ };
255
+ }
256
+ getParentSpanId() {
257
+ return getParentSpanId(this._span);
258
+ }
259
+ get isActivated() {
260
+ return this._activated;
261
+ }
262
+ };
263
+
264
+ // src/opentelemetry-lib/tracing/context.ts
146
265
  var LaminarContextManager = class {
147
266
  static getContext() {
148
267
  const contexts = this._asyncLocalStorage.getStore() || [];
@@ -155,6 +274,12 @@ var LaminarContextManager = class {
155
274
  if (!span.isRecording() && span.spanContext().isRemote) {
156
275
  return context;
157
276
  }
277
+ if (!(span instanceof LaminarSpan)) {
278
+ return context;
279
+ }
280
+ if (!span.isActivated) {
281
+ return context;
282
+ }
158
283
  try {
159
284
  const isActive = this._activeSpans.has(span.spanContext().spanId);
160
285
  if (isActive) {