All Projects → devOpifex → titan

devOpifex / titan

Licence: AGPL-3.0 license
Prometheus monitoring for shiny applications, plumber APIs, and other R web services

Programming Languages

HTML
75241 projects
r
7636 projects
CSS
56736 projects

Travis build status AppVeyor build status Coveralls test coverage

Docs | Monitoring | Install | Metrics

Prometheus monitoring for shiny applications, plumber APIs, and other R web services.

Acknowledgement

I have put this package together in order to 1) grasp a better understanding of Prometheus metrics and 2) have some direct control over the source code of software I deploy for clients. I have written and re-written this three times before discovering openmetrics, an R package that provides the same functionalities. I have taken much inspiration from it.

Shiny

A simple counter, a value that can only increase, and never decrease.

library(titan)
library(shiny)

ui <- fluidPage(
  h1("Hello!")
)

server <- function(input, output){}

# use titanApp
titanApp(
  ui, server,
  inputs = "inputs",
  visits = "visits",
  concurrent = "concurrent",
  duration = "duration"
)

Plumber

Using titan in plumber.

#* Increment a counter
#* @get /
function() {
  return("Hello titan!")
}

#* Plot a histogram
#* @serializer png
#* @get /plot
function() {
  rand <- rnorm(100)
  hist(rand)
}
library(plumber)

titan::prTitan("file.R", latency = "latency") %>% 
  pr_run()

Ambiorix

Using titan with ambiorix.

library(titan)
library(ambiorix)

# basic counter
c <- Counter$new(
  name = "visits_total", 
  help = "Total visit to the site",
  labels = "path"
)

app <- Ambiorix$new()

app$get("/", function(req, res){
  c$inc(path = "/")
  res$send("Using {titan} with {ambiorix}!")
})

app$get("/about", function(req, res){
  c$inc(path = "/about")
  res$send("About {titan} and {ambiorix}!")
})

app$get("/metrics", function(req, res){
  res$text(renderMetrics())
})

app$start()

Related work

There are other packages out there that will let you serve Prometheus metrics.

  • openmetrics provides support for all metrics as well as authentication, and goes a step further in enforcing OpenMetrics standards.
  • pRometheus Provides support for Gauge and Counter.

Code of Conduct

Please note that the titan project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].