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
2 changes: 1 addition & 1 deletion app/dune
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(library
(name prometheus_app)
(public_name prometheus-app)
(libraries prometheus lwt cohttp-lwt asetmap fmt re)
(libraries prometheus lwt cohttp-lwt fmt re)
(modules Prometheus_app)
(wrapped false))

Expand Down
3 changes: 1 addition & 2 deletions prometheus-app.opam
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ homepage: "https://github.com/mirage/prometheus"
doc: "https://mirage.github.io/prometheus/"
bug-reports: "https://github.com/mirage/prometheus/issues"
depends: [
"ocaml" {>= "4.08"}
"ocaml" {>= "4.11.0"}
"dune" {>= "2.3"}
"prometheus" {= version}
"fmt" {>= "0.8.7"}
Expand All @@ -36,7 +36,6 @@ depends: [
"cmdliner"
"alcotest" {with-test}
"alcotest-lwt" {with-test}
"asetmap"
"logs" {>= "0.6.0"}
]
build: [
Expand Down
3 changes: 1 addition & 2 deletions prometheus.opam
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ homepage: "https://github.com/mirage/prometheus"
doc: "https://mirage.github.io/prometheus/"
bug-reports: "https://github.com/mirage/prometheus/issues"
depends: [
"ocaml" {>= "4.01.0"}
"ocaml" {>= "4.11.0"}
"dune" {>= "2.3"}
"asetmap"
"re"
"lwt" {>= "2.5.0"}
]
Expand Down
2 changes: 1 addition & 1 deletion src/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(library
(name prometheus)
(public_name prometheus)
(libraries lwt asetmap re))
(libraries lwt re))
16 changes: 12 additions & 4 deletions src/prometheus.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
open! Asetmap

module type NAME_SPEC = sig
val valid : Re.re
end
Expand Down Expand Up @@ -48,7 +46,17 @@ module LabelSet = struct
type t = string list
let compare (a:t) (b:t) = compare a b
end
module LabelSetMap = Map.Make(LabelSet)
module LabelSetMap = struct
include Map.Make(LabelSet)

let pp ?(sep=Format.pp_print_cut) pp_item f t =
let visit k v first =
if not first then sep f ();
pp_item f (k, v);
false
in
ignore (fold visit t true : bool)
end

module MetricInfo = struct
type t = {
Expand Down Expand Up @@ -189,7 +197,7 @@ end = struct

let labels t label_values =
assert (List.length t.metric.MetricInfo.label_names = List.length label_values);
match LabelSetMap.find label_values t.children with
match LabelSetMap.find_opt label_values t.children with
| Some child -> child
| None ->
let child = Child.create () in
Expand Down
10 changes: 8 additions & 2 deletions src/prometheus.mli
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,16 @@ module MetricInfo : sig
end
(** Metadata about a metric. *)

module LabelSetMap : Asetmap.Map.S with type key = string list
module LabelSetMap : sig
include Map.S with type key = string list
val pp :
?sep:(Format.formatter -> unit -> unit) ->
(Format.formatter -> string list * 'a -> unit) ->
Format.formatter -> 'a t -> unit
end
(** A map indexed by a set of labels. *)

module MetricFamilyMap : Asetmap.Map.S with type key = MetricInfo.t
module MetricFamilyMap : Map.S with type key = MetricInfo.t
(** A map indexed by metric families. *)

module Sample_set : sig
Expand Down