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

# Overview

> Learn how to integrate Galileo with OpenTelemetry and OpenInference for comprehensive observability and tracing

{/*<!-- markdownlint-enable MD044 -->*/}

This guide explains how to integrate Galileo with [OpenTelemetry](https://opentelemetry.io/) and [OpenInference](https://github.com/Arize-ai/openinference) for comprehensive observability and tracing of your AI/ML workflows using industry-standard tools.

## OpenTelemetry

The first step is to configure OpenTelemetry.

<Steps>
  <Step title="Installation">
    Add the Galileo SDK and OpenTelemetry packages to your project:

    <CodeGroup>
      ```bash Python theme={null}
      pip install opentelemetry-api opentelemetry-sdk \
                  opentelemetry-exporter-otlp
      ```

      ```bash TypeScript theme={null}
      npm install galileo \
            @opentelemetry/sdk-trace-node \
            @opentelemetry/exporter-trace-otlp-proto
      ```
    </CodeGroup>

    For Python, the `opentelemetry-api` and `opentelemetry-sdk` packages provide the core OpenTelemetry functionality. The `opentelemetry-exporter-otlp` package enables sending traces to Galileo's OTLP endpoint.

    For TypeScript, the `galileo` package includes the `GalileoSpanProcessor` which handles OTLP export configuration automatically. The `@opentelemetry/sdk-trace-node` and `@opentelemetry/exporter-trace-otlp-proto` packages are required peer dependencies.
  </Step>

  <Step title="Create environment variables for your Galileo settings">
    Set environment variables for your Galileo settings, for example in a `.env` file.
    These environment variables are consumed by the `GalileoSpanProcessor` to authenticate
    and route traces to the correct Galileo Project and Log stream:

    <CodeGroup>
      ```ini .env theme={null}
      # Your Galileo API key
      GALILEO_API_KEY="your-galileo-api-key"

      # Your Galileo project name
      GALILEO_PROJECT="your-galileo-project-name"

      # The name of the Log stream you want to use for logging
      GALILEO_LOG_STREAM="your-galileo-log-stream "

      # Provide the console url below if you are using a
      # custom deployment, and not using the free tier, or app.galileo.ai.
      # This will look something like “console.galileo.yourcompany.com”.
      # GALILEO_CONSOLE_URL="your-galileo-console-url"
      ```
    </CodeGroup>
  </Step>

  <Step title="Self-hosted deployments: Set the OTel endpoint">
    <Note>
      Skip this step if you are using Galileo Cloud.
    </Note>

    The OTel endpoint is different from Galileo's regular API endpoint and is specifically designed to receive telemetry data in the OTLP format.

    If you are using:

    * **Galileo Cloud** at [app.galileo.ai](https://app.galileo.ai), then you don't need to provide a custom OTel endpoint.
      The default endpoint `https://api.galileo.ai/otel/traces` will be used automatically.

    * A **self-hosted Galileo deployment**, replace the `https://api.galileo.ai/otel/traces` endpoint with your deployment URL. The format of this URL is based on your console URL, replacing `console` with `api` and appending `/otel/traces`.

    For example:

    * if your console URL is `https://console.galileo.example.com`, the OTel endpoint would be `https://api.galileo.example.com/otel/traces`
    * if your console URL is `https://console-galileo.apps.mycompany.com`, the OTel endpoint would be `https://api-galileo.apps.mycompany.com/otel/traces`

    The convention is to store this in the `GALILEO_CONSOLE_URL` environment variable. For example:

    <CodeGroup>
      ```python Python theme={null}
      os.environ["GALILEO_CONSOLE_URL"] = "https://console.galileo.example.com"
      ```

      ```typescript TypeScript theme={null}
      process.env.GALILEO_CONSOLE_URL = "https://console.galileo.example.com";
      ```
    </CodeGroup>
  </Step>

  <Step title="Initialize and create the Galileo span processor">
    The `GalileoSpanProcessor` automatically configures authentication
    and metadata using your environment variables. It also:

    * Auto-builds OTLP headers using your Galileo credentials
    * Configures the correct OTLP trace endpoint
    * Registers a batch span processor that exports traces to Galileo

    <CodeGroup>
      ```python Python theme={null}
      from galileo import otel  

      # GalileoSpanProcessor (no manual OTLP config required) loads the env vars for 
      # the Galileo API key, Project, and Log stream. Make sure to set them first. 
      galileo_span_processor = otel.GalileoSpanProcessor(
          # Optional parameters if not set, uses env var
          # project=os.environ["GALILEO_PROJECT"], 
          # logstream=os.environ.get("GALILEO_LOG_STREAM"),  
      )
      ```

      ```typescript TypeScript theme={null}
      import { GalileoSpanProcessor } from 'galileo';

      // GalileoSpanProcessor (no manual OTLP config required) loads the env vars for
      // the Galileo API key, Project, and Log stream. Make sure to set them first.
      const processor = new GalileoSpanProcessor({
          // Optional parameters if not set, uses env var
          // project: process.env.GALILEO_PROJECT,
          // logstream: process.env.GALILEO_LOG_STREAM,
      });
      ```
    </CodeGroup>
  </Step>

  <Step title="Register the span processor">
    The span processor can now be registered with an OTel trace provider.

    <CodeGroup>
      ```python Python theme={null}
      from opentelemetry.sdk import trace as trace_sdk

      tracer_provider = trace_sdk.TracerProvider()
      tracer_provider.add_span_processor(galileo_span_processor)
      ```

      ```typescript TypeScript theme={null}
      import { addGalileoSpanProcessor } from 'galileo';
      import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';

      const provider = new NodeTracerProvider();
      addGalileoSpanProcessor(provider, processor);
      provider.register();
      ```
    </CodeGroup>
  </Step>
</Steps>

You can now use this trace provider either using a framework that supports OTel directly, or via OpenInference.

## OpenInference

<Note>
  OpenInference instrumentors are currently available for Python only. For TypeScript/Node.js applications, use framework-specific OTel integrations such as [Vercel AI SDK](/sdk-api/third-party-integrations/opentelemetry-and-openinference/vercel-ai) or [Mastra](/sdk-api/third-party-integrations/opentelemetry-and-openinference/mastra).
</Note>

You can enable automatic tracing for your framework and LLM operations using OpenInference instrumentors. These add AI-specific semantic conventions to your traces.

For example, to instrument LangChain and OpenAI start by adding the relevant OpenInference packages:

<CodeGroup>
  ```bash Terminal theme={null}
  pip install openinference-instrumentation-langchain \
              openinference-instrumentation-openai
  ```
</CodeGroup>

Now you can add the instrumentation to your code, using the OTel trace provider.

<CodeGroup>
  ```python Python theme={null}
  from openinference.instrumentation.langgraph import (
      LangGraphInstrumentor
  )
  from openinference.instrumentation.openai import (
      OpenAIInstrumentor
  )

  LangGraphInstrumentor().instrument(tracer_provider=tracer_provider)
  OpenAIInstrumentor().instrument(tracer_provider=tracer_provider)
  ```
</CodeGroup>

OpenInference adds:

* Automatic capture of LLM calls, token usage, and model performance metrics
* AI-specific span attributes like `gen_ai.request.model`, `gen_ai.response.content`, and `gen_ai.usage.*`
* Semantic conventions that make your traces more meaningful in Galileo's dashboard
* Framework-specific instrumentation for LangGraph workflows and OpenAI API calls

Once OpenTelemetry and OpenInference is set up your application will automatically capture and send observability data to Galileo with every run, providing complete traces of your AI workflows, detailed LLM call breakdowns, and performance insights organized by project and Log stream.

For a detailed example of using OpenTelemetry and OpenInference with LangGraph, see the [Log with OpenTelemetry, LangGraph, and OpenAI](/how-to-guides/third-party-integrations/otel) how-to guide.

## Next steps

Learn how to integrate with some popular frameworks using OpenTelemetry and OpenInference.

<CardGroup cols={2}>
  <Card title="Google ADK" icon="python" horizontal href="/sdk-api/third-party-integrations/opentelemetry-and-openinference/google-adk">
    Learn how to integrate a Google ADK project with Galileo using OpenTelemetry and OpenInference.
  </Card>

  <Card title="Strands Agents" icon="python" horizontal href="/sdk-api/third-party-integrations/opentelemetry-and-openinference/strands-agents">
    Learn how to integrate a Strands Agents project with Galileo using OpenTelemetry.
  </Card>

  <Card title="Vercel AI SDK" icon="js" horizontal href="/sdk-api/third-party-integrations/opentelemetry-and-openinference/vercel-ai">
    Learn how to integrate a Vercel AI SDK project with Galileo using OpenTelemetry.
  </Card>

  <Card title="Mastra" icon="js" horizontal href="/sdk-api/third-party-integrations/opentelemetry-and-openinference/mastra">
    Learn how to integrate a Mastra project with Galileo using OpenTelemetry.
  </Card>
</CardGroup>
