-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
53 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
lib/elixir_monitoring_prom_web/controllers/brewery_controller.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
defmodule ElixirMonitoringProm.Metrics do | ||
use Prometheus.Metric | ||
|
||
alias ElixirMonitoringProm.{ZipCode, ZipCodes.ZipCode} | ||
|
||
def setup do | ||
# Our counter for the number of searches against a particular zipcode. | ||
# Given that there is a label 'geohash' each zip code gets its own counter. | ||
Counter.new( | ||
name: :elixir_app_zip_code_search, | ||
help: "Counter for brewery zip code searches", | ||
labels: [:zip_code, :geohash] | ||
) | ||
|
||
# The provided radius will fall into one of the defined buckets | ||
Histogram.new( | ||
name: :elixir_app_radius_search, | ||
buckets: [1, 2, 5, 10, 20, 50], | ||
help: "The radius that people are searching within for breweries" | ||
) | ||
end | ||
|
||
def increment_zip_code_search(zip_code) do | ||
zip_code | ||
|> ElixirMonitoringProm.ZipCodes.get_zip_code_info() | ||
|> case do | ||
%ZipCode{point: %Geo.Point{coordinates: {long, lat}}} -> | ||
geo_hash = Geohash.encode(lat, long) | ||
Counter.inc(name: :elixir_app_zip_code_search, labels: [zip_code, geo_hash]) | ||
|
||
_ -> | ||
:noop | ||
end | ||
end | ||
|
||
def observe_radius_search(radius) do | ||
Histogram.observe([name: :elixir_app_radius_search], String.to_integer(radius)) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters