Giter VIP home page Giter VIP logo

elastic-apm-extensions's Introduction

Elastic APM extensions for multiple .NET libraries.

Features

MassTransit

Extension MassTransit
Version 1 Version 7

Usage

public static IHostBuilder CreateHostBuilder(string[] args) =>
    Host.CreateDefaultBuilder(args)
        .ConfigureWebHostDefaults(webBuilder =>
        {
            webBuilder.UseStartup<Startup>();
        })
        .UseElasticApm(
            // Add additional diagnostic subscribers e.g. AspNetCore, Http, etc
            new MassTransitDiagnosticsSubscriber());

The following events from the MassTransit DiagnosticSource are instrumented:

  • Transport.Send
  • Transport.Receive

Options

By default the Elastic APM send/receive label will be as follow:

This can be changed when creating the MassTransitDiagnosticsSubscriber by providing a different label.

new MassTransitDiagnosticsSubscriber(o => 
  o.ReceiveLabel = context => context.Host.AbsolutePath)

or if you return null, the default label will be used.

new MassTransitDiagnosticsSubscriber(o => 
  o.ReceiveLabel = context => 
    if (context is RabbitMqReceiveContext rabbitMqContext)
      ? rabbitMqContext.Exchange
      : default;)

The same can be used also for SendLabel

HotChocolate

Extension HotChocolate
Version 1 Version 11
Version 2 Version 12

Usage

HotChocolate by default is not emitting diagnostic events, but has the infrastructure to instrument each request.

public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        // Add your services

        // Add HotChocolate GraphQL Server
        services
            .AddGraphQLServer()
            .AddQueryType<Query>()
            .AddObservability(); // Register instrumentation for Elastic APM
    }
}

Options

Elastic APM Transaction can be enriched by registering a delegate on configure parameter. In this way you can add custom data to the transaction.

services
    .AddGraphQLServer()
    .AddObservability(o => 
        o.Enrich = (transaction, operationDetails) =>
        {
            transaction.SetLabel("GraphQLResult", operationDetails.HasFailed);
            transaction.SetLabel("Department", Environment.GetEnvironmentVariable("DEPARTMENT"));
        });

Community

This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our community. For more information, see the Swiss Life OSS Code of Conduct.

elastic-apm-extensions's People

Contributors

glucaci avatar johano avatar vhatsura 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.