> ## Documentation Index
> Fetch the complete documentation index at: https://enrolla-nk-hub-guardrails.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# LLM Observability with Middleware and OpenLLMetry

<Frame>
  <img src="https://mintcdn.com/enrolla-nk-hub-guardrails/MnHRGhi6rxtiPuOU/img/integrations/middleware-dashboard-1.png?fit=max&auto=format&n=MnHRGhi6rxtiPuOU&q=85&s=95ce481884ba123fa15ad41e42f8fe2c" width="1960" height="1163" data-path="img/integrations/middleware-dashboard-1.png" />

  <img src="https://mintcdn.com/enrolla-nk-hub-guardrails/MnHRGhi6rxtiPuOU/img/integrations/middleware-dashboard-2.png?fit=max&auto=format&n=MnHRGhi6rxtiPuOU&q=85&s=332adcd4a9c84b6fb63bb71bf5475772" width="1960" height="1163" data-path="img/integrations/middleware-dashboard-2.png" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/enrolla-nk-hub-guardrails/MnHRGhi6rxtiPuOU/img/integrations/middleware-dashboard-3.png?fit=max&auto=format&n=MnHRGhi6rxtiPuOU&q=85&s=18d7b105366a578fe1d55fe643f9d7c5" width="1960" height="1163" data-path="img/integrations/middleware-dashboard-3.png" />

  <img src="https://mintcdn.com/enrolla-nk-hub-guardrails/MnHRGhi6rxtiPuOU/img/integrations/middleware-dashboard-4.png?fit=max&auto=format&n=MnHRGhi6rxtiPuOU&q=85&s=5b41d7ca7ab9edf544139e748e0470ee" width="1960" height="1163" data-path="img/integrations/middleware-dashboard-4.png" />
</Frame>

To send OpenTelemetry metrics and traces generated by Traceloop from your LLM Application to Middleware, Follow the below steps.

<Steps>
  <Step title="Get your Middleware credentials">
    <Steps>
      1. Sign in to your [Middleware](https://app.middleware.io/) account.
      2. Go to settings and click on API Key. [Link](https://app.middleware.io/settings/api-keys)
      3. Copy and Save the value for `MW_API_KEY` and `MW_TARGET`
    </Steps>
  </Step>

  <Step title="Add the following lines to your application code:">
    <Tabs>
      <Tab title="Python">
        ```python theme={null}
        from traceloop.sdk import Traceloop

        Traceloop.init(
            app_name="YOUR_APPLICATION_NAME",
            api_endpoint="<MW_TARGET>",
            headers={
                "Authorization": "<MW_API_KEY>",
                "X-Trace-Source": "traceloop",
            },
            resource_attributes={"key": "value"},
        )
        ```
      </Tab>

      <Tab title="Typescript (Node js)">
        ```javascript theme={null}
        import * as traceloop from "@traceloop/node-server-sdk";
        traceloop.initialize({
          appName: "YOUR_APPLICATION_NAME",
          apiEndpoint: "<MW_TARGET>",
          headers: {
            Authorization: "<MW_API_KEY>",
            "X-Trace-Source": "traceloop",
          },
          resourceAttributes: { "key": "value" },
        });
        ```
      </Tab>
    </Tabs>

    Replace:

    1. `MW_TARGET` with your middleware target url

    * Example - `https://abcde.middleware.io`

    2. `MW_API_KEY` with your middleware api key.

    * Example - nxhqwpbvcmlkjhgfdsazxcvbnmkjhgtyui

    Refer to the Traceloop [Docs](https://www.traceloop.com/docs/introduction) for more advanced configurations and use cases.

    For detailed information on LLM Observability with Middleware and Traceloop, consult Middleware Documentation:
    [LLM Observability Documentation](https://docs.middleware.io/llm-observability/overview).
  </Step>

  <Step title="Visualize in Middleware">
    Once your LLM application is instrumented, you can view the traces, metrics and dashboards in the Middleware LLM Observability section. To access this:

    1. Log in to your Middleware account
    2. Navigate to the [LLM Observability Section](https://app.middleware.io/llm) in the sidebar
  </Step>
</Steps>

***
