Class DefaultFormatter

  • All Implemented Interfaces:
    Formatter

    public class DefaultFormatter
    extends java.lang.Object
    implements Formatter
    Default formatting implementation delimits the key with dot, which is the metric key delimiter for StatsD and Graphite, and each name is encoded by replacing dots with underscores.

    So List("actors", "some.package.Actor", "mailbox-size") becomes "actors.some_package_Actor.mailbox-size".

    The delimiter and encoding replacements can be configured. This is the default configuration:

    
     cinnamon.chmetrics.formatter {
        delimiter = "."
        encode = [
          {
            from = "."
            to = "_"
          },
          {
            from = "@"
            to = "_"
          },
          {
            from = ":"
            to = "_"
          },
          {
            from = "/"
            to = "_"
          }
       ]
     }
     
    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultFormatter​(com.typesafe.config.Config config)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String encode​(java.lang.String name)
      Encode name with all configured replacements.
      java.lang.String join​(java.util.List<java.lang.String> names)
      Join names into a single delimited identifier.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DefaultFormatter

        public DefaultFormatter​(com.typesafe.config.Config config)
    • Method Detail

      • encode

        public java.lang.String encode​(java.lang.String name)
        Encode name with all configured replacements.
        Specified by:
        encode in interface Formatter
        Parameters:
        name - single name element within full identifier
        Returns:
        encoded name to be included in full identifier
      • join

        public java.lang.String join​(java.util.List<java.lang.String> names)
        Join names into a single delimited identifier.
        Specified by:
        join in interface Formatter
        Parameters:
        names - the parts of the full identifier to join together
        Returns:
        a single delimited identifier