Skip to content

No traces from controllers or services with OpenTelemetry Java agent in Spring Boot Kotlin applicationΒ #14210

@powerfulsheron

Description

@powerfulsheron

Describe the bug

Please help identify why no controller/service spans are being generated, and how to get OpenTelemetry auto-instrumentation working for classic Spring Boot controllers in a Kotlin app.

Steps to reproduce

πŸ” Steps to Reproduce

  1. Generate Kotlin Spring Boot project
    Use [Spring Initializr](https://start.spring.io/) with the following settings:

    • Language: Kotlin

    • Spring Boot version: e.g., 3.2.x

    • Dependencies:

      • Spring Web
  2. Create a simple controller

    @RestController
    class HelloController {
    
        @GetMapping("/hello")
        fun hello(): String {
            Thread.sleep(500) // to simulate work and ensure trace is long enough
            return "Hello from controller"
        }
    }
  3. Application class

    @SpringBootApplication
    class MyApplication
    
    fun main(args: Array<String>) {
        runApplication<MyApplication>(*args)
    }
  4. Download OpenTelemetry Java agent

    curl -O https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar
  5. Run the app with the agent with following args

      -Dotel.service.name=xxx \
      -Dotel.exporter.otlp.endpoint=http://localhost:4317 \
      -Dotel.exporter.otlp.protocol=grpc \
      -Dotel.metrics.exporter=none \
      -Dotel.logs.exporter=none \
      -Dotel.instrumentation.spring-web.enabled=true \
      -Dotel.instrumentation.spring-webmvc.enabled=true \
  6. Trigger the endpoint

    curl http://localhost:8080/hello
  7. Check for spans

    • No spans from controller or service layer appear in OTLP endpoint or logs.
    • Agent logs show instrumentations were installed, but no controller traces.

Expected behavior

❌ What Should Work

  • spans/traces from controller layer (e.g., @RestController)
  • spans from service layer (e.g., @Service)

Actual behavior

βœ… What Works

  • App starts fine with the agent.
  • Logs confirm the agent is attached and instrumentation is installed.
  • Agent outputs Installed instrumentations: spring-web, spring-webmvc, etc.
  • Application responds to HTTP requests.

❌ What Does NOT Work

  • No spans/traces from controller layer (e.g., @RestController)
  • No spans from service layer (e.g., @Service)
  • Tried adding Thread.sleep() in controller to ensure timing isn’t an issue β†’ no change.

Javaagent or library instrumentation version

latest from the website

Environment

🧩 Environment

  • Language: Kotlin
  • Framework: Spring Boot
  • Spring Boot Version: 3.3.4
  • OpenTelemetry Java Agent version: Latest (from official site)
  • JDK Version: OpenJDK 21.0.1
  • App Packaging: Gradle

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds author feedbackWaiting for additional feedback from the authorneeds triageNew issue that requires triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions