-
Notifications
You must be signed in to change notification settings - Fork 282
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
OWIN HTTP server metrics #1335
OWIN HTTP server metrics #1335
Conversation
src/OpenTelemetry.Instrumentation.Owin/Implementation/DiagnosticsMiddleware.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Instrumentation.Owin/Implementation/DiagnosticsMiddleware.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Instrumentation.Owin/Implementation/DiagnosticsMiddleware.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Instrumentation.Owin/Implementation/DiagnosticsMiddleware.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Instrumentation.Owin/Implementation/DiagnosticsMiddleware.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Instrumentation.Owin/MetricProviderBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Instrumentation.Owin/Implementation/DiagnosticsMiddleware.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple nits but LGTM
src/OpenTelemetry.Instrumentation.Owin/Implementation/OwinInstrumentationMetrics.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM: Noticed that traces use the older semantic conventions. not sure if those can be updated without going through the transition phase as we are doing in httpclient and aspnetcore libraries. @CodeBlanch - Could you please confirm?
I'm good merging as-is. @matt-hensley I think we need a follow-up effort to look at |
test/OpenTelemetry.Instrumentation.Owin.Tests/DiagnosticsMiddlewareTests.cs
Outdated
Show resolved
Hide resolved
test/OpenTelemetry.Instrumentation.Owin.Tests/DiagnosticsMiddlewareTests.cs
Outdated
Show resolved
Hide resolved
LGTM. Please modify the readme file to include this change. In particular, document that Metrics can be enabled irrespective of tracing (since some other libraries have this limitation). |
|
||
// metric value and span duration should match | ||
// https://github.com/open-telemetry/semantic-conventions/blob/main/docs/http/http-metrics.md#metric-httpserverrequestduration | ||
Assert.Equal(activity.Duration.TotalSeconds, metricPoint.GetHistogramSum()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there test covering the scenario where instrumentTraces = false?, and it relies on its own timestamp to do duration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests were updated to to cover metrics + traces, only traces, only metrics and neither enabled. There is not a check for the Stopwatch based duration, however there is an assertion to ensure the histogram has a value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it.
There is not a check for the Stopwatch based duration, however there is an assertion to ensure the histogram has a value
Nonblocking: It'd be good to cover that to check the actual duration in a future improvement! (the test can setup its own stopwatch, and check that the duration calculated by instrumentaion is within a reasonable range of that.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Please add to readme file. Also left a minor comment about potential test gap.
Call the `AddOwinInstrumentation` `MeterProviderBuilder` extension to register | ||
OpenTelemetry instrumentation which generates request duration metrics for OWIN requests. | ||
|
||
The metric implemention does not rely on tracing, and will generate metrics even if tracing is disabled. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯 love this part!
using var openTelemetry = Sdk.CreateMeterProviderBuilder() | ||
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("Owin-Example")) | ||
.AddOwinInstrumentation() | ||
.AddConsoleExporter() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: show adding the nuget for console.
@matt-hensley The CI check for markdown is failing. Please fix that and we can merge this PR. |
@CodeBlanch, I do not think it is worth to invest in |
Agree. Since this is starting fresh and already doing the new conventions, no need of the opt-in/out behavior. It made sense for other instrumentations which were producing old metrics for quite some time. |
@CodeBlanch was referring to using the environment variable for traces and NOT metrics which this library has been producing for quite some time. |
Got it! My bad! |
This has been merged for quite some time, yet it's not available in any Nuget version. |
Fixes #1306.
Changes
Adds HTTP server metrics for OWIN. There is a new
MeterProviderBuilder
extension methodAddOwinInstrumentation
that takes no options.Currently only three attributes are published: method, scheme, and status code. These are the only attributes published by the ASP.NET instrumentation, making the two instrumentations interchangeable.
Tests were modified to cover metrics with and without an active trace.
When there is an active trace, the Activity duration is used, otherwise a separate timer is spun up.
CHANGELOG.md
updated for non-trivial changes