public HistogramLineIngester(Collection<ChannelHandler> handlers, int port) { this.handlers = new ArrayList<>(handlers); this.port = port; this.connectionsAccepted = Metrics.newCounter(new TaggedMetricName("listeners", "connections.accepted", "port", String.valueOf(port))); this.connectionsIdleClosed = Metrics.newCounter(new TaggedMetricName("listeners", "connections.idle.closed", "port", String.valueOf(port))); }
public TaggedMetricName(String group, String name, Pair<String, String>... tags) { super(group, "", name, null, createMBeanName(group, "", name, tags)); ImmutableMap.Builder<String, String> builder = ImmutableMap.builder(); for (Pair<String, String> tag : tags) { if (tag != null && tag._1 != null && tag._2 != null) { builder.put(tag._1, tag._2); } } this.tags = builder.build(); }
@Override public void processTimer(MetricName name, Timer timer, Void context) throws Exception { MetricName samplingName, rateName; if (name instanceof TaggedMetricName) { TaggedMetricName taggedMetricName = (TaggedMetricName) name; samplingName = new TaggedMetricName( taggedMetricName.getGroup(), taggedMetricName.getName() + ".duration", taggedMetricName.getTags()); rateName = new TaggedMetricName( taggedMetricName.getGroup(), taggedMetricName.getName() + ".rate", taggedMetricName.getTags()); } else { samplingName = new MetricName(name.getGroup(), name.getType(), name.getName() + ".duration"); rateName = new MetricName(name.getGroup(), name.getType(), name.getName() + ".rate"); } writeSummarizable(samplingName, timer); writeSampling(samplingName, timer); writeMetered(rateName, timer); if (clear) timer.clear(); }
public TaggedMetricName(String group, String name, Map<String, String> tags) { this(group, name, makeTags(tags)); }
public TaggedMetricName(String group, String name, Map<String, String> tags) { this(group, name, makeTags(tags)); }
public HistogramLineIngester(Collection<ChannelHandler> handlers, int port) { this.handlers = new ArrayList<>(handlers); this.port = port; this.connectionsAccepted = Metrics.newCounter(new TaggedMetricName("listeners", "connections.accepted", "port", String.valueOf(port))); this.connectionsIdleClosed = Metrics.newCounter(new TaggedMetricName("listeners", "connections.idle.closed", "port", String.valueOf(port))); }
public TaggedMetricName(String group, String name, String... tagAndValues) { this(group, name, makeTags(tagAndValues)); }
public TaggedMetricName(String group, String name, Pair<String, String>... tags) { super(group, "", name, null, createMBeanName(group, "", name, tags)); ImmutableMap.Builder<String, String> builder = ImmutableMap.builder(); for (Pair<String, String> tag : tags) { if (tag != null && tag._1 != null && tag._2 != null) { builder.put(tag._1, tag._2); } } this.tags = builder.build(); }
private void initMetrics(int port) { this.connectionsAccepted = Metrics.newCounter(new TaggedMetricName("listeners", "connections.accepted", "port", String.valueOf(port))); this.connectionsIdleClosed = Metrics.newCounter(new TaggedMetricName("listeners", "connections.idle.closed", "port", String.valueOf(port))); }
@Override public int hashCode() { int result = super.hashCode(); result = 31 * result + getTags().hashCode(); return result; }
public TaggedMetricName(String group, String name, String... tagAndValues) { this(group, name, makeTags(tagAndValues)); }
private void initMetrics(int port) { this.connectionsAccepted = Metrics.newCounter(new TaggedMetricName("listeners", "connections.accepted", "port", String.valueOf(port))); this.connectionsIdleClosed = Metrics.newCounter(new TaggedMetricName("listeners", "connections.idle.closed", "port", String.valueOf(port))); }
@Override public int hashCode() { int result = super.hashCode(); result = 31 * result + getTags().hashCode(); return result; }
private ChannelInitializer createInitializer(ChannelHandler channelHandler, String strPort) { ChannelHandler idleStateEventHandler = new IdleStateEventHandler( Metrics.newCounter(new TaggedMetricName("listeners", "connections.idle.closed", "port", strPort))); ChannelHandler connectionTracker = new ConnectionTrackingHandler( Metrics.newCounter(new TaggedMetricName("listeners", "connections.accepted", "port", strPort)), Metrics.newCounter(new TaggedMetricName("listeners", "connections.active", "port", strPort))); return new ChannelInitializer<SocketChannel>() { @Override public void initChannel(SocketChannel ch) { ChannelPipeline pipeline = ch.pipeline(); pipeline.addFirst("idlehandler", new IdleStateHandler(listenerIdleConnectionTimeout, 0, 0)); pipeline.addLast("idlestateeventhandler", idleStateEventHandler); pipeline.addLast("connectiontracker", connectionTracker); pipeline.addLast(new PlainTextOrHttpFrameDecoder(channelHandler, pushListenerMaxReceivedLength, pushListenerHttpBufferSize)); } }; }
/** * @return " k1=v1 k2=v2 ..." if metricName is an instance of TaggedMetricName. "" otherwise. */ private String tagsForMetricName(MetricName metricName) { if (metricName instanceof TaggedMetricName) { TaggedMetricName taggedMetricName = (TaggedMetricName) metricName; StringBuilder sb = new StringBuilder(); for (Map.Entry<String, String> entry : taggedMetricName.getTags().entrySet()) { sb.append(" ").append(entry.getKey()).append("=\"").append(entry.getValue()).append("\""); } return sb.toString(); } else { return ""; } }
private ChannelInitializer createInitializer(ChannelHandler channelHandler, String strPort) { ChannelHandler idleStateEventHandler = new IdleStateEventHandler( Metrics.newCounter(new TaggedMetricName("listeners", "connections.idle.closed", "port", strPort))); ChannelHandler connectionTracker = new ConnectionTrackingHandler( Metrics.newCounter(new TaggedMetricName("listeners", "connections.accepted", "port", strPort)), Metrics.newCounter(new TaggedMetricName("listeners", "connections.active", "port", strPort))); return new ChannelInitializer<SocketChannel>() { @Override public void initChannel(SocketChannel ch) { ChannelPipeline pipeline = ch.pipeline(); pipeline.addFirst("idlehandler", new IdleStateHandler(listenerIdleConnectionTimeout, 0, 0)); pipeline.addLast("idlestateeventhandler", idleStateEventHandler); pipeline.addLast("connectiontracker", connectionTracker); pipeline.addLast(new PlainTextOrHttpFrameDecoder(channelHandler, pushListenerMaxReceivedLength, pushListenerHttpBufferSize)); } }; }
tags.putAll(((TaggedMetricName) key).getTags());
public String getString(String key, String defaultValue, @Nullable Function<String, String> converter) { String s = prop.getProperty(key, defaultValue); if (s == null || s.trim().isEmpty()) { reportGauge(0, new MetricName("config", "", key)); } else { reportGauge(1, new TaggedMetricName("config", key, "value", converter == null ? s : converter.apply(s))); } return s; }