-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enable to add
traceparent
header taking over trace id to other serv…
…ices with HTTP - Add `M3Tracer.processOutgoingHttpRequest` for tracing with various http clients currently only support Spring RestTemplate
- Loading branch information
Showing
8 changed files
with
122 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
jvm/spring-web/src/main/kotlin/com/m3/tracing/spring/http/client/SpringHttpRequestInfo.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.m3.tracing.spring.http.client | ||
|
||
import com.m3.tracing.http.HttpRequestInfo | ||
import com.m3.tracing.http.HttpRequestMetadataKey | ||
import org.springframework.http.HttpRequest | ||
|
||
open class SpringHttpRequestInfo(protected val req: HttpRequest): HttpRequestInfo { | ||
override fun tryGetHeader(name: String): String? = req.headers.getFirst(name) | ||
override fun trySetHeader(name: String, value: String) = req.headers.set(name, value) | ||
|
||
@Suppress("UNCHECKED_CAST", "IMPLICIT_ANY") | ||
override fun <T> tryGetMetadata(key: HttpRequestMetadataKey<T>): T? = when(key) { | ||
HttpRequestMetadataKey.Method -> req.methodValue as T? | ||
HttpRequestMetadataKey.Host -> req.headers.host?.hostName as T? | ||
HttpRequestMetadataKey.ContentLength -> req.headers.contentLength.let { if (it <= 0) null else it } as T? | ||
HttpRequestMetadataKey.Path -> req.uri.path as T? | ||
HttpRequestMetadataKey.Url -> req.uri.toString() as T? | ||
|
||
else -> null | ||
} | ||
} |