deepset-ai--haystack
c56bef871b
CodeQL / Analyze (python) (push) Has been cancelled
Update Platform Components Table / update (push) Has been cancelled
Docker image release / Build base image (push) Has been cancelled
Sync docs with Docusaurus / sync (push) Has been cancelled
Tests / Check if changed (push) Has been cancelled
Tests / format (push) Has been cancelled
Tests / check-imports (push) Has been cancelled
Tests / Unit / macos-latest (push) Has been cancelled
Tests / Unit / ubuntu-latest (push) Has been cancelled
Tests / Unit / windows-latest (push) Has been cancelled
Tests / mypy (push) Has been cancelled
Tests / Integration / ubuntu-latest (push) Has been cancelled
Tests / Integration / macos-latest (push) Has been cancelled
Tests / Integration / windows-latest (push) Has been cancelled
Tests / notify-slack-on-failure (push) Has been cancelled
Tests / Mark tests as completed (push) Has been cancelled
62 行
2.2 KiB
Plaintext
62 行
2.2 KiB
Plaintext
---
|
|
title: "LoggingTracer"
|
|
id: logging-tracer
|
|
slug: "/tracing-logging-tracer"
|
|
description: "Learn how to inspect the data flowing through your Haystack pipelines in real time with the LoggingTracer."
|
|
---
|
|
|
|
import ClickableImage from "@site/src/components/ClickableImage";
|
|
|
|
# LoggingTracer
|
|
|
|
Learn how to inspect the data flowing through your Haystack pipelines in real time with the `LoggingTracer`.
|
|
|
|
<div className="key-value-table">
|
|
|
|
| | |
|
|
| --- | --- |
|
|
| **Tracer class** | `LoggingTracer` |
|
|
| **How to enable** | `tracing.enable_tracing(LoggingTracer(...))` |
|
|
| **Content tracing** | Required to log inputs and outputs. Set `tracing.tracer.is_content_tracing_enabled = True` |
|
|
| **Package** | Built into Haystack |
|
|
| **GitHub link** | https://github.com/deepset-ai/haystack/blob/main/haystack/tracing/logging_tracer.py |
|
|
|
|
</div>
|
|
|
|
## Overview
|
|
|
|
Use Haystack's [`LoggingTracer`](https://github.com/deepset-ai/haystack/blob/main/haystack/tracing/logging_tracer.py) logs to inspect the data that's flowing through your pipeline in real time.
|
|
|
|
This feature is particularly helpful during experimentation and prototyping, as you don’t need to set up any tracing backend beforehand.
|
|
|
|
## Usage
|
|
|
|
Here’s how you can enable this tracer. In this example, we are adding color tags (this is optional) to highlight the components' names and inputs:
|
|
|
|
```python
|
|
import logging
|
|
from haystack import tracing
|
|
from haystack.tracing.logging_tracer import LoggingTracer
|
|
|
|
logging.basicConfig(
|
|
format="%(levelname)s - %(name)s - %(message)s",
|
|
level=logging.WARNING,
|
|
)
|
|
logging.getLogger("haystack").setLevel(logging.DEBUG)
|
|
|
|
tracing.tracer.is_content_tracing_enabled = (
|
|
True # to enable tracing/logging content (inputs/outputs)
|
|
)
|
|
tracing.enable_tracing(
|
|
LoggingTracer(
|
|
tags_color_strings={
|
|
"haystack.component.input": "\x1b[1;31m",
|
|
"haystack.component.name": "\x1b[1;34m",
|
|
},
|
|
),
|
|
)
|
|
```
|
|
|
|
Here’s what the resulting log would look like when a pipeline is run:
|
|
<ClickableImage src="/img/55c3d5c84282d726c95fb3350ec36be49a354edca8a6164f5dffdab7121cec58-image_2.png" alt="Console output showing Haystack pipeline execution with DEBUG level tracing logs including component names, types, and input/output specifications" />
|