@mastra/langfuse 1.5.3 → 1.5.4-alpha.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
@@ -1,6 +1,6 @@
1
1
  # @mastra/langfuse
2
2
 
3
- Langfuse AI Observability exporter for Mastra applications.
3
+ Export Mastra traces to Langfuse for open-source LLM observability, configure credentials and endpoints, and inspect prompts, tools, and generations.
4
4
 
5
5
  ## Installation
6
6
 
@@ -10,103 +10,33 @@ npm install @mastra/langfuse
10
10
 
11
11
  ## Usage
12
12
 
13
- ### Zero-Config Setup
14
-
15
- The exporter automatically reads credentials from environment variables:
16
-
17
- ```bash
18
- # Required
19
- LANGFUSE_PUBLIC_KEY=pk-lf-...
20
- LANGFUSE_SECRET_KEY=sk-lf-...
21
-
22
- # Optional - defaults to Langfuse cloud
23
- LANGFUSE_BASE_URL=https://cloud.langfuse.com
24
- ```
13
+ Set `LANGFUSE_PUBLIC_KEY` and `LANGFUSE_SECRET_KEY` before creating the exporter.
25
14
 
26
15
  ```typescript
16
+ import { Mastra } from '@mastra/core/mastra';
17
+ import { Observability } from '@mastra/observability';
27
18
  import { LangfuseExporter } from '@mastra/langfuse';
28
19
 
29
- const mastra = new Mastra({
30
- ...,
31
- observability: {
20
+ export const mastra = new Mastra({
21
+ observability: new Observability({
32
22
  configs: {
33
23
  langfuse: {
34
24
  serviceName: 'my-service',
35
25
  exporters: [new LangfuseExporter()],
36
26
  },
37
27
  },
38
- },
28
+ }),
39
29
  });
40
30
  ```
41
31
 
42
- ### Explicit Configuration
43
-
44
- You can also pass credentials directly:
45
-
46
- ```typescript
47
- import { LangfuseExporter } from '@mastra/langfuse';
48
-
49
- const mastra = new Mastra({
50
- ...,
51
- observability: {
52
- configs: {
53
- langfuse: {
54
- serviceName: 'my-service',
55
- exporters: [
56
- new LangfuseExporter({
57
- publicKey: 'pk-lf-...',
58
- secretKey: 'sk-lf-...',
59
- baseUrl: 'https://cloud.langfuse.com', // Optional
60
- additionalHeaders: { 'x-custom-header': 'custom-value' }, // Optional
61
- realtime: true, // Optional - flush after each event
62
- flushAt: 200, // Optional - spans per OTEL batch
63
- flushInterval: 15, // Optional - seconds between OTEL batch flushes
64
- }),
65
- ],
66
- },
67
- },
68
- },
69
- });
70
- ```
71
-
72
- ### Configuration Options
73
-
74
- | Option | Type | Description |
75
- | ------------------- | ------------------------ | ---------------------------------------------------------------------------- |
76
- | `publicKey` | `string` | Langfuse public key. Defaults to `LANGFUSE_PUBLIC_KEY` env var |
77
- | `secretKey` | `string` | Langfuse secret key. Defaults to `LANGFUSE_SECRET_KEY` env var |
78
- | `baseUrl` | `string` | Langfuse host URL. Defaults to `LANGFUSE_BASE_URL` env var or Langfuse cloud |
79
- | `additionalHeaders` | `Record<string, string>` | Additional headers sent with requests to Langfuse |
80
- | `realtime` | `boolean` | Flush after each event for immediate visibility. Defaults to `false` |
81
- | `flushAt` | `number` | Maximum number of spans per OTEL export batch |
82
- | `flushInterval` | `number` | Maximum time in seconds before pending spans are exported |
83
- | `environment` | `string` | Langfuse tracing environment tag |
84
- | `release` | `string` | Langfuse release tag |
85
-
86
- ### High-Volume Streaming
87
-
88
- For self-hosted Langfuse deployments under load, increase the OTEL batch size and flush interval to reduce request pressure:
89
-
90
- ```typescript
91
- new LangfuseExporter({
92
- flushAt: 500,
93
- flushInterval: 20,
94
- });
95
- ```
32
+ ## Documentation
96
33
 
