Skip to content

Commit 56e7ff9

Browse files
authored
docs: refactor telemetry docs into dedicated tracing, metrics, and logging pages (#662)
* docs: refactor telemetry docs into dedicated tracing, metrics, and logging pages Absorb all content from docs/dev/telemetry.md into the public docs and restructure the Evaluation and Observability section: - Replace metrics-and-telemetry.md with telemetry.md (balanced overview hub) - Replace opentelemetry-tracing.md with tracing.md (add Mellea-specific backend span attributes, gen_ai.response.model) - Create metrics.md (token usage, backend support matrix, three exporters, custom metrics API, programmatic access, troubleshooting) - Create logging.md (FancyLogger console logging, OTLP log export, get_otlp_log_handler() API, collector setup) - Move handling-exceptions.md from eval-observability to how-to section - Reorder sidebar: LLM-as-a-Judge first, then Telemetry subgroup - Delete docs/dev/telemetry.md (all content migrated) - Update all cross-references across 10+ files - Fix mintlify dev command in CONTRIBUTING.md and README.md Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com> * fix: correct broken telemetry link in handling-exceptions doc Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com> * fix: re-tag logging.md diataxis category as reference Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com> --------- Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com>
1 parent 80000af commit 56e7ff9

18 files changed

Lines changed: 779 additions & 919 deletions

docs/dev/telemetry.md

Lines changed: 0 additions & 705 deletions
This file was deleted.

docs/docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ npm install -g mintlify
1919

2020
```bash
2121
cd docs/docs
22-
mint dev
22+
mintlify dev
2323
```
2424

2525
The site is available at <http://localhost:3000>.

docs/docs/docs.json

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@
6868
"how-to/use-images-and-vision",
6969
"how-to/build-a-rag-pipeline",
7070
"how-to/refactor-prompts-with-cli",
71-
"how-to/unit-test-generative-code"
71+
"how-to/unit-test-generative-code",
72+
"how-to/handling-exceptions"
7273
]
7374
},
7475
{
@@ -100,10 +101,16 @@
100101
{
101102
"group": "Evaluation and Observability",
102103
"pages": [
103-
"evaluation-and-observability/handling-exceptions",
104-
"evaluation-and-observability/metrics-and-telemetry",
105-
"evaluation-and-observability/opentelemetry-tracing",
106-
"evaluation-and-observability/evaluate-with-llm-as-a-judge"
104+
"evaluation-and-observability/evaluate-with-llm-as-a-judge",
105+
{
106+
"group": "Telemetry",
107+
"pages": [
108+
"evaluation-and-observability/telemetry",
109+
"evaluation-and-observability/tracing",
110+
"evaluation-and-observability/metrics",
111+
"evaluation-and-observability/logging"
112+
]
113+
}
107114
]
108115
},
109116
{

docs/docs/evaluation-and-observability/evaluate-with-llm-as-a-judge.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,4 +202,4 @@ requirements. `sample_generations` lists every attempt made.
202202

203203
**See also:** [The Requirements System](../concepts/requirements-system) |
204204
[Write Custom Verifiers](../how-to/write-custom-verifiers) |
205-
[Handling Exceptions and Failures](../evaluation-and-observability/handling-exceptions)
205+
[Handling Exceptions and Failures](../how-to/handling-exceptions)
Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
---
2+
title: "Logging"
3+
description: "Configure Mellea's console logging and export logs to OTLP collectors."
4+
# diataxis: reference
5+
---
6+
7+
**Prerequisites:** [Telemetry](../evaluation-and-observability/telemetry)
8+
introduces the environment variables and telemetry architecture. This page
9+
covers logging configuration in detail.
10+
11+
Mellea provides two logging layers: a built-in console logger for local
12+
development and an optional OTLP exporter for centralized log aggregation.
13+
Both work simultaneously when enabled.
14+
15+
## Console logging
16+
17+
Mellea uses `FancyLogger`, a color-coded singleton logger built on Python's
18+
`logging` module. All internal Mellea modules obtain their logger via
19+
`FancyLogger.get_logger()`.
20+
21+
### Configuration
22+
23+
| Variable | Description | Default |
24+
| -------- | ----------- | ------- |
25+
| `DEBUG` | Set to any value to enable `DEBUG`-level output | unset (`INFO` level) |
26+
| `FLOG` | Set to any value to forward logs to a local REST endpoint at `http://localhost:8000/api/receive` | unset |
27+
28+
By default, `FancyLogger` logs at `INFO` level with color-coded output to
29+
stdout. Set the `DEBUG` environment variable to lower the level to `DEBUG`:
30+
31+
```bash
32+
export DEBUG=1
33+
python your_script.py
34+
```
35+
36+
### Log format
37+
38+
Console output uses ANSI color codes by log level:
39+
40+
- **Cyan** — DEBUG
41+
- **Grey** — INFO
42+
- **Yellow** — WARNING
43+
- **Red** — ERROR
44+
- **Bold red** — CRITICAL
45+
46+
Each message is formatted as:
47+
48+
```text
49+
=== HH:MM:SS-LEVEL ======
50+
message
51+
```
52+
53+
## OTLP log export
54+
55+
When the `[telemetry]` extra is installed, Mellea can export logs to an OTLP
56+
collector alongside the existing console output. This is useful for centralizing
57+
logs from distributed services.
58+
59+
> **Note:** OTLP logging is disabled by default. When disabled, there is zero
60+
> overhead — no OTLP handler is created.
61+
62+
### Enable OTLP logging
63+
64+
```bash
65+
export MELLEA_LOGS_OTLP=true
66+
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
67+
68+
# Optional: logs-specific endpoint (overrides general endpoint)
69+
export OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=http://localhost:4318
70+
71+
# Optional: set service name
72+
export OTEL_SERVICE_NAME=my-mellea-app
73+
```
74+
75+
### How it works
76+
77+
When `MELLEA_LOGS_OTLP=true`, `FancyLogger` adds an OpenTelemetry
78+
`LoggingHandler` alongside its existing handlers:
79+
80+
- **Console handler** — continues to work normally (color-coded output)
81+
- **REST handler** — continues to work normally (when `FLOG` is set)
82+
- **OTLP handler** — exports logs to the configured OTLP collector
83+
84+
Logs are exported using OpenTelemetry's Logs API with batched processing
85+
for efficiency.
86+
87+
### Programmatic access
88+
89+
Use `get_otlp_log_handler()` to add OTLP log export to your own loggers:
90+
91+
```python
92+
import logging
93+
from mellea.telemetry import get_otlp_log_handler
94+
95+
logger = logging.getLogger("my_app")
96+
handler = get_otlp_log_handler()
97+
if handler:
98+
logger.addHandler(handler)
99+
logger.info("This log will be exported via OTLP")
100+
```
101+
102+
The function returns `None` when OTLP logging is disabled or not configured,
103+
so the `if handler` check is always safe.
104+
105+
### OTLP collector setup example
106+
107+
```bash
108+
cat > otel-collector-config.yaml <<EOF
109+
receivers:
110+
otlp:
111+
protocols:
112+
grpc:
113+
endpoint: 0.0.0.0:4317
114+
115+
exporters:
116+
debug:
117+
verbosity: detailed
118+
file:
119+
path: ./mellea-logs.json
120+
121+
service:
122+
pipelines:
123+
logs:
124+
receivers: [otlp]
125+
exporters: [debug, file]
126+
EOF
127+
128+
docker run -p 4317:4317 \
129+
-v $(pwd)/otel-collector-config.yaml:/etc/otelcol/config.yaml \
130+
-v $(pwd):/logs \
131+
otel/opentelemetry-collector:latest
132+
```
133+
134+
### Integration with observability platforms
135+
136+
OTLP logs work with any OTLP-compatible platform:
137+
138+
- **Grafana Loki** — log aggregation and querying
139+
- **Elasticsearch** — log storage and analysis
140+
- **Datadog** — unified logs, traces, and metrics
141+
- **New Relic** — centralized logging
142+
- **Splunk** — log analysis and monitoring
143+
144+
## Performance
145+
146+
- **Zero overhead when disabled**: No OTLP handler is created, no performance
147+
impact.
148+
- **Batched export**: Logs are batched and exported asynchronously.
149+
- **Non-blocking**: Log export never blocks application code.
150+
- **Minimal overhead when enabled**: OpenTelemetry's efficient batching
151+
minimizes impact.
152+
153+
## Troubleshooting
154+
155+
**Logs not appearing in OTLP collector:**
156+
157+
1. Verify `MELLEA_LOGS_OTLP=true` is set.
158+
2. Check that an OTLP endpoint is configured
159+
(`OTEL_EXPORTER_OTLP_ENDPOINT` or `OTEL_EXPORTER_OTLP_LOGS_ENDPOINT`).
160+
3. Verify the OTLP collector is running and configured to receive logs.
161+
4. Check collector logs for connection errors.
162+
163+
**Warning about missing endpoint:**
164+
165+
```text
166+
WARNING: OTLP logs exporter is enabled but no endpoint is configured
167+
```
168+
169+
Set either `OTEL_EXPORTER_OTLP_ENDPOINT` or `OTEL_EXPORTER_OTLP_LOGS_ENDPOINT`.
170+
171+
**Connection refused:**
172+
173+
1. Verify the OTLP collector is running: `docker ps | grep otel`
174+
2. Check the endpoint URL is correct (default: `http://localhost:4317`).
175+
3. Verify network connectivity: `curl http://localhost:4317`
176+
177+
---
178+
179+
**See also:**
180+
181+
- [Telemetry](../evaluation-and-observability/telemetry) — overview of all
182+
telemetry features and configuration.
183+
- [Tracing](../evaluation-and-observability/tracing) — distributed traces
184+
with Gen-AI semantic conventions.
185+
- [Metrics](../evaluation-and-observability/metrics) — token usage metrics,
186+
exporters, and custom instruments.

0 commit comments

Comments
 (0)