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

# Arconia Tracing

> How to use OpenInference instrumentation for Spring AI with Arconia and export traces to Arize Phoenix.

## Prerequisites

* Java 21 or higher
* (Optional) Phoenix API key if using Phoenix Cloud
* (Optional) Docker or Podman if using the Arconia Phoenix Dev Service

### Add Dependencies

<Tabs>
  <Tab title="Gradle">
    Add the dependencies to your `build.gradle`:

    ```groovy expandable theme={null}
    dependencies {
        implementation 'io.arconia:arconia-openinference-ai-semantic-conventions'
        implementation 'io.arconia:arconia-opentelemetry-spring-boot-starter'

        implementation 'org.springframework.boot:spring-boot-starter-web'
        implementation 'org.springframework.ai:spring-ai-starter-model-mistral-ai'

        testAndDevelopmentOnly 'io.arconia:arconia-dev-services-phoenix'
    }
    ```
  </Tab>

  <Tab title="Maven">
    Add the dependencies to your `pom.xml`:

    ```xml expandable theme={null}
    <dependencies>
      <dependency>
          <groupId>io.arconia</groupId>
          <artifactId>arconia-openinference-ai-semantic-conventions</artifactId>
      </dependency>
      <dependency>
          <groupId>io.arconia</groupId>
          <artifactId>arconia-opentelemetry-spring-boot-starter</artifactId>
      </dependency>
      <dependency>
          <groupId>org.springframework.ai</groupId>
          <artifactId>spring-ai-starter-model-mistral-ai</artifactId>
      </dependency>
      <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-webmvc</artifactId>
      </dependency>
      <dependency>
        <groupId>io.arconia</groupId>
        <artifactId>arconia-dev-services-phoenix</artifactId>
        <scope>runtime</scope>
        <optional>true</optional>
      </dependency>
    </dependencies>
    ```
  </Tab>
</Tabs>

## **Setup Phoenix**

<Tabs>
  <Tab title="Phoenix Dev Service">
    If you included the Arconia Phoenix Dev Service dependency as instructed in the previous step,
    your Spring Boot application will automatically provision a Phoenix service at startup time
    and connect to it. No extra code or configuration needed.

    The application logs will show you the URL where you can access the Phoenix AI observability platform
    in your development environment.

    ```logs theme={null}
    ...Phoenix UI: http://localhost:<port>
    ```

    By default, traces are exported via OTLP using the HTTP/Protobuf format.

    For more info on using Phoenix with Arconia, see [Phoenix Dev Service](https://docs.arconia.io/arconia/latest/dev-services/phoenix/).
  </Tab>

  <Tab title="Docker">
    **Pull latest Phoenix image from** [**Docker Hub**](https://hub.docker.com/r/arizephoenix/phoenix)**:**

    ```bash theme={null}
    docker pull arizephoenix/phoenix:latest
    ```

    **Run your containerized instance:**

    ```bash theme={null}
    docker run -p 6006:6006 -p 4317:4317 arizephoenix/phoenix:latest
    ```

    This command:

    * Exposes port 6006 for the Phoenix web UI
    * Exposes port 4317 for the OTLP gRPC endpoint (where traces are sent)

    For more info on using Phoenix with Docker, see [Docker](/docs/phoenix/self-hosting/deployment-options/docker).
  </Tab>

  <Tab title="Phoenix Cloud">
    **Sign up for Phoenix:**

    <Steps>
      <Step>
        Sign up for an Arize Phoenix account at [https://app.phoenix.arize.com/login](https://app.phoenix.arize.com/login)
      </Step>

      <Step>
        Click `Create Space`, then follow the prompts to create and launch your space.
      </Step>
    </Steps>

    **Set your Phoenix endpoint and API Key:**

    From your new Phoenix Space

    <Steps>
      <Step>
        Create your API key from the Settings page
      </Step>

      <Step>
        Copy your `Hostname` from the Settings page
      </Step>

      <Step>
        Set your endpoint and API key:

        ```bash theme={null}
        export PHOENIX_API_KEY = "your-phoenix-api-key"
        export PHOENIX_COLLECTOR_ENDPOINT = "your-phoenix-endpoint"
        ```
      </Step>
    </Steps>

    <Info>
      Having trouble finding your endpoint? Check out [Finding your Phoenix Endpoint](/docs/phoenix/resources/frequently-asked-questions/what-is-my-phoenix-endpoint)
    </Info>
  </Tab>
</Tabs>

<Warning>
  If you are using Phoenix Cloud or a self-hosted Phoenix, adjust the endpoint in the code as needed via the `arconia.otel.exporter.otlp.endpoint=${PHOENIX_COLLECTOR_ENDPOINT}` and `arconia.otel.exporter.otlp.headers=Authorization=Bearer ${PHOENIX_API_KEY}` properties. Alternatively, you can use the canonical OpenTelemetry Environment Variables: `OTEL_EXPORTER_OTLP_ENDPOINT` and `OTEL_EXPORTER_OTLP_HEADERS`.
</Warning>

## Run Spring AI with Arconia

By instrumenting your application with Arconia, spans are automatically created whenever your AI models via Spring AI are invoked and sent to the Phoenix server for collection. Arconia plugs into Spring Boot and Spring AI without any code or configuration changes.

```java expandable theme={null}
package io.arconia.demo;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
public class ArconiaTracingApplication {
    public static void main(String[] args) {
        SpringApplication.run(ArconiaTracingApplication.class, args);
    }
}

@RestController
class ChatController {

    private static final Logger logger = LoggerFactory.getLogger(ChatController.class);
    private final ChatClient chatClient;

    ChatController(ChatClient.Builder chatClientBuilder) {
        this.chatClient = chatClientBuilder.clone().build();
    }

    @GetMapping("/chat")
    String chat(String question) {
        logger.info("Received question: {}", question);
        return chatClient
                .prompt(question)
                .call()
                .content();
    }
}
```

<Check>
  Full example: [https://github.com/arconia-io/arconia-examples/tree/main/arconia-openinference](https://github.com/arconia-io/arconia-examples/tree/main/arconia-openinference)
</Check>

## Observe

Once configured, your OpenInference traces will be automatically sent to Phoenix where you can:

* **Monitor Performance**: Track latency, throughput, and error rates
* **Analyze Usage**: View token usage, model performance, and cost metrics
* **Debug Issues**: Trace request flows and identify bottlenecks
* **Evaluate Quality**: Run evaluations on your LLM outputs

## Resources

<CardGroup>
  <Card title="Full Example" href="https://github.com/arconia-io/arconia-examples/tree/main/arconia-openinference" icon="github" horizontal description="Complete tracing example" />

  <Card title="Arconia OpenInference Semantic Conventions (docs)" href="https://docs.arconia.io/arconia/latest/observability/semantic-conventions/openinference/" icon="box" horizontal description="Arconia OpenInference Semantic Conventions (docs)" />
</CardGroup>
