Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understand the measurement metrics in a Shiny app and their links

Tags:

r

shiny

I have a deployed Shiny app similar to this one : https://menoretjl.shinyapps.io/MicroAnalysis/

I want to follow the usage of the app by the users so I use the measurement metrics available in the Shiny dashboard : mainly 'usage' (in Account/Usage) , 'connections' and 'memory usage' (in Application/Metrics).

Below are the three metrics for a day. It's seems that they are unrelated : there have been one single and short connection in 20:00. Or there is much more memory usage, and even more usage (more than one hour of usage for this day !).

Based on these facts, my questions are :

  • I do not really understand what each of these metrics mesure. Especially the usage metrics, or this is the base for billing plans ;

  • I do not really understand the (first logical ?!) links between these three metrics.

Connection

Usage

like image 627
Kumpelka Avatar asked Jan 29 '26 17:01

Kumpelka


1 Answers

This worked for me. You must be connected to the relevant shinyapps.io account in RStudio|Tools|Global Options|Publishing.

# download metrics from shinyapps.io

library(tidyverse)
library(lubridate)

# http://docs.rstudio.com/shinyapps.io/metrics.html#ApplicationMetrics
df <- rsconnect::showMetrics("container_status",
                             c("connect_count", 
                               "connect_procs"),
                             appName="pasture_embed",
                             server="shinyapps.io",
                             from="12w",
                             interval="1m"
                             ) 
df <- df %>%
  magrittr::set_colnames(c("connect_count", "dummy", "connect_procs", "timestamp")) %>%
  mutate(across(everything(), as.numeric))

df1 <- df %>% 
  mutate(date=as_datetime(timestamp)) %>% 
  select(-timestamp) %>% 
  arrange(date) %>% 
  mutate(
    n_count=cumsum(connect_count),
    n_procs=cumsum(connect_procs),
    new_connect=case_when(
      connect_count>lag(connect_count,1) ~ connect_count-lag(connect_count,1),
      TRUE ~ 0),
    n_connect=cumsum(new_connect) # approximate
  ) %>% 
  filter(n_count>0)

df2 <- df1 %>%  
  select(n_connect, date) %>% 
  gather(key="key", value="value", -date)

p2 <- ggplot(df2) +
  labs(title="Cumulative Connections", x="", y="") +
  geom_line(aes(x=date, y=value, colour=key)) +
  facet_wrap(~key)

print(p2)
like image 89
Simon Woodward Avatar answered Jan 31 '26 07:01

Simon Woodward



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!