Code Monkey home page Code Monkey logo

opentracing-sqs-csharp's Introduction

OpenTracing Badge Build status NuGet License

opentracing-sqs-csharp

A simple C# library for instrumentation of SQS messages with OpenTracing.

Dependencies

  • NET Core 3.1
  • AWSSDK.SQS 3.3.102.54
  • OpenTracing

Installation

Install the NuGet package:

> dotnet add package EventBus.Sqs

> dotnet add package EventBus.Sqs.Tracing

Getting started

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;
});

Check this link for more information about Jaeger configuration via environment.

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();

Configure health checks for SQS

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;
    }
}

More examples:

Link

Tracing

Contact

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.

License

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.

opentracing-sqs-csharp's People

Contributors

juniortads avatar joeljoseitau avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.