com.codahale.metrics.graphite.GraphiteSender Java Examples
The following examples show how to use
com.codahale.metrics.graphite.GraphiteSender.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GraphiteSenderProvider.java From graylog-plugin-metrics-reporter with GNU General Public License v3.0 | 6 votes |
@Override public GraphiteSender get() { HostAndPort hostAndPort = configuration.getAddress(); String host = hostAndPort.getHost(); int port = hostAndPort.getPortOrDefault(2003); switch (configuration.getProtocol()) { case PICKLE: return new PickledGraphite( host, port, SocketFactory.getDefault(), configuration.getCharset(), configuration.getPickleBatchSize()); case TCP: return new Graphite(host, port, SocketFactory.getDefault(), configuration.getCharset()); case UDP: return new GraphiteUDP(host, port); default: throw new IllegalArgumentException("Unknown Graphite protocol \"" + configuration.getProtocol() + "\""); } }
Example #2
Source File: GraphiteReporterService.java From styx with Apache License 2.0 | 5 votes |
private GraphiteReporterService(Builder builder) { super(requireNonNull(builder.serviceName)); MetricRegistry registry = requireNonNull(builder.registry); GraphiteSender graphiteSender = requireNonNull(builder.graphiteSender); String prefix = requireNonNull(builder.prefix); this.reportingIntervalMillis = builder.reportingIntervalMillis; this.reporter = GraphiteReporter.forRegistry(registry) .prefixedWith(prefix) .convertRatesTo(SECONDS) .convertDurationsTo(MILLISECONDS) .filter(ALL) .build(graphiteSender); }
Example #3
Source File: GraphiteReporter.java From styx with Apache License 2.0 | 5 votes |
/** * Builds a {@link GraphiteReporter} with the given properties, sending metrics using the * given {@link GraphiteSender}. * * @param graphite a {@link GraphiteSender} * @return a {@link GraphiteReporter} */ public GraphiteReporter build(GraphiteSender graphite) { return new GraphiteReporter(registry, graphite, clock, prefix, rateUnit, durationUnit, filter); }
Example #4
Source File: GraphiteReporter.java From styx with Apache License 2.0 | 5 votes |
private GraphiteReporter(MetricRegistry registry, GraphiteSender graphite, Clock clock, String prefix, TimeUnit rateUnit, TimeUnit durationUnit, MetricFilter filter) { super(registry, "graphite-reporter", filter, rateUnit, durationUnit); this.graphite = graphite; this.clock = clock; this.prefix = prefix; }
Example #5
Source File: MetricsGraphiteReporterModule.java From graylog-plugin-metrics-reporter with GNU General Public License v3.0 | 5 votes |
@Override protected void configure() { bind(GraphiteSender.class).toProvider(GraphiteSenderProvider.class); bind(GraphiteReporter.class).toProvider(GraphiteReporterProvider.class); addConfigBeans(); addInitializer(MetricsGraphiteReporterService.class); }
Example #6
Source File: GraphiteReporterProvider.java From graylog-plugin-metrics-reporter with GNU General Public License v3.0 | 5 votes |
@Inject public GraphiteReporterProvider(MetricsGraphiteReporterConfiguration configuration, GraphiteSender graphiteSender, MetricRegistry metricRegistry) { this.configuration = requireNonNull(configuration); this.graphiteSender = requireNonNull(graphiteSender); this.metricRegistry = requireNonNull(metricRegistry); }
Example #7
Source File: GraphiteSenderProviderTest.java From graylog-plugin-metrics-reporter with GNU General Public License v3.0 | 5 votes |
@Test public void getReturnsGraphite() throws Exception { final MetricsGraphiteReporterConfiguration configuration = new MetricsGraphiteReporterConfiguration() { @Override public GraphiteProtocol getProtocol() { return GraphiteProtocol.TCP; } }; final GraphiteSenderProvider provider = new GraphiteSenderProvider(configuration); final GraphiteSender graphiteSender = provider.get(); assertTrue(graphiteSender instanceof Graphite); assertFalse(graphiteSender.isConnected()); }
Example #8
Source File: GraphiteSenderProviderTest.java From graylog-plugin-metrics-reporter with GNU General Public License v3.0 | 5 votes |
@Test public void getReturnsGraphiteUDP() throws Exception { final MetricsGraphiteReporterConfiguration configuration = new MetricsGraphiteReporterConfiguration() { @Override public GraphiteProtocol getProtocol() { return GraphiteProtocol.UDP; } }; final GraphiteSenderProvider provider = new GraphiteSenderProvider(configuration); final GraphiteSender graphiteSender = provider.get(); assertTrue(graphiteSender instanceof GraphiteUDP); assertFalse(graphiteSender.isConnected()); }
Example #9
Source File: GraphiteSenderProviderTest.java From graylog-plugin-metrics-reporter with GNU General Public License v3.0 | 5 votes |
@Test public void getReturnsGraphitePickledGraphite() throws Exception { final MetricsGraphiteReporterConfiguration configuration = new MetricsGraphiteReporterConfiguration() { @Override public GraphiteProtocol getProtocol() { return GraphiteProtocol.PICKLE; } }; final GraphiteSenderProvider provider = new GraphiteSenderProvider(configuration); final GraphiteSender graphiteSender = provider.get(); assertTrue(graphiteSender instanceof PickledGraphite); assertFalse(graphiteSender.isConnected()); }
Example #10
Source File: GraphiteReporterProviderTest.java From graylog-plugin-metrics-reporter with GNU General Public License v3.0 | 5 votes |
@Test public void get() throws Exception { final MetricsGraphiteReporterConfiguration configuration = new MetricsGraphiteReporterConfiguration(); final GraphiteSender graphiteSender = new GraphiteUDP("127.0.0.1", 12345); final MetricRegistry metricRegistry = new MetricRegistry(); final GraphiteReporterProvider provider = new GraphiteReporterProvider(configuration, graphiteSender, metricRegistry); final GraphiteReporter reporter = provider.get(); assertNotNull(reporter); }
Example #11
Source File: HistoricalMetricManager.java From entrada with GNU General Public License v3.0 | 5 votes |
private void send(GraphiteSender graphite, TreeMap<Long, Metric> metricValues) { // do not send the last FLUSH_TIMESTAMP_WAIT timestamps to prevent duplicate timestamps // being sent to graphite. (only the last will count) and will cause dips in charts int max = metricValues.size() - FLUSH_TIMESTAMP_WAIT; if (max < 1) { // no metrics to send return; } metricValues.entrySet().stream().limit(max).forEach(e -> send(graphite, e.getValue())); }
Example #12
Source File: HistoricalMetricManager.java From entrada with GNU General Public License v3.0 | 5 votes |
private void send(GraphiteSender graphite, Metric m) { try { graphite.send(m.getName(), String.valueOf(m.getValue()), m.getTime()); if (m.getSamples() > 0) { graphite .send(StringUtils.replace(m.getName(), ".median", ".samples"), String.valueOf(m.getSamples()), m.getTime()); } } catch (IOException e) { log.error("Error while sending metric: {}", m, e); } }
Example #13
Source File: PublicApi.java From pay-publicapi with MIT License | 5 votes |
private void initialiseMetrics(PublicApiConfig configuration, Environment environment) { GraphiteSender graphiteUDP = new GraphiteUDP(configuration.getGraphiteHost(), Integer.parseInt(configuration.getGraphitePort())); GraphiteReporter.forRegistry(environment.metrics()) .prefixedWith(SERVICE_METRICS_NODE) .build(graphiteUDP) .start(GRAPHITE_SENDING_PERIOD_SECONDS, TimeUnit.SECONDS); }
Example #14
Source File: GraphiteMetricSender.java From circus-train with Apache License 2.0 | 4 votes |
GraphiteMetricSender(GraphiteSender graphite, Clock clock, String prefix) { this.graphite = graphite; this.clock = clock; this.prefix = prefix; }
Example #15
Source File: GraphiteMetricReporterServiceTest.java From nifi with Apache License 2.0 | 3 votes |
/** * Overrides the actual methods in order to inject the mock {@link #graphiteSenderMock}. * <p> * If this method is called with the test property values, it returns the mock. Otherwise operate * regularly. * * @param host the provided hostname. * @param port the provided port. * @param charset the provided graphite server charset. * @return {@link #graphiteSenderMock} if all params were the constant test params, regular result otherwise. */ @Override protected GraphiteSender createSender(String host, int port, Charset charset) { if (TEST_HOST.equals(host) && TEST_PORT == port && TEST_CHARSET.equals(charset)) { return graphiteSenderMock; } return super.createSender(host, port, charset); }
Example #16
Source File: GraphiteMetricReporterService.java From nifi with Apache License 2.0 | 2 votes |
/** * Create a sender. * * @param host the hostname of the server to connect to. * @param port the port on which the server listens. * @param charset the charset in which the server expects logs. * @return The created sender. */ protected GraphiteSender createSender(String host, int port, Charset charset) { return new Graphite(host, port, SocketFactory.getDefault(), charset); }