Skip to content

Annotation @NewSpan does not work for kotlin suspend functions #1366

@mckernant1

Description

@mckernant1

Hey!

I'm building a spring grpc application. I have attached @NewSpan to some suspend service method that makes reactor calls using .awaitSingleOrNull() to convert the Mono to kotlin's suspend syntax.

Tech stack

  • Spring Grpc
  • Reactor
  • Kotlin suspend
  • Kotlin reactor bridge (kotlinx.coroutines.reactor)
  • opentelemetry-extension-kotlin

I have tried an alternate syntax of wrapping the function body in a span, and that seems to work.

suspend fun example(
    argA: String,
    argB: String
): {
    val span = tracer.nextSpan()
        .name("example")
        .tag("argA", argA)
        .tag("argB", argB)
    try {
       block...
    } finally {
        span.end()
    }
}

Can this annotation be expanded to support this behavior?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions