-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from jcchavezs/adds_support_for_reporter_metrics
Adds support for reporter metrics.
- Loading branch information
Showing
10 changed files
with
457 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ php: | |
- '5.6' | ||
- '7.0' | ||
- '7.1' | ||
- '7.2' | ||
|
||
install: | ||
- composer install | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
<?php | ||
|
||
namespace Zipkin\Reporters; | ||
|
||
final class InMemoryMetrics implements Metrics | ||
{ | ||
/** | ||
* @var int | ||
*/ | ||
private $spansCount = 0; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
private $spanBytesCount = 0; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
private $spansDroppedCount = 0; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
private $messagesCount = 0; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
private $messagesDroppedCount = 0; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
private $messageBytes = 0; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
private $queuedSpans = 0; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
private $queuedBytes = 0; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function incrementSpans($quantity) | ||
{ | ||
$this->spansCount += $quantity; | ||
} | ||
|
||
public function getSpans() | ||
{ | ||
return $this->spansCount; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function incrementSpansDropped($quantity) | ||
{ | ||
$this->spansDroppedCount += $quantity; | ||
} | ||
|
||
public function getSpansDropped() | ||
{ | ||
return $this->spansDroppedCount; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function incrementSpanBytes($quantity) | ||
{ | ||
$this->spanBytesCount += $quantity; | ||
} | ||
|
||
public function getSpanBytes() | ||
{ | ||
return $this->spanBytesCount; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function incrementMessages() | ||
{ | ||
$this->messagesCount++; | ||
} | ||
|
||
public function getMessages() | ||
{ | ||
return $this->messagesCount; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function incrementMessagesDropped($cause) | ||
{ | ||
$this->messagesDroppedCount++; | ||
} | ||
|
||
public function getMessagesDropped() | ||
{ | ||
return $this->messagesDroppedCount; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function incrementMessageBytes($quantity) | ||
{ | ||
$this->messageBytes += $quantity; | ||
} | ||
|
||
public function getMessageBytes() | ||
{ | ||
return $this->messageBytes; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function updateQueuedSpans($update) | ||
{ | ||
$this->queuedSpans = $update; | ||
} | ||
|
||
public function getQueuedSpans() | ||
{ | ||
return $this->queuedSpans; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function updateQueuedBytes($update) | ||
{ | ||
$this->queuedBytes = $update; | ||
} | ||
|
||
public function getQueuedBytes() | ||
{ | ||
return $this->queuedBytes; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?php | ||
|
||
namespace Zipkin\Reporters; | ||
|
||
/** | ||
* Instrumented applications report spans over a transport such as Kafka to Zipkin Collectors. | ||
* | ||
* <p>Callbacks on this type are invoked by zipkin reporters to improve the visibility of the | ||
* system. A typical implementation will report metrics to a telemetry system for analysis and | ||
* reporting.</p> | ||
* | ||
* <h3>Spans Reported vs Queryable Spans</h3> | ||
* | ||
* <p>A span in the context of reporting is <= span in the context of query. Instrumentation should | ||
* report a span only once except, but certain types of spans cross the network. For example, RPC | ||
* spans are reported at the client and the server separately.</p> | ||
* | ||
* <h3>Key Relationships</h3> | ||
* | ||
* <p>The following relationships can be used to consider health of the tracing system. | ||
* <pre> | ||
* <ul> | ||
* <li>{@link #updateQueuedSpans Pending spans}. Alert when this increases over time as it could | ||
* lead to dropped spans. | ||
* <li>Dropped spans = Alert when this increases as it could indicate a queue backup. | ||
* <li>Successful Messages = {@link #incrementMessages() Accepted messages} - | ||
* {@link #incrementMessagesDropped Dropped messages}. Alert when this is more than amount of | ||
* messages received from collectors.</li> | ||
* </li> | ||
* </ul> | ||
* </pre> | ||
*/ | ||
interface Metrics | ||
{ | ||
/** | ||
* Increments count of message attempts, which contain 1 or more spans. Ex POST requests or Kafka | ||
* messages sent. | ||
*/ | ||
public function incrementMessages(); | ||
|
||
/** | ||
* Increments count of messages that could not be sent. Ex host unavailable, or peer disconnect. | ||
* @param \Throwable|\Exception $cause | ||
* @return void | ||
*/ | ||
public function incrementMessagesDropped($cause); | ||
|
||
/** | ||
* Increments the count of spans reported. When {@link AsyncReporter} is used, reported spans will | ||
* usually be a larger number than messages. | ||
* | ||
* @param int $quantity | ||
* @return void | ||
*/ | ||
public function incrementSpans($quantity); | ||
|
||
/** | ||
* Increments the number of encoded span bytes reported. | ||
* @param int $quantity | ||
* @return void | ||
*/ | ||
public function incrementSpanBytes($quantity); | ||
|
||
/** | ||
* Increments the number of bytes containing encoded spans in a message. | ||
* | ||
* <p>This is a function of span bytes per message and overhead</p> | ||
* | ||
* @see Sender#messageSizeInBytes | ||
* @param $quantity | ||
* @return void | ||
*/ | ||
public function incrementMessageBytes($quantity); | ||
|
||
/** | ||
* Increments the count of spans dropped for any reason. For example, failure queueing or | ||
* sending. | ||
* | ||
* @param int $quantity | ||
* @return void | ||
*/ | ||
public function incrementSpansDropped($quantity); | ||
|
||
/** | ||
* Updates the count of spans pending, following a flush activity. | ||
* | ||
* @param int $update | ||
* @return void | ||
*/ | ||
public function updateQueuedSpans($update); | ||
|
||
/** | ||
* Updates the count of encoded span bytes pending, following a flush activity. | ||
* | ||
* @param int $update | ||
* @return void | ||
*/ | ||
public function updateQueuedBytes($update); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
namespace Zipkin\Reporters; | ||
|
||
final class NoopMetrics implements Metrics | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function incrementSpans($quantity) | ||
{ | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function incrementSpansDropped($quantity) | ||
{ | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function incrementMessages() | ||
{ | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function incrementMessagesDropped($cause) | ||
{ | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function incrementSpanBytes($quantity) | ||
{ | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function incrementMessageBytes($quantity) | ||
{ | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function updateQueuedSpans($update) | ||
{ | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function updateQueuedBytes($update) | ||
{ | ||
} | ||
} |
Oops, something went wrong.