Skip to content

Fix ktor server instrumentation resolving peer address#16392

Merged
trask merged 3 commits intoopen-telemetry:mainfrom
laurit:ktor-network-peer
Mar 6, 2026
Merged

Fix ktor server instrumentation resolving peer address#16392
trask merged 3 commits intoopen-telemetry:mainfrom
laurit:ktor-network-peer

Conversation

@laurit
Copy link
Copy Markdown
Contributor

@laurit laurit commented Mar 5, 2026

Resolves #16391

@laurit laurit requested a review from a team as a code owner March 5, 2026 14:44

override fun getNetworkProtocolVersion(request: ApplicationRequest, response: ApplicationResponse?): String? = if (request.httpVersion.startsWith("HTTP/")) request.httpVersion.substring("HTTP/".length) else null

override fun getNetworkPeerAddress(request: ApplicationRequest, response: ApplicationResponse?): String? {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.0 does not cause lookup, but later versions do

private val getRemoteAddressMethodHandle: MethodHandle? = getRemoteAddressMethodHandle()

private fun getRemoteAddressMethodHandle(): MethodHandle? = try {
MethodHandles.lookup().findVirtual(RequestConnectionPoint::class.java, "getRemoteAddress", MethodType.methodType(String::class.java))
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

introduced in 2.2.0

@laurit laurit added this to the v2.26.0 milestone Mar 6, 2026
@trask trask merged commit f95ca7e into open-telemetry:main Mar 6, 2026
93 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ktor 3 Don't do reverse lookups of Client and Server Adresses

3 participants