File tree 3 files changed +16
-4
lines changed
.jvm/src/test/scala/wvlet/airframe/http/client
src/main/scala/wvlet/airframe/http
3 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,15 @@ class HttpClientLoggingFilterTest extends AirSpec {
66
66
test(" switch dest" ) {
67
67
client.send(Http .GET (" /" ).withDest(ServerAddress (" localhost:8081" )))
68
68
}
69
+
70
+ test(" with logParameters" ) {
71
+ client.send(
72
+ Http .GET (" /" ),
73
+ context = HttpClientContext (
74
+ logParameters = Map (" k1" -> " v1" )
75
+ )
76
+ )
77
+ }
69
78
}
70
79
71
80
}
Original file line number Diff line number Diff line change @@ -20,9 +20,11 @@ import wvlet.airframe.http.RPCMethod
20
20
* @param rpcMethod
21
21
*/
22
22
case class HttpClientContext (
23
- clientName : String ,
23
+ clientName : String = " default " ,
24
24
rpcMethod : Option [RPCMethod ] = None ,
25
- rpcInput : Option [Any ] = None
25
+ rpcInput : Option [Any ] = None ,
26
+ // Extra parameters used for logging
27
+ logParameters : Map [String , Any ] = Map .empty
26
28
)
27
29
28
30
object HttpClientContext {
Original file line number Diff line number Diff line change @@ -50,8 +50,9 @@ object HttpLogs extends LogSupport {
50
50
m ++= requestHeaderLogs(request, httpLogger.excludeHeaders)
51
51
52
52
// Log RPC context in the client side
53
- clientContext.foreach {
54
- _.rpcMethod.map { rpc => m ++= rpcMethodLogs(rpc) }
53
+ clientContext.foreach { ctx =>
54
+ ctx.rpcMethod.map { rpc => m ++= rpcMethodLogs(rpc) }
55
+ m ++= ctx.logParameters
55
56
}
56
57
// Log RPC context in the server side
57
58
rpcContext.flatMap(_.rpcCallContext).foreach { rcc =>
You can’t perform that action at this time.
0 commit comments