A simple C# library for instrumentation of SQS messages with OpenTracing.
- NET Core 3.1
- AWSSDK.SQS 3.3.102.54
- OpenTracing
Install the NuGet package:
> dotnet add package EventBus.Sqs
> dotnet add package EventBus.Sqs.Tracing
Before, in your application's Startup.cs file, configure OpenTracing first.
using OpenTracing.Util;
...
services.AddSingleton(serviceProvider =>
{
var loggerFactory = new LoggerFactory();
var config = Jaeger.Configuration.FromEnv(loggerFactory);
var tracer = config.GetTracer();
if (!GlobalTracer.IsRegistered())
GlobalTracer.Register(tracer);
return tracer;
});
https://github.com/jaegertracing/jaeger-client-csharp
Next, configure EventBus.Sqs with tracing:
using EventBus.Sqs.Configuration;
using EventBus.Sqs.Tracing.Configuration;
...
services.AddEventBusSQS(Configuration)
.AddOpenTracing();
services.AddHealthChecks()
.AddSqsCheck<HereAddYourIntegrationEvent>();
Finally, We can using in your application's Controller.cs file, Check below this example:
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private readonly IEventBus eventBus;
public WeatherForecastController(IEventBus eventBus)
{
this.eventBus = eventBus;
}
[HttpPost]
public async Task<ActionResult> Create()
{
var rng = new Random();
//Create sample Integration Event
var weatherInEvent = new WeatherInEvent(Guid.NewGuid().ToString(), "Freezing");
await eventBus.Enqueue(weatherInEvent);
return Accepted();
}
}
Don't forget, Creating your Integration event:
public class WeatherInEvent : IntegrationEvent
{
public string WeatherEventId { get; set; }
public string Summary { get; set; }
public WeatherInEvent(string id, string summary) : base(id, DateTime.UtcNow)
{
WeatherEventId = id;
Summary = summary;
}
}
These email addresses serve as the main contact addresses for this project.
Bug reports and feature requests are more likely to be addressed if posted as issues here on GitHub.
This project is licensed under the terms of the MIT license, see also the full LICENSE.
MIT License
Copyright (c) 2020 Joel Junior
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.