{"id":26711660,"url":"https://github.com/swisslife-oss/elastic-apm-extensions","last_synced_at":"2025-04-13T19:51:08.042Z","repository":{"id":44869344,"uuid":"344741332","full_name":"SwissLife-OSS/elastic-apm-extensions","owner":"SwissLife-OSS","description":"Multiple .NET libraries instrumentations for Elastic APM Agent","archived":false,"fork":false,"pushed_at":"2023-02-17T14:15:55.000Z","size":59,"stargazers_count":4,"open_issues_count":5,"forks_count":4,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-27T10:36:21.382Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SwissLife-OSS.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-05T08:16:54.000Z","updated_at":"2022-01-12T16:17:56.000Z","dependencies_parsed_at":"2025-03-27T10:43:01.421Z","dependency_job_id":null,"html_url":"https://github.com/SwissLife-OSS/elastic-apm-extensions","commit_stats":null,"previous_names":[],"tags_count":36,"template":false,"template_full_name":"SwissLife-OSS/template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwissLife-OSS%2Felastic-apm-extensions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwissLife-OSS%2Felastic-apm-extensions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwissLife-OSS%2Felastic-apm-extensions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwissLife-OSS%2Felastic-apm-extensions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SwissLife-OSS","download_url":"https://codeload.github.com/SwissLife-OSS/elastic-apm-extensions/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248773765,"owners_count":21159517,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-27T10:30:07.227Z","updated_at":"2025-04-13T19:51:08.020Z","avatar_url":"https://github.com/SwissLife-OSS.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"Elastic APM extensions for multiple .NET libraries.\n## Features\n\n  - [X] [MassTransit](#masstrasit)\n  - [X] [HotChocolate](#hotchocolate)\n\n## MassTransit\n| Extension | MassTransit |\n| ----------|:-----------:|\n| Version 1 | Version 7   |\n### Usage\n```csharp\npublic static IHostBuilder CreateHostBuilder(string[] args) =\u003e\n    Host.CreateDefaultBuilder(args)\n        .ConfigureWebHostDefaults(webBuilder =\u003e\n        {\n            webBuilder.UseStartup\u003cStartup\u003e();\n        })\n        .UseElasticApm(\n            // Add additional diagnostic subscribers e.g. AspNetCore, Http, etc\n            new MassTransitDiagnosticsSubscriber());\n```\n\nThe following events from the [MassTransit DiagnosticSource](https://masstransit-project.com/advanced/monitoring/diagnostic-source.html) are instrumented:\n- `Transport.Send` \n- `Transport.Receive`\n### Options\nBy default the Elastic APM send/receive label will be as follow:\n- \"Send {label}\" where label is [`SendContext.DestinationAddress.AbsolutePath`](https://github.com/MassTransit/MassTransit/blob/5e2a416384f005c392ead139f5c4af34511c56db/src/MassTransit/SendContext.cs#L31)\n- \"Receive {label}\" where label is [`ReceiveContext.InputAddress.AbsolutePath`](https://github.com/MassTransit/MassTransit/blob/5e2a416384f005c392ead139f5c4af34511c56db/src/MassTransit/ReceiveContext.cs#L24)\n\nThis can be changed when creating the `MassTransitDiagnosticsSubscriber` by providing a different label.\n```csharp\nnew MassTransitDiagnosticsSubscriber(o =\u003e \n  o.ReceiveLabel = context =\u003e context.Host.AbsolutePath)\n```\nor if you return `null`, the default label will be used.\n```csharp\nnew MassTransitDiagnosticsSubscriber(o =\u003e \n  o.ReceiveLabel = context =\u003e \n    if (context is RabbitMqReceiveContext rabbitMqContext)\n      ? rabbitMqContext.Exchange\n      : default;)\n```\nThe same can be used also for `SendLabel`\n## HotChocolate\n| Extension | HotChocolate |\n| ----------|:------------:|\n| Version 1 | Version 11   |\n| Version 2 | Version 12   |\n### Usage\nHotChocolate by default is not emitting diagnostic events, but has the infrastructure to instrument each request.\n```csharp\npublic class Startup\n{\n    public void ConfigureServices(IServiceCollection services)\n    {\n        // Add your services\n\n        // Add HotChocolate GraphQL Server\n        services\n            .AddGraphQLServer()\n            .AddQueryType\u003cQuery\u003e()\n            .AddObservability(); // Register instrumentation for Elastic APM\n    }\n}\n```\n### Options\nElastic APM Transaction can be enriched by registering a delegate on configure parameter. In this way you can add custom data to the transaction.\n```csharp\nservices\n    .AddGraphQLServer()\n    .AddObservability(o =\u003e \n        o.Enrich = (transaction, operationDetails) =\u003e\n        {\n            transaction.SetLabel(\"GraphQLResult\", operationDetails.HasFailed);\n            transaction.SetLabel(\"Department\", Environment.GetEnvironmentVariable(\"DEPARTMENT\"));\n        });\n```\n\n## Community\n\nThis project has adopted the code of conduct defined by the [Contributor Covenant](https://contributor-covenant.org/)\nto clarify expected behavior in our community. For more information, see the [Swiss Life OSS Code of Conduct](https://swisslife-oss.github.io/coc).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswisslife-oss%2Felastic-apm-extensions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswisslife-oss%2Felastic-apm-extensions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswisslife-oss%2Felastic-apm-extensions/lists"}