private static Callable<SocketAddress> staticStatsDAddressResolution(final String hostname, final int port) throws StatsDClientException { try { return staticAddressResolution(hostname, port); } catch (final Exception e) { throw new StatsDClientException("Failed to lookup StatsD host", e); } } }
logger.fine(String.format("Attempted to send 'completed' counter with tags: %s", Arrays.toString(tagsToCounter))); } catch (StatsDClientException e) { logger.severe(String.format("Runtime exception thrown using the StatsDClient. Exception: %s", e.getMessage())); } finally { if(statsd != null){
private static Callable<SocketAddress> staticStatsDAddressResolution(final String hostname, final int port) throws StatsDClientException { try { return staticAddressResolution(hostname, port); } catch (final Exception e) { throw new StatsDClientException("Failed to lookup StatsD host", e); } } }
/** * Get the client, creating it if needed. This should only be called when the clientMonitor has been acquired. */ private NonBlockingUdpSender client() { if (this.client == null) { synchronized (clientMonitor) { if (this.client == null) { try { this.client = new NonBlockingUdpSender(host, port, STATS_D_ENCODING, NO_OP_HANDLER); } catch (Exception e) { throw new StatsDClientException("Failed to start StatsD client", e); } if (log.isDebugEnabled()) { log.debug("Created STATSD client with host = " + host + "; port = " + port + "; prefix = " + queryId + ".dwquery"); } } } } return this.client; }
/** * Create a new StatsD client communicating with a StatsD instance on the * specified host and port. All messages send via this client will have * their keys prefixed with the specified string. The new client will * attempt to open a connection to the StatsD server immediately upon * instantiation, and may throw an exception if that a connection cannot * be established. Once a client has been instantiated in this way, all * exceptions thrown during subsequent usage are passed to the specified * handler and then consumed, guaranteeing that failures in metrics will * not affect normal code execution. * * @param prefix * the prefix to apply to keys sent via this client (can be null or empty for no prefix) * @param hostname * the host name of the targeted StatsD server * @param port * the port of the targeted StatsD server * @param errorHandler * handler to use when an exception occurs during usage * @throws StatsDClientException * if the client could not be started */ public NonBlockingStatsDClient(String prefix, String hostname, int port, StatsDClientErrorHandler errorHandler) throws StatsDClientException { this.prefix = (prefix == null || prefix.trim().isEmpty()) ? "" : (prefix.trim() + "."); try { this.sender = new NonBlockingUdpSender(hostname, port, STATS_D_ENCODING, errorHandler); } catch (Exception e) { throw new StatsDClientException("Failed to start StatsD client", e); } }
throw new StatsDClientException("Failed to start StatsD client", e);
throw new StatsDClientException("Failed to start StatsD client", e);