dotnet / dotnet/docs

[Metrics] Create custom metrics with DI integration

Open
#36,749 0 comments 0 reactions 1 assignee Claimed by @noahfalk View on GitHub
Dominant language
No language data
Stars
4.8k
Forks
6.1k
Avg merge
15h 21m
Merged PRs (30d)
370

Description

The current documentation for creating a custom metric recommends static meter and counters: https://learn.microsoft.com/en-us/dotnet/core/diagnostics/metrics-instrumentation#create-a-custom-metric

An alternative should be recommended that uses `IMeterFactory`, DI and a custom class that contains the counters. Should discuss how this is more unit testable.

An example worker template app (which uses generic host and DI) can show off writing metrics like this.

Can reuse content from ASP.NET Core docs: https://github.com/dotnet/AspNetCore.Docs/pull/30073

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.