No release in over a year
Utilities for creating grafana annotations from your ruby application.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 3.2
~> 0.81

Runtime

 Project Readme

GrafanaAnnotations

Gem Version

Add custom annotations to grafana from your ruby application.

Installation

Add this line to your application's Gemfile:

gem 'grafana_annotations', '~> 0.1.1'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install grafana_annotations

Usage

Configuration

GrafanaAnnotations.configure do |c|
  # Logs requests and responses. Optional.
  c.logger Rails.logger

  # Tags for rake tasks instrumentation. Empty by default.
  c.rake_tags [:my_app, :rake]

  # Rake task annotation prefix
  c.rake_text_prefix 'Rake task'

  # URL to your grafana installation.
  c.grafana_base_url ENV.fetch('GRAFANA_URL')

  # Grafana authorization (i.e. `Bearer xxxxx`)
  c.grafana_authorization ENV.fetch('GRAFANA_AUTHZ')
end

Creating annotations

result = GrafanaAnnotations.default_api_client.create(
  time: GrafanaAnnotations::Utils::Time.now_ms, # timestamp in milliseconds (integer), optional
  tags: [:my_app, :my_event],
  text: "Boom!"
)

Creating annotation span

wrap utility function creates an annotation when block starts executing and updates it with end time after.

GrafanaAnnotations.wrap(text: 'something is happening', tags: [:my_app, :something]) do
  do_something()
end

Rake tasks instrumentation

Just require grafana_annotations/rake within your Rakefile and annotation request will be sent for every rake task.

# Rakefile
require 'grafana_annotations/rake'

Development

After checking out the repo, run bin/setup to install dependencies. You can also run bin/console for an interactive prompt that will allow you to experiment.

Deployment

  1. Update changelog and git add it
bump2version patch --allow-dirty
  1. git push && git push --tags
  2. gem build
  3. gem push grafana_annotations-x.x.x.gem