Skip to content

Commit

Permalink
Merge pull request #160 from AnthonySteele/docs-review-2
Browse files Browse the repository at this point in the history
Docs review 2
  • Loading branch information
AnthonySteele authored Dec 18, 2018
2 parents 0efbf73 + dd7c3de commit 756ad04
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,10 @@ services.AddStatsD(

#### .NET Core (AWS Lambda functions)

An example of registering StatsD dependencies using `IServiceCollection` when using an AWS Lambda function:
An example of registering StatsD dependencies using `IServiceCollection` when using the IP transport, e.g. for an AWS Lambda function:

```csharp
// Simple
services.AddSingleton<IStatsDTransport, IpTransport>();
services.AddStatsD(Environment.GetEnvironmentVariable("MY_STATSD_ENDPOINT"));

// Advanced
services.AddSingleton<IStatsDTransport, IpTransport>();
services.AddStatsD(
(provider) =>
{
Expand Down Expand Up @@ -208,15 +203,15 @@ The stopwatch is automatically stopped and the metric sent when it falls out of

Sometimes the decision of which stat to send should not be taken before the operation completes. e.g. When you are timing http operations and want different status codes to be logged under different stats.

The `IDisposableTimer` has a `StatName` property to set or change the name of the stat. To use this you need a reference to the timer, e.g. `using (var timer = stats.StartTimer("statName"))` instead of `using (stats.StartTimer("statName"))`
The `IDisposableTimer` has a `Bucket` property to set or change the stat bucket - i.e. the name of the stat. To use this you need a reference to the timer, e.g. `using (var timer = stats.StartTimer("statName"))` instead of `using (stats.StartTimer("statName"))`

The stat name must be set to a non-empty string at the end of the `using` block.

```csharp
using (var timer = stats.StartTimer("SomeHttpOperation."))
{
var response = DoSomeHttpOperation();
timer.StatName = timer.StatName + (int)response.StatusCode;
timer.Bucket = timer.Bucket + (int)response.StatusCode;
return response;
}
```
Expand Down

0 comments on commit 756ad04

Please sign in to comment.