@langfuse/core 5.3.0-beta.0 → 5.4.0-beta.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/dist/index.cjs CHANGED
@@ -38,6 +38,7 @@ __export(index_exports, {
38
38
  LANGFUSE_SDK_NAME: () => LANGFUSE_SDK_NAME,
39
39
  LANGFUSE_SDK_VERSION: () => LANGFUSE_SDK_VERSION,
40
40
  LANGFUSE_TRACER_NAME: () => LANGFUSE_TRACER_NAME,
41
+ LANGFUSE_TRACE_ID_BAGGAGE_KEY: () => LANGFUSE_TRACE_ID_BAGGAGE_KEY,
41
42
  LangfuseAPIClient: () => LangfuseAPIClient,
42
43
  LangfuseAPIError: () => LangfuseAPIError,
43
44
  LangfuseAPITimeoutError: () => LangfuseAPITimeoutError,
@@ -80,6 +81,7 @@ __export(index_exports, {
80
81
  generateUUID: () => generateUUID,
81
82
  getEnv: () => getEnv,
82
83
  getGlobalLogger: () => getGlobalLogger,
84
+ getLangfuseTraceIdFromBaggage: () => getLangfuseTraceIdFromBaggage,
83
85
  getPropagatedAttributesFromContext: () => getPropagatedAttributesFromContext,
84
86
  health: () => health_exports,
85
87
  ingestion: () => ingestion_exports,
@@ -103,6 +105,7 @@ __export(index_exports, {
103
105
  scores: () => scores_exports,
104
106
  serializeValue: () => serializeValue,
105
107
  sessions: () => sessions_exports,
108
+ setLangfuseTraceIdInBaggage: () => setLangfuseTraceIdInBaggage,
106
109
  trace: () => trace_exports,
107
110
  utils: () => utils_exports
108
111
  });
@@ -380,7 +383,7 @@ var resetGlobalLogger = () => {
380
383
  // package.json
381
384
  var package_default = {
382
385
  name: "@langfuse/core",
383
- version: "5.3.0-beta.0",
386
+ version: "5.4.0-beta.0",
384
387
  description: "Core functions and utilities for Langfuse packages",
385
388
  type: "module",
386
389
  sideEffects: false,
@@ -451,6 +454,7 @@ var LangfuseOtelSpanAttributes = /* @__PURE__ */ ((LangfuseOtelSpanAttributes2)
451
454
  LangfuseOtelSpanAttributes2["RELEASE"] = "langfuse.release";
452
455
  LangfuseOtelSpanAttributes2["VERSION"] = "langfuse.version";
453
456
  LangfuseOtelSpanAttributes2["AS_ROOT"] = "langfuse.internal.as_root";
457
+ LangfuseOtelSpanAttributes2["IS_APP_ROOT"] = "langfuse.internal.is_app_root";
454
458
  LangfuseOtelSpanAttributes2["EXPERIMENT_ID"] = "langfuse.experiment.id";
455
459
  LangfuseOtelSpanAttributes2["EXPERIMENT_NAME"] = "langfuse.experiment.name";
456
460
  LangfuseOtelSpanAttributes2["EXPERIMENT_DESCRIPTION"] = "langfuse.experiment.description";
@@ -12467,6 +12471,23 @@ var LangfuseOtelContextKeys = {
12467
12471
  };
12468
12472
  var LANGFUSE_BAGGAGE_PREFIX = "langfuse_";
12469
12473
  var LANGFUSE_BAGGAGE_TAGS_SEPARATOR = ",";
12474
+ var LANGFUSE_TRACE_ID_BAGGAGE_KEY = "langfuse_trace_id";
12475
+ function getLangfuseTraceIdFromBaggage(context) {
12476
+ const baggage = import_api.propagation.getBaggage(context);
12477
+ const entry = baggage == null ? void 0 : baggage.getEntry(LANGFUSE_TRACE_ID_BAGGAGE_KEY);
12478
+ if (!(entry == null ? void 0 : entry.value)) return void 0;
12479
+ return entry.value.toLowerCase();
12480
+ }
12481
+ function setLangfuseTraceIdInBaggage(context, traceId) {
12482
+ var _a2;
12483
+ const normalized = traceId.toLowerCase();
12484
+ if (getLangfuseTraceIdFromBaggage(context) === normalized) return context;
12485
+ const baggage = (_a2 = import_api.propagation.getBaggage(context)) != null ? _a2 : import_api.propagation.createBaggage();
12486
+ const updated = baggage.setEntry(LANGFUSE_TRACE_ID_BAGGAGE_KEY, {
12487
+ value: normalized
12488
+ });
12489
+ return import_api.propagation.setBaggage(context, updated);
12490
+ }
12470
12491
  function propagateAttributes(params, fn) {
12471
12492
  var _a2;
12472
12493
  let context = import_api.context.active();
@@ -12591,6 +12612,7 @@ function getPropagatedAttributesFromContext(context) {
12591
12612
  const baggage = import_api.propagation.getBaggage(context);
12592
12613
  if (baggage) {
12593
12614
  baggage.getAllEntries().forEach(([baggageKey, baggageEntry]) => {
12615
+ if (baggageKey === LANGFUSE_TRACE_ID_BAGGAGE_KEY) return;
12594
12616
  if (baggageKey.startsWith(LANGFUSE_BAGGAGE_PREFIX)) {
12595
12617
  const spanKey = getSpanKeyFromBaggageKey(baggageKey);
12596
12618
  if (spanKey) {
@@ -12852,6 +12874,7 @@ function getSpanKeyFromBaggageKey(baggageKey) {
12852
12874
  LANGFUSE_SDK_NAME,
12853
12875
  LANGFUSE_SDK_VERSION,
12854
12876
  LANGFUSE_TRACER_NAME,
12877
+ LANGFUSE_TRACE_ID_BAGGAGE_KEY,
12855
12878
  LangfuseAPIClient,
12856
12879
  LangfuseAPIError,
12857
12880
  LangfuseAPITimeoutError,
@@ -12894,6 +12917,7 @@ function getSpanKeyFromBaggageKey(baggageKey) {
12894
12917
  generateUUID,
12895
12918
  getEnv,
12896
12919
  getGlobalLogger,
12920
+ getLangfuseTraceIdFromBaggage,
12897
12921
  getPropagatedAttributesFromContext,
12898
12922
  health,
12899
12923
  ingestion,
@@ -12917,6 +12941,7 @@ function getSpanKeyFromBaggageKey(baggageKey) {
12917
12941
  scores,
12918
12942
  serializeValue,
12919
12943
  sessions,
12944
+ setLangfuseTraceIdInBaggage,
12920
12945
  trace,
12921
12946
  utils
12922
12947
  });