MyCSharp.HttpUserAgentParser 3.1.2
MyCSharp.HttpUserAgentParser
Fast HTTP User-Agent parsing for .NET.
Repository: https://github.com/mycsharp/HttpUserAgentParser
Install
dotnet add package MyCSharp.HttpUserAgentParser
Quick start (no DI)
string userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36";
HttpUserAgentInformation info = HttpUserAgentParser.Parse(userAgent);
// or: HttpUserAgentInformation.Parse(userAgent)
Dependency injection
If you want to inject a parser (e.g., in ASP.NET Core), use IHttpUserAgentParserProvider.
No cache
services
.AddHttpUserAgentParser();
ConcurrentDictionary cache
services
.AddHttpUserAgentCachedParser();
// or: .AddHttpUserAgentParser<HttpUserAgentParserCachedProvider>();
Telemetry (EventCounters)
Telemetry is:
- Opt-in: disabled by default (keeps hot path overhead-free)
- Low overhead: counters are only written when a listener is attached
Enable telemetry (Fluent API)
services
.AddHttpUserAgentParser()
.WithTelemetry();
EventSource + counters
EventSource: MyCSharp.HttpUserAgentParser (constant: HttpUserAgentParserEventSource.EventSourceName)
parse.requests(incrementing)parse.duration(ms, event counter)cache.hit(incrementing)cache.miss(incrementing)cache.size(polling)
Monitor with dotnet-counters
dotnet-counters monitor --process-id <pid> MyCSharp.HttpUserAgentParser
Telemetry (native Meters)
In addition to EventCounters, this package can emit native System.Diagnostics.Metrics instruments.
Telemetry is:
- Opt-in: disabled by default (keeps hot path overhead-free)
- Low overhead: measurements are only recorded when enabled
Enable meters (Fluent API)
services
.AddHttpUserAgentParser()
.WithMeterTelemetry();
Meter + instruments
Meter: MyCSharp.HttpUserAgentParser (constant: HttpUserAgentParserMeters.MeterName)
parse.requests(counter)parse.duration(histogram, ms)cache.hit(counter)cache.miss(counter)cache.size(observable gauge)
Export to OpenTelemetry
You can collect these EventCounters via OpenTelemetry metrics and export them (OTLP, Prometheus, Azure Monitor, …).
Packages you typically need:
OpenTelemetryOpenTelemetry.Exporter.OpenTelemetryProtocol(or another exporter)OpenTelemetry.Instrumentation.EventCounters
Example (minimal):
using OpenTelemetry.Metrics;
using MyCSharp.HttpUserAgentParser.Telemetry;
builder.Services.AddOpenTelemetry()
.WithMetrics(metrics =>
{
metrics
.AddEventCountersInstrumentation(options =>
{
options.AddEventSources(HttpUserAgentParserEventSource.EventSourceName);
})
.AddOtlpExporter();
});
If you also use the MemoryCache/AspNetCore packages, add their EventSource names too.
Export native meters to OpenTelemetry
If you enabled native meters (see above), collect them via AddMeter(...):
using OpenTelemetry.Metrics;
using MyCSharp.HttpUserAgentParser.Telemetry;
builder.Services.AddOpenTelemetry()
.WithMetrics(metrics =>
{
metrics
.AddMeter(HttpUserAgentParserMeters.MeterName)
.AddOtlpExporter();
});
Export to Application Insights
There are two common approaches:
1) Recommended: OpenTelemetry → Application Insights
Collect with OpenTelemetry (see above) and export to Azure Monitor / Application Insights using an Azure Monitor exporter. This keeps your pipeline consistent and avoids custom listeners.
Typical packages (names may differ by version):
OpenTelemetryOpenTelemetry.Instrumentation.EventCountersAzure.Monitor.OpenTelemetry.Exporter
2) Custom EventListener → TelemetryClient
If you prefer a direct listener, you can attach an EventListener and forward values as custom metrics.
High-level idea:
- Enable the EventSource
- Parse the
EventCounterspayload - Track as Application Insights metrics
Notes:
- This is best-effort telemetry (caches can race)
- Keep aggregation intervals reasonable (e.g. 10s)
Showing the top 20 packages that depend on MyCSharp.HttpUserAgentParser.
| Packages | Downloads |
|---|---|
|
Volo.Abp.AspNetCore
Package Description
|
7 |
|
Volo.Abp.AspNetCore
Package Description
|
8 |
|
Volo.Abp.AspNetCore
Package Description
|
9 |
|
Volo.Abp.AspNetCore
Package Description
|
10 |
|
Volo.Abp.AspNetCore
Package Description
|
13 |
|
Volo.Abp.AspNetCore
Package Description
|
14 |
|
Volo.Abp.AspNetCore
Package Description
|
15 |
|
Volo.Abp.AspNetCore
Package Description
|
17 |
.NET 8.0
.NET 9.0
.NET 10.0
| Version | Downloads | Last updated |
|---|---|---|
| 3.1.2 | 2 | 02/21/2026 |
| 3.0.28 | 10 | 09/01/2025 |
| 3.0.27 | 11 | 08/25/2025 |
| 3.0.25 | 11 | 07/04/2025 |
| 3.0.23 | 11 | 07/04/2025 |
| 3.0.21-gd594614d04 | 12 | 07/04/2025 |
| 3.0.20-g7795a06d24 | 10 | 07/04/2025 |
| 3.0.19-g3452a5347c | 11 | 07/04/2025 |
| 3.0.18-gbf6637cea6 | 12 | 07/04/2025 |
| 3.0.13 | 11 | 07/04/2025 |
| 3.0.13-g9ebf55cc61 | 11 | 07/04/2025 |
| 3.0.12 | 12 | 07/04/2025 |
| 3.0.12-g2db20cc097 | 11 | 07/04/2025 |
| 3.0.11 | 11 | 07/04/2025 |
| 3.0.11-gd806c9c385 | 11 | 07/04/2025 |
| 3.0.10 | 11 | 07/04/2025 |
| 3.0.10-g39a7b02192 | 13 | 07/04/2025 |
| 3.0.9 | 11 | 07/04/2025 |
| 3.0.9-gffc9953931 | 11 | 07/04/2025 |
| 3.0.9-gbb914c5083 | 11 | 07/04/2025 |
| 3.0.8 | 11 | 07/04/2025 |
| 3.0.8-gc872dd36a7 | 11 | 07/04/2025 |
| 3.0.7 | 11 | 07/04/2025 |
| 3.0.7-g7326cc7952 | 11 | 07/04/2025 |
| 3.0.7-g23b089add4 | 13 | 07/04/2025 |
| 3.0.7-g16a90295af | 12 | 07/04/2025 |
| 3.0.6 | 11 | 07/04/2025 |
| 3.0.6-g1a8d58908d | 12 | 07/04/2025 |
| 3.0.5 | 12 | 07/04/2025 |
| 3.0.4 | 12 | 07/04/2025 |
| 3.0.3 | 11 | 07/04/2025 |
| 3.0.3-g52f717c570 | 11 | 07/04/2025 |
| 3.0.3-g2e3740f28e | 10 | 07/04/2025 |
| 3.0.2 | 11 | 07/04/2025 |
| 3.0.2-g1ec8e12b08 | 11 | 07/04/2025 |
| 3.0.1 | 12 | 07/04/2025 |
| 2.0.5-g44d1ffded6 | 12 | 07/04/2025 |
| 2.0.3 | 12 | 07/04/2025 |
| 2.0.2 | 12 | 07/04/2025 |
| 2.0.1 | 10 | 07/04/2025 |
| 1.1.5 | 11 | 07/04/2025 |
| 1.1.4 | 11 | 07/04/2025 |
| 1.1.2 | 11 | 07/04/2025 |
| 1.1.1 | 12 | 07/04/2025 |
| 0.1.20 | 13 | 07/04/2025 |
| 0.1.19 | 11 | 07/04/2025 |
| 0.1.18 | 12 | 07/04/2025 |
| 0.1.17 | 10 | 07/04/2025 |
| 0.1.15 | 11 | 07/04/2025 |
| 0.1.13-ga54ab93e06 | 10 | 07/04/2025 |
| 0.1.11-gf9f22361b4 | 11 | 07/04/2025 |
| 0.1.11-gd2c4a82063 | 12 | 07/04/2025 |
| 0.1.10-g97d215a597 | 12 | 07/04/2025 |
| 0.1.9-gfdbeeac4d0 | 13 | 07/04/2025 |
| 0.1.7-g4f7d811228 | 11 | 07/04/2025 |
| 0.1.3-ga995c8cead | 11 | 07/04/2025 |
| 0.1.2-g30a7553669 | 11 | 07/04/2025 |