Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 153262004F5 for ; Fri, 11 Aug 2017 14:29:36 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 1212616D2F8; Fri, 11 Aug 2017 12:29:36 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 5EC4E16D2FC for ; Fri, 11 Aug 2017 14:29:35 +0200 (CEST) Received: (qmail 79566 invoked by uid 500); 11 Aug 2017 12:29:34 -0000 Mailing-List: contact dev-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@accumulo.apache.org Delivered-To: mailing list dev@accumulo.apache.org Received: (qmail 79544 invoked by uid 99); 11 Aug 2017 12:29:33 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Aug 2017 12:29:33 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id E5110DF97C; Fri, 11 Aug 2017 12:29:31 +0000 (UTC) From: billoley To: dev@accumulo.apache.org Reply-To: dev@accumulo.apache.org References: In-Reply-To: Subject: [GitHub] accumulo pull request #291: ACCUMULO-4693: Add instance-specific ProcessName... Content-Type: text/plain Message-Id: <20170811122931.E5110DF97C@git1-us-west.apache.org> Date: Fri, 11 Aug 2017 12:29:31 +0000 (UTC) archived-at: Fri, 11 Aug 2017 12:29:36 -0000 Github user billoley commented on a diff in the pull request: https://github.com/apache/accumulo/pull/291#discussion_r132674187 --- Diff: server/base/src/main/java/org/apache/accumulo/server/metrics/MetricsSystemHelper.java --- @@ -16,20 +16,65 @@ */ package org.apache.accumulo.server.metrics; +import java.util.HashMap; +import java.util.Map; + import org.apache.hadoop.metrics2.MetricsSystem; import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem; +import org.apache.hadoop.metrics2.source.JvmMetrics; +import org.apache.hadoop.metrics2.source.JvmMetricsInfo; /** * */ public class MetricsSystemHelper { + private static Map serviceNameMap = new HashMap<>(); + private static String processName = "Unknown"; + + static { + serviceNameMap.put("master", "Master"); + serviceNameMap.put("tserver", "TabletServer"); + serviceNameMap.put("monitor", "Monitor"); + serviceNameMap.put("gc", "GarbageCollector"); + serviceNameMap.put("tracer", "Tracer"); + serviceNameMap.put("shell", "Shell"); + } + + public static void configure(String application) { + String serviceName = application; + if (MetricsSystemHelper.serviceNameMap.containsKey(application)) { + serviceName = MetricsSystemHelper.serviceNameMap.get(application); + } + + // a system property containing 'instance' can be used if more than one TabletServer is started on a host + String serviceInstance = ""; + if (serviceName.equals("TabletServer")) { + for (Map.Entry p : System.getProperties().entrySet()) { + if (((String) p.getKey()).contains("instance")) { --- End diff -- This was an attempt to not tie the code to a specifc property. It's probably better to just use the property. I can't just pass all of the properties to the metrics system and defer the decision. I'm creating a specific tag "ProcessName" that is used by the MetricsRegistry and metrics2 sinks. We are using the -Daccumulo.service.instance to deconflict the log file names (this is why the _ is added to the instance) and to correlate a running process to the logs. I'm trying to make it easy to montor the long-running tserver processes by using well-named metrics that also correlate to the running process and the log file with the same instance (1, 2, 3, etc). Since this is only a concern for the tservers, I could grab this property closer to the top of the call chain (TabletServer.main()) if that would be more acceptable. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. ---