> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dataframer.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Server Instrumentation

> Auto-stamp journey ids onto your AI traces with dataframer-journey

`dataframer-journey` is a small Python library that reads the journey id off incoming requests and stamps it onto every Langfuse trace your service creates, no need to pass it around manually. Pair it with the [browser SDK](/user-signals/browser-sdk), which is what generates the journey id in the first place.

## Install

```bash theme={null}
pip install dataframer-journey
```

Zero runtime dependencies. It only patches libraries you already have installed (`requests`, `httpx`, `langfuse`).

## Set up

<Tabs>
  <Tab title="FastAPI / Starlette">
    ```python theme={null}
    from dataframer_journey import instrument

    app = FastAPI()
    instrument(app)
    ```
  </Tab>

  <Tab title="Django">
    Add the middleware, then call `instrument()`:

    ```python theme={null}
    MIDDLEWARE = [
        ...,
        'dataframer_journey.django.JourneyIdMiddleware',
    ]

    import dataframer_journey
    dataframer_journey.instrument()
    ```
  </Tab>
</Tabs>

That's it. From here on, one call is doing three things for you:

1. **Reading it in**: the journey id is read off each incoming request (header or cookie) into request-local context.
2. **Passing it along**: every outgoing `requests`/`httpx` call to another service automatically carries the id forward, so a multi-service call chain stays connected.
3. **Stamping traces**: every Langfuse trace your code creates during that request gets `metadata.journey_id` set automatically, plus a `journey:<id>` tag.

## Non-HTTP entry points

Queue consumers and scheduled jobs don't go through a middleware, so pull the id from your payload yourself:

```python theme={null}
from dataframer_journey import with_journey

with with_journey(payload["journey_id"]):
    ...  # traces created here get stamped; outbound calls carry the id
```

<Warning>
  **Supports Langfuse v2 SDK only.** Langfuse v3 (OpenTelemetry-based) and LangSmith aren't supported yet. Using either means traces won't be auto-stamped, and the library logs a warning so you'll notice.
</Warning>

## CORS

This library doesn't add anything to CORS by itself, it just reads whatever id it's given. If your frontend and backend are on different domains, the header allowance you need is on the [browser SDK page](/user-signals/browser-sdk#cors-when-you-need-it-and-when-you-dont). Same-domain setups need nothing.

## Next steps

<Card title="Browser SDK" icon="browser" href="/user-signals/browser-sdk">
  Generate the journey id in your frontend and send user events.
</Card>
