Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions content/integrations/frameworks/spring-ai.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,65 @@ With these configurations and dependencies in place, your Spring Boot applicatio

Each span will carry attributes like `gen_ai.operation.name`, `gen_ai.system` (the provider, e.g. “openai”), model names, token usage, etc., and – since we enabled them – events for the prompt and response content.


## ⚠️ Important: JDBC Dependency Conflict

If your Spring AI application uses a JDBC datasource, you may encounter a dependency conflict that prevents the application from starting. This is caused by a version mismatch between OpenTelemetry libraries.

### The Problem

When you add JDBC dependencies (e.g., `spring-boot-starter-jdbc`), the application fails to start with an error like:

```
APPLICATION FAILED TO START

An attempt was made to call a method that does not exist.

The following method did not exist:
'setCaptureQueryParameters(boolean)'
```

This happens because:

1. `micrometer-tracing-bridge-otel` (managed by Spring Boot) has a transitive dependency on an older `opentelemetry-instrumentation-api-incubator` version
2. `opentelemetry-jdbc` (from `opentelemetry-spring-boot-starter`) requires a newer `opentelemetry-instrumentation-api-incubator` version
3. Maven resolves this in favor of the older transitive dependency, causing the method-not-found error

> **Note:** The exact version numbers in the error message may vary depending on your Spring Boot and OpenTelemetry versions. Look for the same `setCaptureQueryParameters` method-not-found error.

### The Solution

Exclude the problematic transitive dependency from `micrometer-tracing-bridge-otel`. Since the guide's BOM already manages `opentelemetry-instrumentation-api-incubator`, you don't need to specify a version:

```xml
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-tracing-bridge-otel</artifactId>
<exclusions>
<exclusion>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-instrumentation-api-incubator</artifactId>
</exclusion>
</exclusions>
</dependency>
```

> **Note:** The `opentelemetry-instrumentation-bom` in your `<dependencyManagement>` will automatically resolve the correct version. No explicit version declaration is needed.

**For Gradle users:**

```groovy
configurations.all {
exclude group: 'io.opentelemetry.instrumentation', module: 'opentelemetry-instrumentation-api-incubator'
}
```

### Reference

For more details, see:
- [Spring AI Demo Fix PR](https://github.com/langfuse/langfuse-examples/pull/34)
- [Related Bug Report](https://github.com/langfuse/langfuse/issues/14312)

## Step 2: Configure Langfuse

Now that your Spring AI application is emitting OpenTelemetry trace data, the next step is to direct that data to Langfuse.
Expand Down