Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ Follow the [yabeda-external-http-requests](http://localhost:3000/d/OGd-oEXWz/yab
Finally, after a couple of minutes when data collected you will see the following:
![Monitor external HTTP calls with Grafana](docs/dashboard.png)

## Configuration

Configuration is handled by [anyway_config] gem. With it you can load settings from environment variables (upcased and prefixed with `YABEDA_HTTP_REQUESTS_`), YAML files, and other sources. See [anyway_config] docs for details.

| Config key | Type | Default | Description |
| -----------| ----- | ------- | ------------------------------------------- |
| `buckets` | array | [] | Set buckets to be used by histogram metrics |

## Development with Docker

Get local development environment working and tests running is very easy with docker-compose:
Expand Down
15 changes: 8 additions & 7 deletions lib/yabeda/http_requests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

require 'yabeda/http_requests/version'
require 'yabeda/http_requests/sniffer'
require 'yabeda/http_requests/config'
require 'yabeda'
require 'sniffer'

Expand All @@ -16,22 +17,22 @@ module HttpRequests
].freeze

Yabeda.configure do
config = ::Yabeda::HttpRequests::Config.new
buckets = config.buckets || LONG_RUNNING_REQUEST_BUCKETS

group :http

counter :request_total,
comment: 'A counter of the total number of external HTTP \
requests.',
comment: 'A counter of the total number of external HTTP requests.',
tags: %i[host port method]
counter :response_total,
comment: 'A counter of the total number of external HTTP \
responses.',
comment: 'A counter of the total number of external HTTP responses.',
tags: %i[host port method status]

histogram :response_duration, tags: %i[host port method status],
unit: :milliseconds,
buckets: LONG_RUNNING_REQUEST_BUCKETS,
comment: "A histogram of the response \
duration (milliseconds)."
buckets: buckets,
comment: 'A histogram of the response duration (milliseconds).'

::Sniffer.config do |c|
c.enabled = true
Expand Down
14 changes: 14 additions & 0 deletions lib/yabeda/http_requests/config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

require 'anyway'

module Yabeda
module HttpRequests
# yabeda-http-requests configuration
class Config < ::Anyway::Config
config_name :yabeda_http_requests

attr_config :buckets
end
end
end
2 changes: 2 additions & 0 deletions yabeda-http_requests.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ['lib']

spec.add_dependency 'anyway_config', '>= 1.3', '< 3.0'

spec.add_runtime_dependency 'sniffer'
spec.add_runtime_dependency 'yabeda'
end