@@ -77,12 +77,18 @@ protected function handleRequestTerminated(RequestTerminated $event): void
77
77
$ tracer = TracerContext::getTracer ();
78
78
$ span = TracerContext::getRoot ();
79
79
$ span ->setTag ($ this ->spanTagManager ->get ('response ' , 'status_code ' ), (string ) $ response ->getStatusCode ());
80
+ if ($ this ->spanTagManager ->has ('response ' , 'body ' )) {
81
+ $ span ->setTag ($ this ->spanTagManager ->get ('response ' , 'body ' ), (string ) $ response ->getBody ());
82
+ }
80
83
81
84
if ($ event ->exception && $ this ->switchManager ->isEnable ('exception ' ) && ! $ this ->switchManager ->isIgnoreException ($ event ->exception )) {
82
85
$ this ->appendExceptionToSpan ($ span , $ exception = $ event ->exception );
83
86
84
87
if ($ exception instanceof HttpException) {
85
88
$ span ->setTag ($ this ->spanTagManager ->get ('response ' , 'status_code ' ), $ exception ->getStatusCode ());
89
+ if ($ this ->spanTagManager ->has ('response ' , 'body ' )) {
90
+ $ span ->setTag ($ this ->spanTagManager ->get ('response ' , 'body ' ), (string ) $ response ->getBody ());
91
+ }
86
92
}
87
93
}
88
94
@@ -107,6 +113,9 @@ protected function buildSpan(ServerRequestInterface $request): Span
107
113
$ span ->setTag ($ this ->spanTagManager ->get ('request ' , 'path ' ), (string ) $ uri ->getPath ());
108
114
$ span ->setTag ($ this ->spanTagManager ->get ('request ' , 'method ' ), $ request ->getMethod ());
109
115
$ span ->setTag ($ this ->spanTagManager ->get ('request ' , 'uri ' ), (string ) $ uri );
116
+ if ($ this ->spanTagManager ->has ('request ' , 'body ' )) {
117
+ $ span ->setTag ($ this ->spanTagManager ->get ('request ' , 'body ' ), (string ) $ request ->getBody ());
118
+ }
110
119
foreach ($ request ->getHeaders () as $ key => $ value ) {
111
120
$ span ->setTag ($ this ->spanTagManager ->get ('request ' , 'header ' ) . '. ' . $ key , implode (', ' , $ value ));
112
121
}
0 commit comments