Skip to content

Rajgan/devopsflex-telemetry-web

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

devopsflex-telemetry-web

Contains ASPNET Core middleware and utility classes to facilitate bootstrapping devops-telemetry in ASPNET Core applications

How do I bootstrap it?

In your Startup Configure method just do UseBigBrotherExceptionHandler at the start of the pipeline

public void Configure(IApplicationBuilder app)
{
    // This should be done at the start of the pipeline or it won't catch exceptions
    // that happen on the pipeline before this
    app.UseBigBrotherExceptionHandler();
}

The middleware class needs IBigBrother as a service dependency, so you need to make sure it's bootstrapped.

What about configuration helpers?

The package contains a Telemetry POCO to facilitate binding to configuration sections

/// <summary>
/// Contains settings related to Telemetry.
/// </summary>
public class TelemetrySettings
{
    /// <summary>
    /// Gets and sets the main telemetry instrumentation key.
    /// </summary>
    public string InstrumentationKey { get; set; }

    /// <summary>
    /// Gets and sets the internal instrumentation key.
    /// </summary>
    public string InternalKey { get; set; }
}

That will bind to the Telemetry section of this JSON settings example

{
    "Telemetry": {
        "InstrumentationKey": "SOME-KEY",
        "InternalKey": "ANOTHER-KEY"
    }
}

BadRequestException

The middleware will convert BadRequestException into an HTTP400 and relevant JSON payload. It contains a set of extension methods that facilitate working with this Exception:

[HttpPost]
[SwaggerOperation("CreateBrowser")]
[ProducesResponseType(typeof(BrowserResponse), 200)]
public async Task<IActionResult> CreateAsync([FromBody] BrowserRequest newBrowser)
{
    BadRequestThrowIf.NullOrWhiteSpace(() => newBrowser.SomeParam, () => newBrowser.AnotherParam);

    // Do some stuff

    return Ok();
}

About

ASPNET Core features on top of DevOpsFlex.Telemetry

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages