Skip to content
This repository has been archived by the owner on Nov 29, 2021. It is now read-only.

Commit

Permalink
Merge pull request #72 from philkra/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
philkra authored Apr 15, 2019
2 parents 80e79d7 + 4f2aea3 commit 68232fb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ Addings spans (https://www.elastic.co/guide/en/apm/server/current/transactions.h
Please consult the documentation for your exact needs. Below is an example for adding a MySQL span.

```php
$trxName = 'GET /some/transaction/name';

// create the agent
$agent = new \PhilKra\Agent(['appName' => 'Demo with Spans']);

// start a new transaction
$transaction = $agent->startTransaction('GET /some/transaction/name');
$transaction = $agent->startTransaction($trxName);

// create a span
$spans = [];
Expand Down Expand Up @@ -104,6 +106,11 @@ $spans[] = [
// add the array of spans to the transaction
$transaction->setSpans($spans);

// Do some stuff you want to watch ...
sleep(1);

$agent->stopTransaction($trxName);

// send our transactions to te apm
$agent->send();
```
Expand Down
4 changes: 2 additions & 2 deletions src/Events/EventBean.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ final protected function getContext() : array

// Build Context Stub
$SERVER_PROTOCOL = $_SERVER['SERVER_PROTOCOL'] ?? '';
$remote_address = $_SERVER['REMOTE_ADDR'];
$remote_address = $_SERVER['REMOTE_ADDR'] ?? '';
if (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER) === true) {
$remote_address = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
Expand All @@ -238,7 +238,7 @@ final protected function getContext() : array
'http_version' => substr($SERVER_PROTOCOL, strpos($SERVER_PROTOCOL, '/')),
'method' => $_SERVER['REQUEST_METHOD'] ?? 'cli',
'socket' => [
'remote_address' => $remote_address ?? '',
'remote_address' => $remote_address,
'encrypted' => isset($_SERVER['HTTPS'])
],
'response' => $this->contexts['response'],
Expand Down

0 comments on commit 68232fb

Please sign in to comment.