Skip to content

Commit 7b62b90

Browse files
alienzachsaqadri
authored andcommitted
refactor: otel settings have stable (de)serialization (lastmile-ai#551)
* feat: v3 otel settings * fix: reserialization and compatability with tests * fix: align examples with new otel schema * fix: exporter list merge instead of replace\nfeat: replace {} with string\n feat: test cases * fix: unused import * minor fixes * update schema * minor fixes to langfuse * formatter --------- Co-authored-by: Sarmad Qadri <[email protected]>
1 parent 853c7ca commit 7b62b90

File tree

21 files changed

+1021
-363
lines changed

21 files changed

+1021
-363
lines changed

examples/tracing/agent/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ If desired, [install Jaeger locally](https://www.jaegertracing.io/docs/2.5/getti
1616
otel:
1717
enabled: true
1818
exporters:
19-
- type: console
20-
- type: file
21-
- type: otlp
22-
endpoint: "http://localhost:4318/v1/traces"
19+
- console
20+
- file
21+
- otlp:
22+
endpoint: "http://localhost:4318/v1/traces"
2323
```
2424
2525
<img width="2160" alt="Image" src="https://github.com/user-attachments/assets/93ffc4e5-f255-43a9-be3a-755994fec809" />

examples/tracing/agent/mcp_agent.config.yaml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@ openai:
2626

2727
otel:
2828
enabled: true
29-
exporters: [
30-
{ type: console },
31-
{ type: file },
32-
# To export to a collector, also include:
33-
# { type: otlp, endpoint: "http://localhost:4318/v1/traces" },
34-
35-
]
29+
exporters:
30+
- console
31+
- file
32+
# To export to a collector, also include:
33+
# - otlp:
34+
# endpoint: "http://localhost:4318/v1/traces"
3635
service_name: "BasicTracingAgentExample"

examples/tracing/langfuse/README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,25 @@ Obtain a secret and public API key for your desired Langfuse project and then ge
4646
echo -n "pk-your-public-key:sk-your-secret-key" | base64
4747
```
4848

49-
In `mcp_agent.secrets.yaml` set the Authorization header for OTLP (merged automatically with the typed exporter):
49+
In `mcp_agent.secrets.yaml` set the OTLP exporter with the Authorization header (this fully defines the exporter for Langfuse):
5050

5151
```yaml
5252
otel:
53-
otlp_settings:
54-
headers:
55-
Authorization: "Basic AUTH_STRING"
53+
exporters:
54+
- otlp:
55+
endpoint: "https://us.cloud.langfuse.com/api/public/otel/v1/traces"
56+
headers:
57+
Authorization: "Basic AUTH_STRING"
5658
```
5759
58-
Lastly, ensure the proper trace endpoint is configured in the typed exporter in `mcp_agent.config.yaml` for your Langfuse region, e.g.:
60+
The default `mcp_agent.config.yaml` leaves the exporters list commented out so this secrets entry is the only OTLP exporter (preventing a duplicate without headers). For non-authenticated collectors, you can instead define the exporter directly in `mcp_agent.config.yaml` and omit it from `mcp_agent.secrets.yaml`, e.g.:
5961

6062
```yaml
6163
otel:
6264
enabled: true
6365
exporters:
64-
- type: otlp
65-
endpoint: "https://us.cloud.langfuse.com/api/public/otel/v1/traces"
66+
- otlp:
67+
endpoint: "https://some.other.tracing.com"
6668
```
6769

6870
## `4` Run locally

examples/tracing/langfuse/mcp_agent.config.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ openai:
2626

2727
otel:
2828
enabled: true
29-
exporters: [{ type: otlp, endpoint: "https://us.cloud.langfuse.com/api/public/otel/v1/traces" }]
29+
# OTLP exporter (with headers) is defined in mcp_agent.secrets.yaml.
30+
# For non-authenticated collectors, uncomment and configure below:
31+
# exporters:
32+
# - otlp:
33+
# endpoint: "https://some.other.tracing.com"
3034
# Set Authorization header with API key in mcp_agent.secrets.yaml
3135
service_name: "BasicTracingLangfuseExample"

examples/tracing/langfuse/mcp_agent.secrets.yaml.example

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ anthropic:
77
api_key: anthropic_api_key
88

99
otel:
10-
# Headers are merged with typed OTLP exporter settings
11-
otlp_settings:
12-
headers:
13-
Authorization: "Basic <Langfuse AUTH_STRING>"
10+
# Define the Langfuse OTLP exporter (including headers) here so
11+
# mcp_agent.config.yaml does not need a duplicate entry.
12+
exporters:
13+
- otlp:
14+
endpoint: "https://us.cloud.langfuse.com/api/public/otel/v1/traces"
15+
headers:
16+
Authorization: "Basic AUTH_STRING"

examples/tracing/llm/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ Then update the `mcp_agent.config.yaml` to include a typed OTLP exporter with th
2929
otel:
3030
enabled: true
3131
exporters:
32-
- type: console
33-
- type: file
34-
- type: otlp
35-
endpoint: "http://localhost:4318/v1/traces"
32+
- console
33+
- file
34+
- otlp:
35+
endpoint: "http://localhost:4318/v1/traces"
3636
```
3737
3838
<img width="2160" alt="Image" src="https://github.com/user-attachments/assets/f2d1cedf-6729-4ce1-9530-ec9d5653103d" />

examples/tracing/llm/mcp_agent.config.yaml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@ openai:
2626

2727
otel:
2828
enabled: true
29-
exporters: [
30-
{ type: console },
31-
{ type: file },
32-
# To export to a collector, also include:
33-
# { type: otlp, endpoint: "http://localhost:4318/v1/traces" },
34-
]
35-
29+
exporters:
30+
- console
31+
- file
32+
# To export to a collector, also include:
33+
# - otlp:
34+
# endpoint: "http://localhost:4318/v1/traces"
3635
service_name: "BasicTracingLLMExample"

examples/tracing/mcp/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ Then open `mcp_agent.secrets.yaml` and add your api key for your preferred LLM f
5454
otel:
5555
enabled: true
5656
exporters:
57-
- type: otlp
58-
endpoint: "http://localhost:4318/v1/traces"
57+
- otlp:
58+
endpoint: "http://localhost:4318/v1/traces"
5959
```
6060
6161
## `4` Run locally

examples/tracing/mcp/mcp_agent.config.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,7 @@ openai:
1717

1818
otel:
1919
enabled: true
20-
exporters: [{ type: otlp, endpoint: "http://localhost:4318/v1/traces" }]
20+
exporters:
21+
- otlp:
22+
endpoint: "http://localhost:4318/v1/traces"
2123
service_name: "MCPAgentSSEExample"

examples/tracing/temporal/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ To run any of these examples, you'll need to:
5353
otel:
5454
enabled: true
5555
exporters:
56-
- type: otlp
57-
endpoint: "http://localhost:4318/v1/traces"
56+
- otlp:
57+
endpoint: "http://localhost:4318/v1/traces"
5858
```
5959
6060
4. In a separate terminal, start the worker:

0 commit comments

Comments
 (0)