Adding a happy & comm failure test case for StatsDMonitor.
This checks some but not all of the counters but also makes sure the exceptional path branches are exercised.
To make this test possible, I added an additional constructor to StatsDMonitor that takes a StatsDClient.
Adding StatsDMonitor to DDAgentWriter
Modified Writer.createAgentWriter to read the health Monitor configs and construct StatsDMonitor when health metrics are enabled
Updated DDTracerTest to check for use of appropriate Monitor class depending on the Config
Introducing a Monitor for DDAgentWriter
Monitor can be used to track critical lifecycle events in the publishing of spans. This change only contains a NoopMonitor, but a StatsD variant will be added in later commit.
The DDAgentWriter has been altered to take a Monitor instance at construction for the purposes of testing the Monitor.
DDAgentWriter now includes tests to count spans published and sent -- including new tests for multi-threaded writing and slow agent response scenarios.
Changing the DDApi send methods to return a new Response object instead of a boolean result.
The Response object allows additional information to be propagated to the DDAgentWriter that is needed for helath monitoring.
Beyond success / fail represented by DDApi.Response.success, this includes...
- communication exception to the agent
- status code returned by the agent
- JSON parsing exception caused by bad payload returned by the agent
DDApiTest-s have also been updated to check response.success() but also to check response.status() as appropriate.
It is a linear operation that can take a long time when many spans are involved.
Using an atomic integer to track the size allows it to be a constant operation.
This is a more generic form of the previous `split-by-domain` and `split-by-instance`.
(Note: evaluation is done when a tag is set, so If multiple tags are configured, the last tag set will take precidence.)
For example, this setting can be used to rename `aws-sdk` spans to be identified with the corresponding `aws.service` tag:
```
-Ddd.trace.split-by-tags=aws.service
```
There are some slight differences with this setting compared with`dd.trace.http.client.split-by-domain` and `dd.trace.db.client.split-by-instance`. `split-by-tags` applies to every span, where `split-by-domain` and `split-by-instance` only apply to http and db client spans respectively.