-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Blazor - rendering metrics and tracing #61609
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
base: main
Are you sure you want to change the base?
Conversation
328a584
to
cebb68e
Compare
# Conflicts: # src/Components/Components/src/PublicAPI.Unshipped.txt
- add tracing
You're adding a lot of metrics here. I think you should do some performance testing. There is performance overhead of metrics - they require some synronization when incrementing counters and recording values. Having many low level metrics could cause performance issues. |
I removed few and kept only the most useful ones. I have 2 remaining issues
|
I don't know how Blazor circuits are created, but if it's from a Hub method then Activity.Current won't be the HTTP activity. We hop off the HTTP activity on purpose in SignalR: aspnetcore/src/SignalR/server/Core/src/Internal/DefaultHubDispatcher.cs Lines 398 to 403 in 9f2b088
Is that because the HTTP request is still running? I don't think activites show up in the dashboard until they're stopped, and if you're using SignalR you're likely using a websocket request which is long running. |
I'm capturing
This is it, thank you @BrennanConroy ! |
It's also topic to discuss for long running activities on Blazor.
We have 2 way how to deal with them I think
Right now I have short+links implementation. I guess developers use OTEL mostly in production and so even the long running traces would be recorded already. But maybe developers also use it in inner dev loop ? In which case it would be great to have "trace preview" for thing that started but not stopped yet. To not get confused the same way as I did. |
- cleanup
Co-authored-by: Noah Falk <[email protected]>
P0-P2 - This is useful angle, thanks!
Note, I also mention |
This goes back to my questions about long running activities. We can definitely improve naming.
Right now, the short circuit and route activities mostly serve as something that click event activities could link to. For the context. |
Maybe we just need to rename it? Anyway, this is more on the troubleshooting side of misbehaving component. Producing long diffs/batches leads to network traffic, latency and slow rendering. As I suggested above, we could have separate namespace for it with separate opt-in.
We also count exceptions per click/event. But I need to see if the exceptions from batch related problems would appear there.
At the moment this works only for SignalR interactive. I think we could also make it work for form-submit.
I already renamed this and dropped "async". It means including your DB request or whatever async business logic.
Yes, or
Except WASM.
It has the route pattern as tag/dimension that you can use as filter. It's more business oriented KPI. Which of my pages are hot ? |
Making circuit/route activity/trace long lived has troubles with re-installing them into If we keep them short, maybe they should be literally 0ms long. Just an context anchor, grouping other traces. Re Activity names: they are not very visible in the Aspire UI, and Circuit Activity/trace is created in internal Route Activity/trace is created in Regarding click/event. We already have concept of event. The activity should be active thru whole duration of I would like event Activity also trigger for form submit, interop call from JS, and enhanced navigation. Maybe we can change it to |
Sam: Is circuitId useful for DisplayName of Circuit activity? What else we could display there instead. Could we have IP address ? |
I met with @pavelsavara and I now understand what everything is for - it looks great. I think customers will be really happy with this. My concerns about granularity in terms of sending too much data have been mitigated. |
My mind set - if a customer is having an issue with your site, and calls IT to complain - how do they match the traces to the user? Is there somewhere that ID gets displayed to them? If we don't stick in that data (which is a good from a being secure by default position) is there a hook-point we can document before the activity is finished that the customer can access the activity and add their extra tags to it? As the circuit is created as an instantaneous activity, it may not be on the stack for many calls to user code where they can access it. |
I think this problem of mapping traces to users on hotline is not specific to Blazor. I'm linking the HTTP Activity/trace that created the circuit, so if there is more tags on the HTTP trace, they could use that (after the session and the long running HTTP/WS connection is finished). Sometimes there is authenticated user in the HTTP context, but I think it's probably not good for use to expose any PII. If the app developer wanted to add more tags, I believe that they could capture Maybe the app developer could also add "show my circuitID" into application settings menu and the IT call center could ask them to click it. The circuitID is random number and it's not a secret from security perspective. |
The activity is created in CircuitFactory at line 127 and is stopped at line 173. Is there any user code executed between these points where the activity would be active, so they can retrieve it and add tags. Once its stopped, AFAIK its too late to add anything to it. |
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.
Some naming suggestions.
For sessions, I wonder if when log messages are fired, is the activity context going to be the session activity, and if not is there a way to force it to be? @noahfalk this is an issue with essentially zero length spans - you might want to force log messages to be parented to it but something else is the activity at that point?
{ | ||
{ "component.type", componentType ?? "unknown" }, | ||
{ "component.method", methodName ?? "unknown" }, | ||
{ "attribute.name", attributeName ?? "unknown" } |
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.
I understand why this is based on the attribute, but its really also the event name. would that make more sense as "event"?
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.
This refers to onclick
in the example below. Attribute makes it easier for me personally but I don't have strong preference. It's attributeName
thru Blazor internals.
@danroth27 do you prefer "event" or something else ?
<button class="btn btn-primary" @onclick="Buy" @focus="OnFocus">Buy</button>
|
||
var tags = new TagList | ||
{ | ||
{ "component.type", componentType ?? "unknown" }, |
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.
code.class.name
? to match https://github.com/open-telemetry/semantic-conventions/blob/main/docs/attributes-registry/code.md
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.
We don't really have code reference, as in file name and line number.
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.
My initial thought is that the thing being refered to was the Blazor component abstraction in which case component.type and component.method made sense to me. The fact that code.class.name isn't currently defined also nudges me in that direction. If we did want to use code.* attributes instead this feels like another spot where OTel semconv feedback could be helpful.
Thanks, that helps a bunch on understanding where things are at now. A couple thoughts:
Activity.Current can be set at any time, but it can't be set to an Activity that is already stopped. If you did want to produce the set of all log messages that occurred within a given circuit I think the best options would be one of:
|
Co-authored-by: Sam Spencer <[email protected]>
Co-authored-by: Sam Spencer <[email protected]>
Co-authored-by: Sam Spencer <[email protected]>
All, I created open-telemetry/semantic-conventions#2235 in order to validate and document the new metrics in OTEL community. As a result I updated all tags in this PR with prefix |
@lmolkova's feedback on the other PR is
"event" means something specific in otel. But also something in the browser and in Blazor. Suggestion to rename
|
- rename aspnetcore.components.circuit to aspnetcore.components.circuits - rename circuits.active_circuits to circuit.active and connected_circuits to circuit.connected - rename aspnetcore.components.event.duration to aspnetcore.components.event_handler and include exceptions - rename aspnetcore.components.update_parameters.duration to aspnetcore.components.update_parameters and include exceptions - rename aspnetcore.components.rendering.batch.duration to aspnetcore.components.render_diff and include exceptions
@lmolkova I pushed changes based on your feedback. The remaining issues are
I will discuss it with @javiercn and come to some conclusion. |
Blazor metrics
new meter
Microsoft.AspNetCore.Components
aspnetcore.components.navigation
- Total number of route changes.aspnetcore.components.event_handler
- Duration of processing browser event including business logic.new meter
Microsoft.AspNetCore.Components.Lifecycle
aspnetcore.components.update_parameters
- Duration of processing component parameters including business logic.aspnetcore.components.render_batch
- Duration of rendering batch including browser round-trip.meter
Microsoft.AspNetCore.Components.Server.Circuits
aspnetcore.components.circuit.active
- Number of active circuits in memory.aspnetcore.components.circuit.connected
- Number of circuits connected to client.aspnetcore.components.circuit.duration
- Duration of circuit lifetime and their total count.Blazor activity tracing
Microsoft.AspNetCore.Components
Microsoft.AspNetCore.Components.CircuitStart
:Circuit {circuitId}
aspnetcore.components.circuit.id
Microsoft.AspNetCore.Components.RouteChange
:Route {route} -> {componentType}
aspnetcore.components.circuit.id
,aspnetcore.components.type
,aspnetcore.components.route
Microsoft.AspNetCore.Components.HandleEvent
:Event {attributeName} -> {componentType}.{methodName}
aspnetcore.components.circuit.id
,aspnetcore.components.type
,aspnetcore.components.method
,aspnetcore.components.attribute.name
,error.type
Feedback
IMeterFactory
to be available in DITODO - Metrics need to be documented at https://learn.microsoft.com/en-us/aspnet/core/log-mon/metrics/built-in
Out of scope
Contributes to #53613
Contributes to #29846
Feedback for #61516