newrelic / newrelic-java-agent

The New Relic Java agent
Apache License 2.0
202 stars 143 forks source link

Support for Spring interface annotations #1207

Closed stevenhurd closed 8 months ago

stevenhurd commented 1 year ago

Is your feature request related to a problem? Please describe.

Currently, it doesn't appear that the New Relic Java Agent supports interface driven annotations for Spring controllers. For example, see the following:

interface

package com.example

import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestMethod

@RequestMapping("/v1/example/")
interface MyInterface {

    @RequestMapping(
        method = [RequestMethod.POST],
        value = ["/testing"],
        produces = ["application/json"],
        consumes = ["application/json"]
    )
    fun testPost(): ResponseEntity<Void>
}

controller

package com.example

import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.RestController

@RestController
class MyInterfaceImpl : MyInterface {
    override fun testPost(): ResponseEntity<Void> {
        return ResponseEntity.ok().build()
    }
}

Spring will pick this up (since Spring 5.1) and route the requests properly. The New Relic Agent, however, will ignore this controller class and not instrument it for Transactions.

This feature is necessary when using something like OpenAPI to generate server-side interfaces (published in an artifact). This allows us to keep the implementation and API definition in sync rather than relying on manually creating request mappings in our implementation.

Feature Description

Support for request mapping annotations at the interface level.

Describe Alternatives

The only alternatives are manually doing a setTransactionName in the implementation or copying the request mapping annotations.

Additional context

Add any other context here.

Priority

Please help us better understand this feature request by choosing a priority from the following options: [Nice to Have, Really Want, Must Have, Blocker]

workato-integration[bot] commented 1 year ago

https://issues.newrelic.com/browse/NEWRELIC-8079

kford-newrelic commented 1 year ago

@stevenhurd thanks for the enhancement request! We'll be reviewing this internally

kford-newrelic commented 1 year ago

@stevenhurd our team has agreed to pull this into our backlog. We cannot commit to a timeframe but as we plan work for future quarters, this will be considered. Thanks for the suggestion!

workato-integration[bot] commented 1 year ago

Jira CommentId: 218191 Commented by rkaran:

Hi, is there any timeline or ETA we can expect for this, surely there are many customers now on the newer versions who are requesting this?

kford-newrelic commented 1 year ago

Not at the moment.

We do not have this planned for the Jul-Sep quarter but we're discussing whether this is something we could explore in the quarter after that.

jtduffy commented 8 months ago

This issue was resolved in #1675, available in the latest agent release.