This package makes it easy to instrument your .NET app to send useful events to Honeycomb, a service for debugging your software in production.
The library targets .NET Standard 2.0.
To build and test the project locally, you'll need .NET SDK 5.0+.
To build all the projects, run the following:
dotnet build
To run tests, run:
dotnet test
To create the nuget packages, run:
dotnet pack
using Honeycomb.AspNetCore.Middleware;
...
public void ConfigureServices(IServiceCollection services)
{
...
services.AddHoneycomb(Configuration);
...
}
Note the relative position to app.UseMvc()
using Honeycomb.AspNetCore.Middleware;
...
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
...
app.UseHoneycomb();
app.UseMvc();
...
}
Configuration can either be done through adding this to your appSettings.json
{
"HoneycombSettings": {
"WriteKey": "<your-writekey>",
"DefaultDataSet": "<your-dataset>",
"BatchSize": 100,
"SendFrequency": 10000
}
}
Or alternatively, you can create an instance of HoneycombApiSettings
and pass it directly to the Service registration:
using Honeycomb.Models;
...
services.AddHoneycomb(new HoneycombApiSettings {
WriteKey = "<your-writekey>",
DefaultDataSet = "<your-dataset>"
BatchSize = 100,
SendFrequency = 10000,
});
public class HomeController : Controller
{
private readonly IHoneycombEventManager _eventManager;
public HomeController(IHoneycombEventManager eventManager)
{
_eventManager = eventManager;
}
...
public IActionResult MyAction()
{
var stopWatch = new Stopwatch();
stopWatch.Start();
...
result = GetDataFromAPI();
...
stopWatch.Stop();
_eventManager.AddData("api_response_ms", stopWatch.ElapsedMilliseconds);
return result;
}
}
This project was kindly donated to Honeycomb by @martinjt.