Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

[CSL-1585] Namespace cardano EKG metrics #1464

Merged

Conversation

adinapoli-iohk
Copy link
Contributor

This PR correctly namespace IOHK's metrics by the "cardano" namespace, for which I have added a smart "constructor" inside a new module called Pos.System.Metrics.Constants within core.

Note this PR is not complete as we need to modify timewarp-nt so that registerQueueMetrics can take an optional namespace (will do this in parallel):

https://github.com/serokell/time-warp-nt/blob/40f4235cda65c746c6edc2a3455242d96d7175bf/src/Network/Broadcast/OutboundQueue.hs#L607

Last but not least, now the time-based queues are parametrised by their unit of measures, microseconds in txp case. (maybe one of the devops like @deepfire or @domenkozar could tell us if statsd will choke if non-ASCII chars are passed to it). This is the result so far:

screen shot 2017-08-31 at 12 42 10

@mention-bot
Copy link

@adinapoli-iohk, thanks for your PR! By analyzing the history of the files in this pull request, we identified @neongreen, @pva701 and @gromakovsky to be potential reviewers.

@adinapoli-iohk adinapoli-iohk requested a review from pva701 as a code owner August 31, 2017 10:45
This commit:

* Switch to use a transient non-master revision of timewarp-nt which
  removes the `Node.Util.Monitor` module;

* Adds the `Pos.Util.Monitor` module as part of Cardano;

* Gives better names to the metrics in `setupMonitor` together with
  units of measure;

* Drops `ekg` in favour of `ekg-wai`, to avoid transitive deps on
  snap-server and io-streams.
@adinapoli-iohk
Copy link
Contributor Author

adinapoli-iohk commented Aug 31, 2017

Note This is currently using a non-master, non-upstream revision of timewarp-nt as my outstanding PR needs to be merged first. (also, I need to run pkgs/generate.sh but it's pointless doing it now as we'll need to switch back to a master revision of timewarp-nt anyway).

Now we have namespaced metrics for everything IOHK related, with units of measure:

screen shot 2017-08-31 at 15 53 04

@domenkozar
Copy link
Contributor

I suggest we use ASCII just to be sure - it's quicker than verifying this :)

@adinapoli-iohk
Copy link
Contributor Author

I suggest we use ASCII just to be sure - it's quicker than verifying this :)

Haha, I was sure you guys were going to prefer the safe route 😁 . I think we are fine though.

StatsD spec explicitly says tags can be UTF-8:

https://github.com/b/statsd_spec#metric-types--formats

Th DD agent should support utf-8 as well:

DataDog/datadogpy#152

But if you guys don't feel confident anyway I'm happy to go with ASCII 😀

@domenkozar
Copy link
Contributor

We can either take the risk of figuring out only on next deploy or spend a few minutes taking the safe route :) Both are fine with me though - my experience with python shows that few programmers write code that works well with non-ASCII encodings.

@adinapoli-iohk
Copy link
Contributor Author

We can either take the risk of figuring out only on next deploy or spend a few minutes taking the safe route :)

I won't be the guy responsible for degrading the velocity of the project 😀 Safe route will be! Fix incoming.

@dcoutts
Copy link
Contributor

dcoutts commented Aug 31, 2017

This is currently using a non-master, non-upstream revision of timewarp-nt as my outstanding PR needs to be merged first.

The TW PR is merged, you can update.

Copy link
Contributor

@dcoutts dcoutts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking OK. As discussed, we should keep the bit of code that adds time-warp metrics into the store in time-warp.

{-# LANGUAGE OverloadedStrings #-}
module Pos.System.Metrics.Constants (
withCardanoNamespace
) where
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this spacing in our style guide? :-)

@@ -0,0 +1,13 @@
{-# LANGUAGE OverloadedStrings #-}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This extension (among many others) is enabled by default.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I must have been taken in by flycheck or something 😉

Copy link
Contributor

@dcoutts dcoutts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking fine.

ekgStore' <- setupMonitor
(runProduction . runToProd JsonLogDisabled oq) node' nrEkgStore
let ekgStore' = nrEkgStore
registerMetrics (Just cardanoNamespace) (runProduction . runToProd JsonLogDisabled oq) node' ekgStore'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need ekgStore' any more. It was only there because the old setupMonitor returned a possibly modified store, and no it doesn't, so there's no need to name the result.

{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In infra (and I guess in all other packages) this extension is enabled by default too.

@@ -0,0 +1,47 @@
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find it much better to avoid name shadowing than to suppress warnings. If there are fundamental reasons why it can't be avoided, it should be justified in comments.

import Control.Monad.IO.Class
import Mockable.Class
import qualified Mockable.Metrics as Metrics
import Node
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imports should be qualified or contain explicit import list, according to style-guide.

@adinapoli-iohk adinapoli-iohk changed the title [WIP][CSL-1585] Namespace cardano EKG metrics [CSL-1585] Namespace cardano EKG metrics Sep 1, 2017
@adinapoli-iohk adinapoli-iohk merged commit ee50e1d into master Sep 1, 2017
@adinapoli-iohk adinapoli-iohk deleted the alfredo/csl-1585-correctly-namespace-ekg-metrics branch September 1, 2017 09:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants