@langfuse/core 4.4.10 → 4.5.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/dist/index.cjs CHANGED
@@ -81,8 +81,10 @@ __export(index_exports, {
81
81
  logger: () => LoggerSingleton,
82
82
  media: () => media_exports,
83
83
  metrics: () => metrics_exports,
84
+ metricsV2: () => metricsV2_exports,
84
85
  models: () => models_exports,
85
86
  observations: () => observations_exports,
87
+ observationsV2: () => observationsV2_exports,
86
88
  opentelemetry: () => opentelemetry_exports,
87
89
  organizations: () => organizations_exports,
88
90
  projects: () => projects_exports,
@@ -351,7 +353,7 @@ var resetGlobalLogger = () => {
351
353
  // package.json
352
354
  var package_default = {
353
355
  name: "@langfuse/core",
354
- version: "4.4.10-alpha.3",
356
+ version: "4.5.0",
355
357
  description: "Core functions and utilities for Langfuse packages",
356
358
  type: "module",
357
359
  sideEffects: false,
@@ -808,12 +810,18 @@ var MediaContentType = {
808
810
  ApplicationX7ZCompressed: "application/x-7z-compressed"
809
811
  };
810
812
 
813
+ // src/api/api/resources/metricsV2/index.ts
814
+ var metricsV2_exports = {};
815
+
811
816
  // src/api/api/resources/metrics/index.ts
812
817
  var metrics_exports = {};
813
818
 
814
819
  // src/api/api/resources/models/index.ts
815
820
  var models_exports = {};
816
821
 
822
+ // src/api/api/resources/observationsV2/index.ts
823
+ var observationsV2_exports = {};
824
+
817
825
  // src/api/api/resources/observations/index.ts
818
826
  var observations_exports = {};
819
827
 
@@ -5686,6 +5694,232 @@ var Media = class {
5686
5694
  }
5687
5695
  };
5688
5696
 
5697
+ // src/api/api/resources/metricsV2/client/Client.ts
5698
+ var MetricsV2 = class {
5699
+ constructor(_options) {
5700
+ this._options = _options;
5701
+ }
5702
+ /**
5703
+ * Get metrics from the Langfuse project using a query object. V2 endpoint with optimized performance.
5704
+ *
5705
+ * ## V2 Differences
5706
+ * - Supports `observations`, `scores-numeric`, and `scores-categorical` views only (traces view not supported)
5707
+ * - Direct access to tags and release fields on observations
5708
+ * - Backwards-compatible: traceName, traceRelease, traceVersion dimensions are still available on observations view
5709
+ * - High cardinality dimensions are not supported and will return a 400 error (see below)
5710
+ *
5711
+ * For more details, see the [Metrics API documentation](https://langfuse.com/docs/metrics/features/metrics-api).
5712
+ *
5713
+ * ## Available Views
5714
+ *
5715
+ * ### observations
5716
+ * Query observation-level data (spans, generations, events).
5717
+ *
5718
+ * **Dimensions:**
5719
+ * - `environment` - Deployment environment (e.g., production, staging)
5720
+ * - `type` - Type of observation (SPAN, GENERATION, EVENT)
5721
+ * - `name` - Name of the observation
5722
+ * - `level` - Logging level of the observation
5723
+ * - `version` - Version of the observation
5724
+ * - `tags` - User-defined tags
5725
+ * - `release` - Release version
5726
+ * - `traceName` - Name of the parent trace (backwards-compatible)
5727
+ * - `traceRelease` - Release version of the parent trace (backwards-compatible, maps to release)
5728
+ * - `traceVersion` - Version of the parent trace (backwards-compatible, maps to version)
5729
+ * - `providedModelName` - Name of the model used
5730
+ * - `promptName` - Name of the prompt used
5731
+ * - `promptVersion` - Version of the prompt used
5732
+ * - `startTimeMonth` - Month of start_time in YYYY-MM format
5733
+ *
5734
+ * **Measures:**
5735
+ * - `count` - Total number of observations
5736
+ * - `latency` - Observation latency (milliseconds)
5737
+ * - `streamingLatency` - Generation latency from completion start to end (milliseconds)
5738
+ * - `inputTokens` - Sum of input tokens consumed
5739
+ * - `outputTokens` - Sum of output tokens produced
5740
+ * - `totalTokens` - Sum of all tokens consumed
5741
+ * - `outputTokensPerSecond` - Output tokens per second
5742
+ * - `tokensPerSecond` - Total tokens per second
5743
+ * - `inputCost` - Input cost (USD)
5744
+ * - `outputCost` - Output cost (USD)
5745
+ * - `totalCost` - Total cost (USD)
5746
+ * - `timeToFirstToken` - Time to first token (milliseconds)
5747
+ * - `countScores` - Number of scores attached to the observation
5748
+ *
5749
+ * ### scores-numeric
5750
+ * Query numeric and boolean score data.
5751
+ *
5752
+ * **Dimensions:**
5753
+ * - `environment` - Deployment environment
5754
+ * - `name` - Name of the score (e.g., accuracy, toxicity)
5755
+ * - `source` - Origin of the score (API, ANNOTATION, EVAL)
5756
+ * - `dataType` - Data type (NUMERIC, BOOLEAN)
5757
+ * - `configId` - Identifier of the score config
5758
+ * - `timestampMonth` - Month in YYYY-MM format
5759
+ * - `timestampDay` - Day in YYYY-MM-DD format
5760
+ * - `value` - Numeric value of the score
5761
+ * - `traceName` - Name of the parent trace
5762
+ * - `tags` - Tags
5763
+ * - `traceRelease` - Release version
5764
+ * - `traceVersion` - Version
5765
+ * - `observationName` - Name of the associated observation
5766
+ * - `observationModelName` - Model name of the associated observation
5767
+ * - `observationPromptName` - Prompt name of the associated observation
5768
+ * - `observationPromptVersion` - Prompt version of the associated observation
5769
+ *
5770
+ * **Measures:**
5771
+ * - `count` - Total number of scores
5772
+ * - `value` - Score value (for aggregations)
5773
+ *
5774
+ * ### scores-categorical
5775
+ * Query categorical score data. Same dimensions as scores-numeric except uses `stringValue` instead of `value`.
5776
+ *
5777
+ * **Measures:**
5778
+ * - `count` - Total number of scores
5779
+ *
5780
+ * ## High Cardinality Dimensions
5781
+ * The following dimensions cannot be used as grouping dimensions in v2 metrics API as they can cause performance issues.
5782
+ * Use them in filters instead.
5783
+ *
5784
+ * **observations view:**
5785
+ * - `id` - Use traceId filter to narrow down results
5786
+ * - `traceId` - Use traceId filter instead
5787
+ * - `userId` - Use userId filter instead
5788
+ * - `sessionId` - Use sessionId filter instead
5789
+ * - `parentObservationId` - Use parentObservationId filter instead
5790
+ *
5791
+ * **scores-numeric / scores-categorical views:**
5792
+ * - `id` - Use specific filters to narrow down results
5793
+ * - `traceId` - Use traceId filter instead
5794
+ * - `userId` - Use userId filter instead
5795
+ * - `sessionId` - Use sessionId filter instead
5796
+ * - `observationId` - Use observationId filter instead
5797
+ *
5798
+ * ## Aggregations
5799
+ * Available aggregation functions: `sum`, `avg`, `count`, `max`, `min`, `p50`, `p75`, `p90`, `p95`, `p99`, `histogram`
5800
+ *
5801
+ * ## Time Granularities
5802
+ * Available granularities for timeDimension: `auto`, `minute`, `hour`, `day`, `week`, `month`
5803
+ * - `auto` bins the data into approximately 50 buckets based on the time range
5804
+ *
5805
+ * @param {LangfuseAPI.GetMetricsV2Request} request
5806
+ * @param {MetricsV2.RequestOptions} requestOptions - Request-specific configuration.
5807
+ *
5808
+ * @throws {@link LangfuseAPI.Error}
5809
+ * @throws {@link LangfuseAPI.UnauthorizedError}
5810
+ * @throws {@link LangfuseAPI.AccessDeniedError}
5811
+ * @throws {@link LangfuseAPI.MethodNotAllowedError}
5812
+ * @throws {@link LangfuseAPI.NotFoundError}
5813
+ *
5814
+ * @example
5815
+ * await client.metricsV2.metrics({
5816
+ * query: "query"
5817
+ * })
5818
+ */
5819
+ metrics(request, requestOptions) {
5820
+ return HttpResponsePromise.fromPromise(
5821
+ this.__metrics(request, requestOptions)
5822
+ );
5823
+ }
5824
+ async __metrics(request, requestOptions) {
5825
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
5826
+ const { query } = request;
5827
+ const _queryParams = {};
5828
+ _queryParams["query"] = query;
5829
+ let _headers = mergeHeaders(
5830
+ (_a2 = this._options) == null ? void 0 : _a2.headers,
5831
+ mergeOnlyDefinedHeaders({
5832
+ Authorization: await this._getAuthorizationHeader(),
5833
+ "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
5834
+ "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
5835
+ "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
5836
+ }),
5837
+ requestOptions == null ? void 0 : requestOptions.headers
5838
+ );
5839
+ const _response = await fetcher({
5840
+ url: url_exports.join(
5841
+ (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
5842
+ "/api/public/v2/metrics"
5843
+ ),
5844
+ method: "GET",
5845
+ headers: _headers,
5846
+ queryParameters: { ..._queryParams, ...requestOptions == null ? void 0 : requestOptions.queryParams },
5847
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
5848
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
5849
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
5850
+ });
5851
+ if (_response.ok) {
5852
+ return {
5853
+ data: _response.body,
5854
+ rawResponse: _response.rawResponse
5855
+ };
5856
+ }
5857
+ if (_response.error.reason === "status-code") {
5858
+ switch (_response.error.statusCode) {
5859
+ case 400:
5860
+ throw new Error2(
5861
+ _response.error.body,
5862
+ _response.rawResponse
5863
+ );
5864
+ case 401:
5865
+ throw new UnauthorizedError(
5866
+ _response.error.body,
5867
+ _response.rawResponse
5868
+ );
5869
+ case 403:
5870
+ throw new AccessDeniedError(
5871
+ _response.error.body,
5872
+ _response.rawResponse
5873
+ );
5874
+ case 405:
5875
+ throw new MethodNotAllowedError(
5876
+ _response.error.body,
5877
+ _response.rawResponse
5878
+ );
5879
+ case 404:
5880
+ throw new NotFoundError(
5881
+ _response.error.body,
5882
+ _response.rawResponse
5883
+ );
5884
+ default:
5885
+ throw new LangfuseAPIError({
5886
+ statusCode: _response.error.statusCode,
5887
+ body: _response.error.body,
5888
+ rawResponse: _response.rawResponse
5889
+ });
5890
+ }
5891
+ }
5892
+ switch (_response.error.reason) {
5893
+ case "non-json":
5894
+ throw new LangfuseAPIError({
5895
+ statusCode: _response.error.statusCode,
5896
+ body: _response.error.rawBody,
5897
+ rawResponse: _response.rawResponse
5898
+ });
5899
+ case "timeout":
5900
+ throw new LangfuseAPITimeoutError(
5901
+ "Timeout exceeded when calling GET /api/public/v2/metrics."
5902
+ );
5903
+ case "unknown":
5904
+ throw new LangfuseAPIError({
5905
+ message: _response.error.errorMessage,
5906
+ rawResponse: _response.rawResponse
5907
+ });
5908
+ }
5909
+ }
5910
+ async _getAuthorizationHeader() {
5911
+ const username = await Supplier.get(this._options.username);
5912
+ const password = await Supplier.get(this._options.password);
5913
+ if (username != null && password != null) {
5914
+ return BasicAuth.toAuthorizationHeader({
5915
+ username,
5916
+ password
5917
+ });
5918
+ }
5919
+ return void 0;
5920
+ }
5921
+ };
5922
+
5689
5923
  // src/api/api/resources/metrics/client/Client.ts
5690
5924
  var Metrics = class {
5691
5925
  constructor(_options) {
@@ -6261,6 +6495,217 @@ var Models = class {
6261
6495
  }
6262
6496
  };
6263
6497
 
6498
+ // src/api/api/resources/observationsV2/client/Client.ts
6499
+ var ObservationsV2 = class {
6500
+ constructor(_options) {
6501
+ this._options = _options;
6502
+ }
6503
+ /**
6504
+ * Get a list of observations with cursor-based pagination and flexible field selection.
6505
+ *
6506
+ * ## Cursor-based Pagination
6507
+ * This endpoint uses cursor-based pagination for efficient traversal of large datasets.
6508
+ * The cursor is returned in the response metadata and should be passed in subsequent requests
6509
+ * to retrieve the next page of results.
6510
+ *
6511
+ * ## Field Selection
6512
+ * Use the `fields` parameter to control which observation fields are returned:
6513
+ * - `core` - Always included: id, traceId, startTime, endTime, projectId, parentObservationId, type
6514
+ * - `basic` - name, level, statusMessage, version, environment, bookmarked, public, userId, sessionId
6515
+ * - `time` - completionStartTime, createdAt, updatedAt
6516
+ * - `io` - input, output
6517
+ * - `metadata` - metadata
6518
+ * - `model` - providedModelName, internalModelId, modelParameters
6519
+ * - `usage` - usageDetails, costDetails, totalCost
6520
+ * - `prompt` - promptId, promptName, promptVersion
6521
+ * - `metrics` - latency, timeToFirstToken
6522
+ *
6523
+ * If not specified, `core` and `basic` field groups are returned.
6524
+ *
6525
+ * ## Filters
6526
+ * Multiple filtering options are available via query parameters or the structured `filter` parameter.
6527
+ * When using the `filter` parameter, it takes precedence over individual query parameter filters.
6528
+ *
6529
+ * @param {LangfuseAPI.GetObservationsV2Request} request
6530
+ * @param {ObservationsV2.RequestOptions} requestOptions - Request-specific configuration.
6531
+ *
6532
+ * @throws {@link LangfuseAPI.Error}
6533
+ * @throws {@link LangfuseAPI.UnauthorizedError}
6534
+ * @throws {@link LangfuseAPI.AccessDeniedError}
6535
+ * @throws {@link LangfuseAPI.MethodNotAllowedError}
6536
+ * @throws {@link LangfuseAPI.NotFoundError}
6537
+ *
6538
+ * @example
6539
+ * await client.observationsV2.getMany()
6540
+ */
6541
+ getMany(request = {}, requestOptions) {
6542
+ return HttpResponsePromise.fromPromise(
6543
+ this.__getMany(request, requestOptions)
6544
+ );
6545
+ }
6546
+ async __getMany(request = {}, requestOptions) {
6547
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
6548
+ const {
6549
+ fields,
6550
+ limit,
6551
+ cursor,
6552
+ parseIoAsJson,
6553
+ name,
6554
+ userId,
6555
+ type: type_,
6556
+ traceId,
6557
+ level,
6558
+ parentObservationId,
6559
+ environment,
6560
+ fromStartTime,
6561
+ toStartTime,
6562
+ version,
6563
+ filter
6564
+ } = request;
6565
+ const _queryParams = {};
6566
+ if (fields != null) {
6567
+ _queryParams["fields"] = fields;
6568
+ }
6569
+ if (limit != null) {
6570
+ _queryParams["limit"] = limit.toString();
6571
+ }
6572
+ if (cursor != null) {
6573
+ _queryParams["cursor"] = cursor;
6574
+ }
6575
+ if (parseIoAsJson != null) {
6576
+ _queryParams["parseIoAsJson"] = parseIoAsJson.toString();
6577
+ }
6578
+ if (name != null) {
6579
+ _queryParams["name"] = name;
6580
+ }
6581
+ if (userId != null) {
6582
+ _queryParams["userId"] = userId;
6583
+ }
6584
+ if (type_ != null) {
6585
+ _queryParams["type"] = type_;
6586
+ }
6587
+ if (traceId != null) {
6588
+ _queryParams["traceId"] = traceId;
6589
+ }
6590
+ if (level != null) {
6591
+ _queryParams["level"] = level;
6592
+ }
6593
+ if (parentObservationId != null) {
6594
+ _queryParams["parentObservationId"] = parentObservationId;
6595
+ }
6596
+ if (environment != null) {
6597
+ if (Array.isArray(environment)) {
6598
+ _queryParams["environment"] = environment.map((item) => item);
6599
+ } else {
6600
+ _queryParams["environment"] = environment;
6601
+ }
6602
+ }
6603
+ if (fromStartTime != null) {
6604
+ _queryParams["fromStartTime"] = fromStartTime;
6605
+ }
6606
+ if (toStartTime != null) {
6607
+ _queryParams["toStartTime"] = toStartTime;
6608
+ }
6609
+ if (version != null) {
6610
+ _queryParams["version"] = version;
6611
+ }
6612
+ if (filter != null) {
6613
+ _queryParams["filter"] = filter;
6614
+ }
6615
+ let _headers = mergeHeaders(
6616
+ (_a2 = this._options) == null ? void 0 : _a2.headers,
6617
+ mergeOnlyDefinedHeaders({
6618
+ Authorization: await this._getAuthorizationHeader(),
6619
+ "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
6620
+ "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
6621
+ "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
6622
+ }),
6623
+ requestOptions == null ? void 0 : requestOptions.headers
6624
+ );
6625
+ const _response = await fetcher({
6626
+ url: url_exports.join(
6627
+ (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
6628
+ "/api/public/v2/observations"
6629
+ ),
6630
+ method: "GET",
6631
+ headers: _headers,
6632
+ queryParameters: { ..._queryParams, ...requestOptions == null ? void 0 : requestOptions.queryParams },
6633
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
6634
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
6635
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
6636
+ });
6637
+ if (_response.ok) {
6638
+ return {
6639
+ data: _response.body,
6640
+ rawResponse: _response.rawResponse
6641
+ };
6642
+ }
6643
+ if (_response.error.reason === "status-code") {
6644
+ switch (_response.error.statusCode) {
6645
+ case 400:
6646
+ throw new Error2(
6647
+ _response.error.body,
6648
+ _response.rawResponse
6649
+ );
6650
+ case 401:
6651
+ throw new UnauthorizedError(
6652
+ _response.error.body,
6653
+ _response.rawResponse
6654
+ );
6655
+ case 403:
6656
+ throw new AccessDeniedError(
6657
+ _response.error.body,
6658
+ _response.rawResponse
6659
+ );
6660
+ case 405:
6661
+ throw new MethodNotAllowedError(
6662
+ _response.error.body,
6663
+ _response.rawResponse
6664
+ );
6665
+ case 404:
6666
+ throw new NotFoundError(
6667
+ _response.error.body,
6668
+ _response.rawResponse
6669
+ );
6670
+ default:
6671
+ throw new LangfuseAPIError({
6672
+ statusCode: _response.error.statusCode,
6673
+ body: _response.error.body,
6674
+ rawResponse: _response.rawResponse
6675
+ });
6676
+ }
6677
+ }
6678
+ switch (_response.error.reason) {
6679
+ case "non-json":
6680
+ throw new LangfuseAPIError({
6681
+ statusCode: _response.error.statusCode,
6682
+ body: _response.error.rawBody,
6683
+ rawResponse: _response.rawResponse
6684
+ });
6685
+ case "timeout":
6686
+ throw new LangfuseAPITimeoutError(
6687
+ "Timeout exceeded when calling GET /api/public/v2/observations."
6688
+ );
6689
+ case "unknown":
6690
+ throw new LangfuseAPIError({
6691
+ message: _response.error.errorMessage,
6692
+ rawResponse: _response.rawResponse
6693
+ });
6694
+ }
6695
+ }
6696
+ async _getAuthorizationHeader() {
6697
+ const username = await Supplier.get(this._options.username);
6698
+ const password = await Supplier.get(this._options.password);
6699
+ if (username != null && password != null) {
6700
+ return BasicAuth.toAuthorizationHeader({
6701
+ username,
6702
+ password
6703
+ });
6704
+ }
6705
+ return void 0;
6706
+ }
6707
+ };
6708
+
6264
6709
  // src/api/api/resources/observations/client/Client.ts
6265
6710
  var Observations = class {
6266
6711
  constructor(_options) {
@@ -11526,6 +11971,10 @@ var LangfuseAPIClient = class {
11526
11971
  var _a2;
11527
11972
  return (_a2 = this._media) != null ? _a2 : this._media = new Media(this._options);
11528
11973
  }
11974
+ get metricsV2() {
11975
+ var _a2;
11976
+ return (_a2 = this._metricsV2) != null ? _a2 : this._metricsV2 = new MetricsV2(this._options);
11977
+ }
11529
11978
  get metrics() {
11530
11979
  var _a2;
11531
11980
  return (_a2 = this._metrics) != null ? _a2 : this._metrics = new Metrics(this._options);
@@ -11534,6 +11983,10 @@ var LangfuseAPIClient = class {
11534
11983
  var _a2;
11535
11984
  return (_a2 = this._models) != null ? _a2 : this._models = new Models(this._options);
11536
11985
  }
11986
+ get observationsV2() {
11987
+ var _a2;
11988
+ return (_a2 = this._observationsV2) != null ? _a2 : this._observationsV2 = new ObservationsV2(this._options);
11989
+ }
11537
11990
  get observations() {
11538
11991
  var _a2;
11539
11992
  return (_a2 = this._observations) != null ? _a2 : this._observations = new Observations(this._options);
@@ -11763,6 +12216,7 @@ var LangfuseOtelContextKeys = {
11763
12216
  metadata: (0, import_api.createContextKey)("langfuse_metadata"),
11764
12217
  version: (0, import_api.createContextKey)("langfuse_version"),
11765
12218
  tags: (0, import_api.createContextKey)("langfuse_tags"),
12219
+ traceName: (0, import_api.createContextKey)("langfuse_trace_name"),
11766
12220
  // Experiments
11767
12221
  experimentId: (0, import_api.createContextKey)("langfuse_experiment_id"),
11768
12222
  experimentName: (0, import_api.createContextKey)("langfuse_experiment_name"),
@@ -11781,7 +12235,15 @@ function propagateAttributes(params, fn) {
11781
12235
  let context = import_api.context.active();
11782
12236
  const span = import_api.trace.getActiveSpan();
11783
12237
  const asBaggage = (_a2 = params.asBaggage) != null ? _a2 : false;
11784
- const { userId, sessionId, metadata, version, tags, _internalExperiment } = params;
12238
+ const {
12239
+ userId,
12240
+ sessionId,
12241
+ metadata,
12242
+ version,
12243
+ tags,
12244
+ traceName,
12245
+ _internalExperiment
12246
+ } = params;
11785
12247
  if (userId) {
11786
12248
  if (isValidPropagatedString({ value: userId, attributeName: "userId" })) {
11787
12249
  context = setPropagatedAttribute({
@@ -11821,6 +12283,20 @@ function propagateAttributes(params, fn) {
11821
12283
  });
11822
12284
  }
11823
12285
  }
12286
+ if (traceName) {
12287
+ if (isValidPropagatedString({
12288
+ value: traceName,
12289
+ attributeName: "traceName"
12290
+ })) {
12291
+ context = setPropagatedAttribute({
12292
+ key: "traceName",
12293
+ value: traceName,
12294
+ context,
12295
+ span,
12296
+ asBaggage
12297
+ });
12298
+ }
12299
+ }
11824
12300
  if (tags && tags.length > 0) {
11825
12301
  const validTags = tags.filter(
11826
12302
  (tag) => isValidPropagatedString({
@@ -11902,6 +12378,11 @@ function getPropagatedAttributesFromContext(context) {
11902
12378
  const spanKey = getSpanKeyForPropagatedKey("version");
11903
12379
  propagatedAttributes[spanKey] = version;
11904
12380
  }
12381
+ const traceName = context.getValue(LangfuseOtelContextKeys["traceName"]);
12382
+ if (traceName && typeof traceName === "string") {
12383
+ const spanKey = getSpanKeyForPropagatedKey("traceName");
12384
+ propagatedAttributes[spanKey] = traceName;
12385
+ }
11905
12386
  const tags = context.getValue(LangfuseOtelContextKeys["tags"]);
11906
12387
  if (tags && Array.isArray(tags)) {
11907
12388
  const spanKey = getSpanKeyForPropagatedKey("tags");
@@ -12020,6 +12501,8 @@ function getSpanKeyForPropagatedKey(key) {
12020
12501
  return "session.id" /* TRACE_SESSION_ID */;
12021
12502
  case "version":
12022
12503
  return "langfuse.version" /* VERSION */;
12504
+ case "traceName":
12505
+ return "langfuse.trace.name" /* TRACE_NAME */;
12023
12506
  case "metadata":
12024
12507
  return "langfuse.trace.metadata" /* TRACE_METADATA */;
12025
12508
  case "tags":
@@ -12052,6 +12535,8 @@ function getBaggageKeyForPropagatedKey(key) {
12052
12535
  return `${LANGFUSE_BAGGAGE_PREFIX}session_id`;
12053
12536
  case "version":
12054
12537
  return `${LANGFUSE_BAGGAGE_PREFIX}version`;
12538
+ case "traceName":
12539
+ return `${LANGFUSE_BAGGAGE_PREFIX}trace_name`;
12055
12540
  case "metadata":
12056
12541
  return `${LANGFUSE_BAGGAGE_PREFIX}metadata`;
12057
12542
  case "tags":
@@ -12090,6 +12575,8 @@ function getSpanKeyFromBaggageKey(baggageKey) {
12090
12575
  return getSpanKeyForPropagatedKey("sessionId");
12091
12576
  case "version":
12092
12577
  return getSpanKeyForPropagatedKey("version");
12578
+ case "trace_name":
12579
+ return getSpanKeyForPropagatedKey("traceName");
12093
12580
  case "tags":
12094
12581
  return getSpanKeyForPropagatedKey("tags");
12095
12582
  case "experiment_id":
@@ -12171,8 +12658,10 @@ function getSpanKeyFromBaggageKey(baggageKey) {
12171
12658
  logger,
12172
12659
  media,
12173
12660
  metrics,
12661
+ metricsV2,
12174
12662
  models,
12175
12663
  observations,
12664
+ observationsV2,
12176
12665
  opentelemetry,
12177
12666
  organizations,
12178
12667
  projects,