Skip to content

Commit 431dbc3

Browse files
committed
Add AuthN and AuthZ metrics
1 parent 15ff0ab commit 431dbc3

File tree

5 files changed

+421
-0
lines changed

5 files changed

+421
-0
lines changed

.chloggen/2530.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
change_type: enhancement
2+
component: aspnetcore
3+
note: Add ASP.NET Core authentication and authorization metrics and update the registry.
4+
issues: [2530]

docs/dotnet/dotnet-aspnetcore-metrics.md

Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ This article defines semantic conventions for ASP.NET Core metrics.
2121
- [Metric: `aspnetcore.rate_limiting.queued_requests`](#metric-aspnetcorerate_limitingqueued_requests)
2222
- [Metric: `aspnetcore.rate_limiting.request.time_in_queue`](#metric-aspnetcorerate_limitingrequesttime_in_queue)
2323
- [Metric: `aspnetcore.rate_limiting.requests`](#metric-aspnetcorerate_limitingrequests)
24+
- [Authentication](#authentication)
25+
- [Metric: `aspnetcore.authentication.authenticate.duration`](#metric-aspnetcoreauthenticationauthenticateduration)
26+
- [Metric: `aspnetcore.authentication.challenges`](#metric-aspnetcoreauthenticationchallenges)
27+
- [Metric: `aspnetcore.authentication.forbids`](#metric-aspnetcoreauthenticationforbids)
28+
- [Metric: `aspnetcore.authentication.sign_ins`](#metric-aspnetcoreauthenticationsign_ins)
29+
- [Metric: `aspnetcore.authentication.sign_outs`](#metric-aspnetcoreauthenticationsign_outs)
30+
- [Authorization](#authorization)
31+
- [Metric: `aspnetcore.authorization.attempts`](#metric-aspnetcoreauthorizationattempts)
2432

2533
<!-- tocstop -->
2634

@@ -310,4 +318,228 @@ Meter name: `Microsoft.AspNetCore.RateLimiting`; Added in: ASP.NET Core 8.0
310318
<!-- END AUTOGENERATED TEXT -->
311319
<!-- endsemconv -->
312320

321+
## Authentication
322+
323+
### Metric: `aspnetcore.authentication.authenticate.duration`
324+
325+
<!-- semconv metric.aspnetcore.authentication.authenticate.duration -->
326+
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
327+
<!-- see templates/registry/markdown/snippet.md.j2 -->
328+
<!-- prettier-ignore-start -->
329+
<!-- markdownlint-capture -->
330+
<!-- markdownlint-disable -->
331+
332+
| Name | Instrument Type | Unit (UCUM) | Description | Stability | Entity Associations |
333+
| -------- | --------------- | ----------- | -------------- | --------- | ------ |
334+
| `aspnetcore.authentication.authenticate.duration` | Histogram | `s` | The authentication duration for a request. [1] | ![Development](https://img.shields.io/badge/-development-blue) | |
335+
336+
**[1]:** Meter name: `Microsoft.AspNetCore.Authentication`; Added in: ASP.NET Core 10.0
337+
338+
| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
339+
|---|---|---|---|---|---|
340+
| [`aspnetcore.authentication.result`](/docs/registry/attributes/aspnetcore.md) | string | The result of the authentication operation. | `success`; `failure` | `Required` | ![Development](https://img.shields.io/badge/-development-blue) |
341+
| [`aspnetcore.authentication.scheme`](/docs/registry/attributes/aspnetcore.md) | string | The identifier that names a particular authentication handler. | `Cookies`; `Bearer`; `Identity.Application` | `Conditionally Required` if a scheme is specified during authentication. | ![Development](https://img.shields.io/badge/-development-blue) |
342+
| [`error.type`](/docs/registry/attributes/error.md) | string | The full name of exception type. | `System.OperationCanceledException` | `Conditionally Required` if and only if an error has occurred. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) |
343+
344+
---
345+
346+
`aspnetcore.authentication.result` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
347+
348+
| Value | Description | Stability |
349+
|---|---|---|
350+
| `failure` | Authentication failed. | ![Development](https://img.shields.io/badge/-development-blue) |
351+
| `none` | No authentication information returned. | ![Development](https://img.shields.io/badge/-development-blue) |
352+
| `success` | Authentication was successful. | ![Development](https://img.shields.io/badge/-development-blue) |
353+
354+
---
355+
356+
`error.type` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
357+
358+
| Value | Description | Stability |
359+
|---|---|---|
360+
| `_OTHER` | A fallback error value to be used when the instrumentation doesn't define a custom value. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) |
361+
362+
<!-- markdownlint-restore -->
363+
<!-- prettier-ignore-end -->
364+
<!-- END AUTOGENERATED TEXT -->
365+
<!-- endsemconv -->
366+
367+
### Metric: `aspnetcore.authentication.challenges`
368+
369+
<!-- semconv metric.aspnetcore.authentication.challenges -->
370+
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
371+
<!-- see templates/registry/markdown/snippet.md.j2 -->
372+
<!-- prettier-ignore-start -->
373+
<!-- markdownlint-capture -->
374+
<!-- markdownlint-disable -->
375+
376+
| Name | Instrument Type | Unit (UCUM) | Description | Stability | Entity Associations |
377+
| -------- | --------------- | ----------- | -------------- | --------- | ------ |
378+
| `aspnetcore.authentication.challenges` | Counter | `{challenge}` | The total number of times a scheme is challenged. [1] | ![Development](https://img.shields.io/badge/-development-blue) | |
379+
380+
**[1]:** Meter name: `Microsoft.AspNetCore.Authentication`; Added in: ASP.NET Core 10.0
381+
382+
| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
383+
|---|---|---|---|---|---|
384+
| [`aspnetcore.authentication.scheme`](/docs/registry/attributes/aspnetcore.md) | string | The identifier that names a particular authentication handler. | `Cookies`; `Bearer`; `Identity.Application` | `Conditionally Required` if a scheme is specified during authentication. | ![Development](https://img.shields.io/badge/-development-blue) |
385+
| [`error.type`](/docs/registry/attributes/error.md) | string | The full name of exception type. | `System.OperationCanceledException` | `Conditionally Required` if and only if an error has occurred. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) |
386+
387+
---
388+
389+
`error.type` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
390+
391+
| Value | Description | Stability |
392+
|---|---|---|
393+
| `_OTHER` | A fallback error value to be used when the instrumentation doesn't define a custom value. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) |
394+
395+
<!-- markdownlint-restore -->
396+
<!-- prettier-ignore-end -->
397+
<!-- END AUTOGENERATED TEXT -->
398+
<!-- endsemconv -->
399+
400+
### Metric: `aspnetcore.authentication.forbids`
401+
402+
<!-- semconv metric.aspnetcore.authentication.forbids -->
403+
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
404+
<!-- see templates/registry/markdown/snippet.md.j2 -->
405+
<!-- prettier-ignore-start -->
406+
<!-- markdownlint-capture -->
407+
<!-- markdownlint-disable -->
408+
409+
| Name | Instrument Type | Unit (UCUM) | Description | Stability | Entity Associations |
410+
| -------- | --------------- | ----------- | -------------- | --------- | ------ |
411+
| `aspnetcore.authentication.forbids` | Counter | `{forbid}` | The total number of times an authenticated user attempts to access a resource they are not permitted to access. [1] | ![Development](https://img.shields.io/badge/-development-blue) | |
412+
413+
**[1]:** Meter name: `Microsoft.AspNetCore.Authentication`; Added in: ASP.NET Core 10.0
414+
415+
| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
416+
|---|---|---|---|---|---|
417+
| [`aspnetcore.authentication.scheme`](/docs/registry/attributes/aspnetcore.md) | string | The identifier that names a particular authentication handler. | `Cookies`; `Bearer`; `Identity.Application` | `Conditionally Required` if a scheme is specified during authentication. | ![Development](https://img.shields.io/badge/-development-blue) |
418+
| [`error.type`](/docs/registry/attributes/error.md) | string | The full name of exception type. | `System.OperationCanceledException` | `Conditionally Required` if and only if an error has occurred. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) |
419+
420+
---
421+
422+
`error.type` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
423+
424+
| Value | Description | Stability |
425+
|---|---|---|
426+
| `_OTHER` | A fallback error value to be used when the instrumentation doesn't define a custom value. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) |
427+
428+
<!-- markdownlint-restore -->
429+
<!-- prettier-ignore-end -->
430+
<!-- END AUTOGENERATED TEXT -->
431+
<!-- endsemconv -->
432+
433+
### Metric: `aspnetcore.authentication.sign_ins`
434+
435+
<!-- semconv metric.aspnetcore.authentication.sign_ins -->
436+
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
437+
<!-- see templates/registry/markdown/snippet.md.j2 -->
438+
<!-- prettier-ignore-start -->
439+
<!-- markdownlint-capture -->
440+
<!-- markdownlint-disable -->
441+
442+
| Name | Instrument Type | Unit (UCUM) | Description | Stability | Entity Associations |
443+
| -------- | --------------- | ----------- | -------------- | --------- | ------ |
444+
| `aspnetcore.authentication.sign_ins` | Counter | `{sign_in}` | The total number of times a principal is signed in with a scheme. [1] | ![Development](https://img.shields.io/badge/-development-blue) | |
445+
446+
**[1]:** Meter name: `Microsoft.AspNetCore.Authentication`; Added in: ASP.NET Core 10.0
447+
448+
| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
449+
|---|---|---|---|---|---|
450+
| [`aspnetcore.authentication.scheme`](/docs/registry/attributes/aspnetcore.md) | string | The identifier that names a particular authentication handler. | `Cookies`; `Bearer`; `Identity.Application` | `Conditionally Required` if a scheme is specified during authentication. | ![Development](https://img.shields.io/badge/-development-blue) |
451+
| [`error.type`](/docs/registry/attributes/error.md) | string | The full name of exception type. | `System.OperationCanceledException` | `Conditionally Required` if and only if an error has occurred. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) |
452+
453+
---
454+
455+
`error.type` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
456+
457+
| Value | Description | Stability |
458+
|---|---|---|
459+
| `_OTHER` | A fallback error value to be used when the instrumentation doesn't define a custom value. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) |
460+
461+
<!-- markdownlint-restore -->
462+
<!-- prettier-ignore-end -->
463+
<!-- END AUTOGENERATED TEXT -->
464+
<!-- endsemconv -->
465+
466+
### Metric: `aspnetcore.authentication.sign_outs`
467+
468+
<!-- semconv metric.aspnetcore.authentication.sign_outs -->
469+
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
470+
<!-- see templates/registry/markdown/snippet.md.j2 -->
471+
<!-- prettier-ignore-start -->
472+
<!-- markdownlint-capture -->
473+
<!-- markdownlint-disable -->
474+
475+
| Name | Instrument Type | Unit (UCUM) | Description | Stability | Entity Associations |
476+
| -------- | --------------- | ----------- | -------------- | --------- | ------ |
477+
| `aspnetcore.authentication.sign_outs` | Counter | `{sign_out}` | The total number of times a principal is signed out with a scheme. [1] | ![Development](https://img.shields.io/badge/-development-blue) | |
478+
479+
**[1]:** Meter name: `Microsoft.AspNetCore.Authentication`; Added in: ASP.NET Core 10.0
480+
481+
| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
482+
|---|---|---|---|---|---|
483+
| [`aspnetcore.authentication.scheme`](/docs/registry/attributes/aspnetcore.md) | string | The identifier that names a particular authentication handler. | `Cookies`; `Bearer`; `Identity.Application` | `Conditionally Required` if a scheme is specified during authentication. | ![Development](https://img.shields.io/badge/-development-blue) |
484+
| [`error.type`](/docs/registry/attributes/error.md) | string | The full name of exception type. | `System.OperationCanceledException` | `Conditionally Required` if and only if an error has occurred. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) |
485+
486+
---
487+
488+
`error.type` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
489+
490+
| Value | Description | Stability |
491+
|---|---|---|
492+
| `_OTHER` | A fallback error value to be used when the instrumentation doesn't define a custom value. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) |
493+
494+
<!-- markdownlint-restore -->
495+
<!-- prettier-ignore-end -->
496+
<!-- END AUTOGENERATED TEXT -->
497+
<!-- endsemconv -->
498+
499+
## Authorization
500+
501+
### Metric: `aspnetcore.authorization.attempts`
502+
503+
<!-- semconv metric.aspnetcore.authorization.attempts -->
504+
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
505+
<!-- see templates/registry/markdown/snippet.md.j2 -->
506+
<!-- prettier-ignore-start -->
507+
<!-- markdownlint-capture -->
508+
<!-- markdownlint-disable -->
509+
510+
| Name | Instrument Type | Unit (UCUM) | Description | Stability | Entity Associations |
511+
| -------- | --------------- | ----------- | -------------- | --------- | ------ |
512+
| `aspnetcore.authorization.attempts` | Counter | `{attempt}` | The total number of authorization attempts. [1] | ![Development](https://img.shields.io/badge/-development-blue) | |
513+
514+
**[1]:** Meter name: `Microsoft.AspNetCore.Authorization`; Added in: ASP.NET Core 10.0
515+
516+
| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
517+
|---|---|---|---|---|---|
518+
| [`aspnetcore.user.is_authenticated`](/docs/registry/attributes/aspnetcore.md) | boolean | A value that indicates whether the user is authenticated. | `true` | `Required` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) |
519+
| [`aspnetcore.authorization.policy`](/docs/registry/attributes/aspnetcore.md) | string | The name of the authorization policy. | `RequireAdminRole` | `Conditionally Required` if a policy is specified. | ![Development](https://img.shields.io/badge/-development-blue) |
520+
| [`aspnetcore.authorization.result`](/docs/registry/attributes/aspnetcore.md) | string | The result of calling the authorization service. | `success`; `failure` | `Conditionally Required` if no exception was thrown. | ![Development](https://img.shields.io/badge/-development-blue) |
521+
| [`error.type`](/docs/registry/attributes/error.md) | string | The full name of exception type. | `System.OperationCanceledException` | `Conditionally Required` if and only if an error has occurred. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) |
522+
523+
---
524+
525+
`aspnetcore.authorization.result` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
526+
527+
| Value | Description | Stability |
528+
|---|---|---|
529+
| `failure` | Authorization failed. | ![Development](https://img.shields.io/badge/-development-blue) |
530+
| `success` | Authorization was successful. | ![Development](https://img.shields.io/badge/-development-blue) |
531+
532+
---
533+
534+
`error.type` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
535+
536+
| Value | Description | Stability |
537+
|---|---|---|
538+
| `_OTHER` | A fallback error value to be used when the instrumentation doesn't define a custom value. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) |
539+
540+
<!-- markdownlint-restore -->
541+
<!-- prettier-ignore-end -->
542+
<!-- END AUTOGENERATED TEXT -->
543+
<!-- endsemconv -->
544+
313545
[DocumentStatus]: https://opentelemetry.io/docs/specs/otel/document-status

0 commit comments

Comments
 (0)