Skip to content

Commit

Permalink
Merge pull request #89 from wonder-game/develop
Browse files Browse the repository at this point in the history
http_tracker增加path白名单
  • Loading branch information
Joyboo authored Feb 26, 2024
2 parents b204512 + a89b93f commit 93fada3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/EventInitialize.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,10 @@ function (Request $request, Response $response) {

LamUnit::setI18n($request);

if ( ! is_null($this->httpTracker)) {
$isTracker = ! is_null($this->httpTracker)
&& is_array($this->httpTrackerConfig['ignore_path'])
&& ! in_array($request->getUri()->getPath(), $this->httpTrackerConfig['ignore_path']);
if ($isTracker) {
$repeated = intval(stripos($request->getHeaderLine('user-agent'), ';HttpTracker') !== false);
// 开启链路追踪
$point = HttpTracker::getInstance($this->httpTrackerConfig)->createStart($this->httpTracker);
Expand Down Expand Up @@ -338,7 +341,10 @@ function (Request $request, Response $response) {
}
}

if ( ! is_null($this->httpTracker)) {
$isTracker = ! is_null($this->httpTracker)
&& is_array($this->httpTrackerConfig['ignore_path'])
&& ! in_array($request->getUri()->getPath(), $this->httpTrackerConfig['ignore_path']);
if ($isTracker) {
$point = HttpTracker::getInstance()->startPoint();
$point && $point->setEndArg(HttpTracker::endArgsResponse($response))->end();
}
Expand Down
11 changes: 11 additions & 0 deletions src/HttpTracker/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,23 @@ public static function startArgsRequest(Request $request, array $merge = [])
'server_name' => config('SERVNAME'),
'header' => $request->getHeaders(),
// 'server' => $request->getServerParams(),
];

// 有值才记录
$extArr = [
'GET' => $request->getQueryParams(),
'POST' => $request->getParsedBody(),
'JSON' => json_decode($_body, true),
// 主要是记录微信支付回调
'XML' => json_decode(json_encode(simplexml_load_string($_body, 'SimpleXMLElement', LIBXML_NOCDATA)), true)
];

foreach ($extArr as $key => $val) {
if ( ! empty($val)) {
$arr[$key] = $val;
}
}

return array_merge($arr, $merge);
}

Expand Down

0 comments on commit 93fada3

Please sign in to comment.