Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define metrics using Prometheus.unsafeRegister instead of having the metrics-core wrapper #4085

Merged
merged 5 commits into from
Jun 17, 2024
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
1 change: 1 addition & 0 deletions changelog.d/5-internal/federator-metrics
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
federator: Add metrics for garbage collections and unexpected errors that were caught
1 change: 1 addition & 0 deletions changelog.d/5-internal/metrics-core
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
metrics-core: Delete `Data.Metrics` in favour of defining metrics closer to where they are being emitted
8 changes: 0 additions & 8 deletions libs/metrics-core/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,23 @@
# dependencies are added or removed.
{ mkDerivation
, base
, containers
, gitignoreSource
, hashable
, immortal
, imports
, lib
, prometheus-client
, text
, time
, unordered-containers
}:
mkDerivation {
pname = "metrics-core";
version = "0.3.2";
src = gitignoreSource ./.;
libraryHaskellDepends = [
base
containers
hashable
immortal
imports
prometheus-client
text
time
unordered-containers
];
description = "Metrics core";
license = lib.licenses.agpl3Only;
Expand Down
7 changes: 1 addition & 6 deletions libs/metrics-core/metrics-core.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ build-type: Simple

library
exposed-modules:
Data.Metrics
Data.Metrics.AWS
Data.Metrics.GC

Expand Down Expand Up @@ -66,14 +65,10 @@ library
-Wredundant-constraints -Wunused-packages

build-depends:
base >=4.9
, containers
, hashable >=1.2
base >=4.9
, immortal
, imports
, prometheus-client
, text >=0.11
, time
, unordered-containers >=0.2

default-language: GHC2021
295 changes: 0 additions & 295 deletions libs/metrics-core/src/Data/Metrics.hs

This file was deleted.

18 changes: 14 additions & 4 deletions libs/metrics-core/src/Data/Metrics/AWS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,24 @@

module Data.Metrics.AWS (gaugeTokenRemaing) where

import Data.Metrics (Metrics, gaugeSet, path)
import Data.Time
import Imports
import Prometheus qualified as Prom

gaugeTokenRemaing :: Metrics -> Maybe NominalDiffTime -> IO ()
gaugeTokenRemaing m mbRemaining = do
gaugeTokenRemaing :: Maybe NominalDiffTime -> IO ()
gaugeTokenRemaing mbRemaining = do
let t = toSeconds (fromMaybe 0 mbRemaining)
gaugeSet t (path "aws_auth.token_secs_remaining") m
Prom.setGauge awsAuthTokenSecsRemaining t
where
toSeconds :: NominalDiffTime -> Double
toSeconds = fromRational . toRational

{-# NOINLINE awsAuthTokenSecsRemaining #-}
awsAuthTokenSecsRemaining :: Prom.Gauge
awsAuthTokenSecsRemaining =
Prom.unsafeRegister $
Prom.gauge
Prom.Info
{ Prom.metricName = "aws_auth.token_secs_remaining",
Prom.metricHelp = "Number of seconds left before AWS Auth expires"
}
Loading
Loading