-
Notifications
You must be signed in to change notification settings - Fork 357
[Instrumentation.AspNet] Update semantic conventions for metrics #1429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
158d4de
1126f11
b8f19ad
b9b02a8
f14f43f
22aaef2
ec284b1
609bda5
5c00e8e
d780ca6
0b04175
ec7158e
c444309
fc7e83f
4480d65
73b6759
33c750e
2a73a4b
706f14f
e349bfb
3dd0fae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,24 @@ | |
| * New overload of `AddAspNetInstrumentation` now accepts a configuration delegate. | ||
| * The `Enrich` can be used to add additional metric attributes. | ||
|
|
||
| * HTTP server metrics now follow stable | ||
| [semantic conventions](https://github.com/open-telemetry/semantic-conventions/blob/v1.23.0/docs/http/http-metrics.md#http-server). | ||
|
|
||
| The `http.request.duration` metric is replaced with `http.server.request.duration`. | ||
| Note that the unit changes from milliseconds to seconds. | ||
|
||
| ([#1429](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1429)): | ||
|
|
||
| The following metric attributes has been added: | ||
|
|
||
| * `http.request.method` (previously `http.method`) | ||
| * `http.response.status_code` (previously `http.status_code`) | ||
| * `url.scheme` (previously `http.scheme`) | ||
| * `server.address` | ||
| * `server.port` | ||
| * `network.protocol.name` (http) | ||
| * `network.protocol.version` (`1.1`, `2`, `3`) | ||
| * `http.route` | ||
|
|
||
| ## 1.6.0-beta.2 | ||
|
|
||
| Released 2023-Nov-06 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| // <copyright file="HttpRequestRouteHelper.cs" company="OpenTelemetry Authors"> | ||
| // Copyright The OpenTelemetry Authors | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
| // </copyright> | ||
|
|
||
| using System; | ||
| using System.Web; | ||
| using System.Web.Routing; | ||
|
|
||
| namespace OpenTelemetry.Instrumentation.AspNet.Implementation; | ||
|
|
||
| /// <summary> | ||
| /// Helper class for processing http requests. | ||
| /// </summary> | ||
| internal class HttpRequestRouteHelper | ||
qhris marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| private readonly PropertyFetcher<object> routeFetcher = new("Route"); | ||
| private readonly PropertyFetcher<string> routeTemplateFetcher = new("RouteTemplate"); | ||
|
|
||
| /// <summary> | ||
| /// Extracts the route template from the <see cref="HttpRequest"/>. | ||
| /// </summary> | ||
| /// <param name="request">The <see cref="HttpRequest"/> being processed.</param> | ||
| /// <returns>The route template or <see langword="null"/>.</returns> | ||
| internal string? GetRouteTemplate(HttpRequest request) | ||
| { | ||
| var routeData = request.RequestContext.RouteData; | ||
|
|
||
| string? template = null; | ||
| if (routeData.Values.TryGetValue("MS_SubRoutes", out object msSubRoutes)) | ||
| { | ||
| // WebAPI attribute routing flows here. Use reflection to not take a dependency on microsoft.aspnet.webapi.core\[version]\lib\[framework]\System.Web.Http. | ||
|
|
||
| if (msSubRoutes is Array attributeRouting && attributeRouting.Length == 1) | ||
| { | ||
| var subRouteData = attributeRouting.GetValue(0); | ||
|
|
||
| _ = this.routeFetcher.TryFetch(subRouteData, out var route); | ||
| _ = this.routeTemplateFetcher.TryFetch(route, out template); | ||
| } | ||
| } | ||
| else if (routeData.Route is Route route) | ||
| { | ||
| // MVC + WebAPI traditional routing & MVC attribute routing flow here. | ||
| template = route.Url; | ||
| } | ||
|
|
||
| return template; | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.