1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * See LICENSE.txt included in this distribution for the specific 9 * language governing permissions and limitations under the License. 10 * 11 * When distributing Covered Code, include this CDDL HEADER in each 12 * file and include the License file at LICENSE.txt. 13 * If applicable, add the following below this CDDL HEADER, with the 14 * fields enclosed by brackets "[]" replaced with your own identifying 15 * information: Portions Copyright [yyyy] [name of copyright owner] 16 * 17 * CDDL HEADER END 18 */ 19 20 /* 21 * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. 22 */ 23 package org.opengrok.indexer.configuration; 24 25 import io.micrometer.statsd.StatsdFlavor; 26 27 /** 28 * Configuration for Statsd metrics emitted by the Indexer via {@link org.opengrok.indexer.util.Statistics}. 29 */ 30 public class StatsdConfig { 31 private int port; 32 private String host; 33 private boolean enabled; 34 private StatsdFlavor flavor; 35 getHost()36 public String getHost() { 37 return host; 38 } 39 setHost(String host)40 public void setHost(String host) { 41 this.host = host; 42 } 43 getPort()44 public int getPort() { 45 return port; 46 } 47 setPort(int port)48 public void setPort(int port) { 49 this.port = port; 50 } 51 getFlavor()52 public StatsdFlavor getFlavor() { 53 return flavor; 54 } 55 setFlavor(StatsdFlavor flavor)56 public void setFlavor(StatsdFlavor flavor) { 57 this.flavor = flavor; 58 } 59 isEnabled()60 public boolean isEnabled() { 61 return port != 0 && host != null && !host.isEmpty() && flavor != null; 62 } 63 64 /** 65 * Gets an instance version suitable for helper documentation by shifting 66 * most default properties slightly. 67 */ getForHelp()68 static StatsdConfig getForHelp() { 69 StatsdConfig res = new StatsdConfig(); 70 res.setHost("foo.bar"); 71 res.setPort(8125); 72 res.setFlavor(StatsdFlavor.ETSY); 73 return res; 74 } 75 } 76