Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mnie/appinsights.enricher
Enrich your telemetry data!
https://github.com/mnie/appinsights.enricher
appinsights azure csharp telemetry
Last synced: 2 days ago
JSON representation
Enrich your telemetry data!
- Host: GitHub
- URL: https://github.com/mnie/appinsights.enricher
- Owner: MNie
- License: mit
- Created: 2019-05-14T22:37:31.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-06-22T22:22:41.000Z (over 2 years ago)
- Last Synced: 2023-03-06T06:16:18.778Z (over 1 year ago)
- Topics: appinsights, azure, csharp, telemetry
- Language: C#
- Homepage:
- Size: 41 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AppInsights.Enricher [![NuGet](https://buildstats.info/nuget/AppInsights.Enricher?includePreReleases=true)](https://www.nuget.org/packages/AppInsights.Enricher)
Could be downloaded from NuGet:
- ```Install-Package AppInsights.Enricher```
- ```dotnet add package AppInsights.Enricher```
- ```paket add AppInsights.Enricher```How to use it:
* implement own ITelemetryEnricher
You say here when you want to store Request/Response:```csharp
public class CustomTelemetryEnricher : ITelemetryEnricher
{
public ITelemetry Enrich(ITelemetry tele) => tele;
public bool AttachRequest(HttpContext context) => true;
public bool AttachResponse(HttpContext context) => context?.Request?.Path.Value?.Contains("mail") == true;
}
```* implement own IProcessorApplier
You say here when you want to log data to AppInsights```csharp
public class CustomProcessorApplier: IProcessorApplier
{
public bool Apply(ITelemetry tele)
{
if (tele is RequestTelemetry request)
{
var isItBadRequestOrConnection = request.ResponseCode == "404";
if (isItBadRequestOrConnection)
return false;
}if (!(tele is DependencyTelemetry dependency)) return true;
return true;
}
}
```* Register it in container
```csharp
services.AddApplicationInsightsKubernetesEnricher();
services.AddSingleton();
services.AddSingleton();
services.AddSingleton(new RequestDataAccessor(1_000, 1_000, 100_000));
return services.AddTelemetry(new ApplicationInsightsServiceOptions { InstrumentationKey = "your_key" });
```And that's all!
If you want to read more about using this lib, you could take a look [at my blog post about it](https://www.mnie.me/appinsightslogging).