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 #95 from philkra/metricset-with-tags
Browse files Browse the repository at this point in the history
Metricset with tags
  • Loading branch information
philkra authored Sep 5, 2019
2 parents 09371df + 7e70d49 commit bc7376e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
8 changes: 7 additions & 1 deletion docs/examples/spans.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@
Please consult the documentation for your exact needs.
Below is an example to add spans for MySQL, Redis and generic request wraped by a parent span.

![Dashboard](https://github.com/philkra/elastic-apm-php-agent/blob/master/docs/examples/blob/span_dashboard.png "Spans Dashboard") ![Stacktrace](https://github.com/philkra/elastic-apm-php-agent/blob/master/docs/examples/blob/span_stacktrace.png "Span Stacktrace")
## Screenshots
**Transactions Dashboard showing the Spans**
![Dashboard](https://github.com/philkra/elastic-apm-php-agent/blob/master/docs/examples/blob/span_overview.png "Spans Dashboard")

**Stacktrace of a Span**
![Stacktrace](https://github.com/philkra/elastic-apm-php-agent/blob/master/docs/examples/blob/span_stacktrace.png "Span Stacktrace")

## Example Code
```php
// create the agent
$agent = new \PhilKra\Agent(['appName' => 'examples']);
Expand Down
2 changes: 1 addition & 1 deletion src/Events/DefaultEventFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function newSpan(string $name, EventBean $parent): Span
/**
* {@inheritdoc}
*/
public function newMetricset($set, $tags): Metricset
public function newMetricset(array $set, array $tags = []): Metricset
{
return new Metricset($set, $tags);
}
Expand Down
8 changes: 0 additions & 8 deletions src/Events/EventBean.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,6 @@ class EventBean
*/
private $parentId = null;

/**
* Offset between the current Event and the parent Event's
*
* @var number
*/
private $parentTimestampOffset = null;

/**
* Error occurred on Timestamp
*
Expand Down Expand Up @@ -188,7 +181,6 @@ public function setParent(EventBean $parent)
{
$this->setParentId($parent->getId());
$this->setTraceId($parent->getTraceId());
$this->parentTimestampOffset = ($this->getTimestamp() - $parent->getTimestamp());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Events/EventFactoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ public function newSpan(string $name, EventBean $parent): Span;
*
* @return Metricset
*/
public function newMetricset($set, $tags): Metricset;
public function newMetricset(array $set, array $tags = []): Metricset;

}
3 changes: 2 additions & 1 deletion src/Events/Metricset.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Metricset extends EventBean implements \JsonSerializable
* @param array $set
* @param array $tags
*/
public function __construct(array $set, array $tags)
public function __construct(array $set, array $tags = [])
{
parent::__construct([]);
foreach($set as $k => $v) {
Expand All @@ -47,6 +47,7 @@ public function jsonSerialize() : array
return [
'metricset' => [
'samples' => $this->samples,
// 'tags' => $this->tags,
'timestamp' => $this->getTimestamp(),
]
];
Expand Down

0 comments on commit bc7376e

Please sign in to comment.