Skip to content

Commit 3dc2eaf

Browse files
committed
combine the get
1 parent 8418524 commit 3dc2eaf

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/Log/EagleEye.php

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,19 +192,28 @@ public static function requestStart($trace_id = "", $rpc_id = "")
192192
*/
193193
public static function requestFinished()
194194
{
195+
$requestInfo = RequestContext::getMulti([
196+
self::FIELD_VERSION => ["key" => "x_version", "default" => "fend-1.2"],
197+
self::FIELD_TRACE_ID => ["key" => "x_trace_id"],
198+
self::FIELD_DEPARTMENT => ["key" => "x_department", "default" => "tal_wx"],
199+
self::FIELD_START_TIMESTAMP => ["key" => "x_timestamp"],
200+
self::FIELD_PID => ["key" => "x_pid"],
201+
self::FIELD_EXTRA_CONTEXT => ["key" => "x_extra", "default" => []],
202+
]);
203+
195204
//set at first
196205
$log = array(
197206
"x_name" => "request.info",
198-
"x_version" => RequestContext::get(self::FIELD_VERSION, "fend-1.2"),
199-
"x_trace_id" => RequestContext::get(self::FIELD_TRACE_ID),
207+
"x_version" => $requestInfo["x_version"],
208+
"x_trace_id" => $requestInfo["x_trace_id"],
200209
"x_rpc_id" => self::getReciveRpcId() . ".1",
201-
"x_department" => RequestContext::get(self::FIELD_DEPARTMENT, "tal_wx"),
210+
"x_department" => $requestInfo["x_department"],
202211
"x_server_ip" => self::getServerIp(),
203-
"x_timestamp" => (int)RequestContext::get(self::FIELD_START_TIMESTAMP),
204-
"x_duration" => round(microtime(true) - RequestContext::get(self::FIELD_START_TIMESTAMP), 4),
205-
"x_pid" => RequestContext::get(self::FIELD_PID),
212+
"x_timestamp" => (int)$requestInfo["x_timestamp"],
213+
"x_duration" => round(microtime(true) - $requestInfo["x_timestamp"], 4),
214+
"x_pid" => $requestInfo["x_pid"],
206215
"x_module" => "php_request_end",
207-
"x_extra" => RequestContext::get(self::FIELD_EXTRA_CONTEXT, [])
216+
"x_extra" => $requestInfo["x_extra"]
208217
);
209218

210219
//option value added

0 commit comments

Comments
 (0)