Metrics
DotVVM is instrumented with System.Diagnostics.Metrics, which should be consumable by most observability platforms (i.e. OpenTelemetry, Prometheus exporter). The metrics which we consider important and generally useful:
dotvvm_viewmodel_size_byteshistogram - Size of the returned viewmodel JSON in bytes.- Labels
route=RouteNameandrequest_type=Navigate/SpaNavigate/Command/StaticCommand
- Labels
dotvvm_request_duration_seconds- Time it took to stringify the resulting JSON view model.- Labels
route,request_typeanddothtml_file - You can use ASP.NET Core statistics about request duration, this metric makes it possible to split the measurement by DotVVM route name.
- Labels
dotvvm_viewmodel_serialization_secondshistogram - Time it took to serialize view model to JSON objects.- Labels
routeandrequest_type
- Labels
dotvvm_control_lifecycle_secondshistogram - Time it took to process a request on the specific route- Labels
routeandlifecycle_type=PreInit/Init/Load/PreRender/PreRenderComplete
- Labels
dotvvm_command_invocation_seconds- Time it took to invoke a specific command method. Compared torequest_duration_secondsthis only includes the time spent in the command method, and is labeled by the executed binding (command)- Labels
commandandresult=Ok/Exception/UnhandledException
- Labels
dotvvm_staticcommand_invocation_seconds- Similar tocommand_invocation_seconds, but for staticCommand invocations- Labels
commandandresult=Ok/Exception/UnhandledException
- Labels
dotvvm_viewmodel_validation_errors_totalhistogram - Number view model validation errors returned to the client.- Labels
routeandrequest_type
- Labels
dotvvm_uploaded_file_bytes- Total size of user-uploaded filesdotvvm_returned_file_bytes- Total size of returned files. Measured when the file is returned, not when downloaded by the client
If you are using Server-side viewmodel cache you might be also interested in the related metrics in order to measure if/how is the cache helping:
dotvvm_viewmodel_cache_hit_totalcounter - number of cache hitsdotvvm_viewmodel_cache_miss_totalcounter - number of cache misses - on a cache miss, the request fails and client has to retry uploading the entire view model.viewmodel_cache_loaded_bytes_totalcounter - number of bytes loaded from the cache, you may interpret it as an upper bound estimate on the bandwidth saved
The more niche / internal metrics are:
dotvvm_view_compiled_total- number of views compiled (should stay constant at runtime).dotvvm_view_compilation_seconds_total- time spent in view compiler.dotvvm_property_initialized_total- number of DotVVM properties initialized (should be constant at runtime).dotvvm_binding_initialized_total- number of bindings instantiated.dotvvm_binding_compiled_total- number of binding expressions compiled (if it continues growing, it signifies problem with a missing cache).dotvvm_request_rejected_total- number of requests rejected (for security reasons) on the specific route.dotvvm_resource_serve_seconds- time it took to lookup and serve a resource.dotvvm_lazy_csrf_token_created_total- number of lazy CSRF tokens created.
All metrics are listed in the DotvvmMetrics.cs source code file.
Prometheus configuration
If you want to use the prometheus-net library to expose the metrics in prometheus format, we recommend calling the Prometheus.MeterAdapter.StartListening method as soon as possible (at the start of Startup/DotvvmStartup is a good place), and configuring the buckets for histograms.
MeterAdapter.StartListening(new MeterAdapterOptions {
ResolveHistogramBuckets = instrument => {
// prometheus-net does not know which buckets will make sense for each histogram and System.Diagnostics.Metrics API
// does not provide a way to specify it. The ResolveHistogramBuckets function will be called for each exported histogram in to define the buckets.
return DotvvmMetrics.TryGetRecommendedBuckets(instrument) ?? MeterAdapterOptions.DefaultHistogramBuckets;
}
});