97
- `flushAt` and `flushInterval` map directly to the upstream `LangfuseSpanProcessor` options, so you can cross-reference Langfuse OTEL documentation when tuning them.
34
+ - [Langfuse](https://mastra.ai/integrations/observability/langfuse)
98
35
 
99
- To suppress high-volume `MODEL_CHUNK` spans, use the observability-level `excludeSpanTypes` option. See the [span filtering reference](https://mastra.ai/reference/observability/tracing/span-filtering) for details.
36
+ ## Changelog
100
37
 
101
- ## Features
38
+ See the [package changelog](https://github.com/mastra-ai/mastra/blob/main/observability/langfuse/CHANGELOG.md) for version history and release notes.
102
39
 
103
- ### Tracing
40
+ ## Support
104
41
 
105
- - **Automatic span mapping**: Root spans become Langfuse traces
106
- - **Official Langfuse OTEL export**: Uses `@langfuse/otel` and `@langfuse/client`
107
- - **Model generation support**: `MODEL_GENERATION` spans are mapped into Langfuse generations with usage data
108
- - **Type-specific metadata**: Preserves agent, tool, workflow, and span metadata
109
- - **Prompt linking and TTFT**: Maps Mastra tracing metadata into Langfuse OTEL attributes
110
- - **Error tracking**: Preserves span failures and error details in exported traces
111
- - **Hierarchical traces**: Maintains parent-child relationships across exported spans
112
- - **Batch tuning for self-hosted deployments**: Exposes OTEL batch size and interval controls
42
+ We have an [open community Discord](https://discord.gg/mastra-ai). Come and say hello and let us know if you have any questions or need any help getting things running.
@@ -1 +1 @@
1
- {"version":3,"file":"tracing.d.ts","sourceRoot":"","sources":["../src/tracing.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,KAAK,EAAE,YAAY,EAAmB,mBAAmB,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAEjH,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAKhE,eAAO,MAAM,yBAAyB,+BAA+B,CAAC;AAEtE,MAAM,WAAW,sBAAuB,SAAQ,kBAAkB;IAChE,0BAA0B;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0BAA0B;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iEAAiE;IACjE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wDAAwD;IACxD,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,oDAAoD;IACpD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gEAAgE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AAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,MAAM,CAAC;QACnB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KAChC,GAAG,OAAO,CAAC,IAAI,CAAC,CAUhB;IAEK,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAE3B;IAEK,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAE9B;CACF"}
package/package.json CHANGED
@@ -1,13 +1,12 @@
1
1
  {
2
2
  "name": "@mastra/langfuse",
3
- "version": "1.5.3",
3
+ "version": "1.5.4-alpha.1",
4
4
  "description": "Langfuse observability provider for Mastra - uses official Langfuse v5 SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "files": [
9
- "dist",
10
- "CHANGELOG.md"
9
+ "dist"
11
10
  ],
12
11
  "exports": {
13
12
  ".": {
@@ -26,8 +25,8 @@
26
25
  "dependencies": {
27
26
  "@langfuse/client": "^5.9.1",
28
27
  "@langfuse/otel": "^5.9.1",
29
- "@mastra/observability": "1.17.4",
30
- "@mastra/otel-exporter": "1.3.12"
28
+ "@mastra/otel-exporter": "1.3.13-alpha.1",
29
+ "@mastra/observability": "1.17.5-alpha.1"
31
30
  },
32
31
  "devDependencies": {
33
32
  "@opentelemetry/api": "^1.9.1",
@@ -37,11 +36,11 @@
37
36
  "@vitest/ui": "4.1.10",
38
37
  "eslint": "^10.7.0",
39
38
  "tsdown": "0.22.9",
40
- "typescript": "^6.0.3",
39
+ "typescript": "^7.0.2",
41
40
  "vitest": "4.1.10",
42
- "@internal/lint": "0.0.128",
43
- "@internal/types-builder": "0.0.103",
44
- "@mastra/core": "1.63.1"
41
+ "@internal/lint": "0.0.129",
42
+ "@internal/types-builder": "0.0.104",
43
+ "@mastra/core": "1.64.0-alpha.7"
45
44
  },
46
45
  "peerDependencies": {
47
46
  "@mastra/core": ">=1.16.0-0 <2.0.0-0",