Java Code Examples for com.yammer.metrics.core.VirtualMachineMetrics#getInstance()
The following examples show how to use
com.yammer.metrics.core.VirtualMachineMetrics#getInstance() .
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: TestMetricsService.java From localization_nifi with Apache License 2.0 | 6 votes |
@Test public void testGetVirtualMachineMetrics() { final VirtualMachineMetrics virtualMachineMetrics = VirtualMachineMetrics.getInstance(); final MetricsService service = new MetricsService(); final Map<String,String> metrics = service.getMetrics(virtualMachineMetrics); Assert.assertTrue(metrics.containsKey(MetricNames.JVM_UPTIME)); Assert.assertTrue(metrics.containsKey(MetricNames.JVM_HEAP_USED)); Assert.assertTrue(metrics.containsKey(MetricNames.JVM_HEAP_USAGE)); Assert.assertTrue(metrics.containsKey(MetricNames.JVM_NON_HEAP_USAGE)); Assert.assertTrue(metrics.containsKey(MetricNames.JVM_THREAD_STATES_RUNNABLE)); Assert.assertTrue(metrics.containsKey(MetricNames.JVM_THREAD_STATES_BLOCKED)); Assert.assertTrue(metrics.containsKey(MetricNames.JVM_THREAD_STATES_TIMED_WAITING)); Assert.assertTrue(metrics.containsKey(MetricNames.JVM_THREAD_STATES_TERMINATED)); Assert.assertTrue(metrics.containsKey(MetricNames.JVM_THREAD_COUNT)); Assert.assertTrue(metrics.containsKey(MetricNames.JVM_DAEMON_THREAD_COUNT)); Assert.assertTrue(metrics.containsKey(MetricNames.JVM_FILE_DESCRIPTOR_USAGE)); }
Example 2
Source File: TestMetricsService.java From localization_nifi with Apache License 2.0 | 6 votes |
@Test public void testGetVirtualMachineMetrics() { final VirtualMachineMetrics virtualMachineMetrics = VirtualMachineMetrics.getInstance(); final Map<String, Double> metrics = metricsService.getJVMMetrics(virtualMachineMetrics); Assert.assertTrue(metrics.containsKey(MetricNames.JVM_UPTIME)); Assert.assertTrue(metrics.containsKey(MetricNames.JVM_HEAP_USED)); Assert.assertTrue(metrics.containsKey(MetricNames.JVM_HEAP_USAGE)); Assert.assertTrue(metrics.containsKey(MetricNames.JVM_NON_HEAP_USAGE)); Assert.assertTrue(metrics.containsKey(MetricNames.JVM_THREAD_STATES_RUNNABLE)); Assert.assertTrue(metrics.containsKey(MetricNames.JVM_THREAD_STATES_BLOCKED)); Assert.assertTrue(metrics.containsKey(MetricNames.JVM_THREAD_STATES_TIMED_WAITING)); Assert.assertTrue(metrics.containsKey(MetricNames.JVM_THREAD_STATES_TERMINATED)); Assert.assertTrue(metrics.containsKey(MetricNames.JVM_THREAD_COUNT)); Assert.assertTrue(metrics.containsKey(MetricNames.JVM_DAEMON_THREAD_COUNT)); Assert.assertTrue(metrics.containsKey(MetricNames.JVM_FILE_DESCRIPTOR_USAGE)); }
Example 3
Source File: TestDataDogReportingTask.java From localization_nifi with Apache License 2.0 | 6 votes |
private void initContexts() { configurationContext = Mockito.mock(ConfigurationContext.class); context = Mockito.mock(ReportingContext.class); Mockito.when(context.getProperty(DataDogReportingTask.ENVIRONMENT)) .thenReturn(new MockPropertyValue(env, null)); Mockito.when(context.getProperty(DataDogReportingTask.METRICS_PREFIX)) .thenReturn(new MockPropertyValue(prefix, null)); Mockito.when(context.getProperty(DataDogReportingTask.API_KEY)) .thenReturn(new MockPropertyValue("agent", null)); Mockito.when(context.getProperty(DataDogReportingTask.DATADOG_TRANSPORT)) .thenReturn(new MockPropertyValue("DataDog Agent", null)); EventAccess eventAccess = Mockito.mock(EventAccess.class); Mockito.when(eventAccess.getControllerStatus()).thenReturn(status); Mockito.when(context.getEventAccess()).thenReturn(eventAccess); logger = Mockito.mock(Logger.class); initContext = Mockito.mock(ReportingInitializationContext.class); Mockito.when(initContext.getIdentifier()).thenReturn(UUID.randomUUID().toString()); //Mockito.when(initContext.getLogger()).thenReturn(logger); metricsMap = new ConcurrentHashMap<>(); metricRegistry = Mockito.mock(MetricRegistry.class); virtualMachineMetrics = VirtualMachineMetrics.getInstance(); metricsService = Mockito.mock(MetricsService.class); }
Example 4
Source File: TestMetricsService.java From nifi-prometheus-reporter with Apache License 2.0 | 6 votes |
@Test public void testGetVirtualMachineMetrics() { final VirtualMachineMetrics virtualMachineMetrics = VirtualMachineMetrics.getInstance(); final MetricsService service = new MetricsService(); final Map<String, String> metrics = service.getMetrics(virtualMachineMetrics); Assert.assertTrue(metrics.containsKey(MetricNames.JVM_UPTIME)); Assert.assertTrue(metrics.containsKey(MetricNames.JVM_HEAP_USED)); Assert.assertTrue(metrics.containsKey(MetricNames.JVM_HEAP_USAGE)); Assert.assertTrue(metrics.containsKey(MetricNames.JVM_NON_HEAP_USAGE)); Assert.assertTrue(metrics.containsKey(MetricNames.JVM_THREAD_STATES_RUNNABLE)); Assert.assertTrue(metrics.containsKey(MetricNames.JVM_THREAD_STATES_BLOCKED)); Assert.assertTrue(metrics.containsKey(MetricNames.JVM_THREAD_STATES_TIMED_WAITING)); Assert.assertTrue(metrics.containsKey(MetricNames.JVM_THREAD_STATES_TERMINATED)); Assert.assertTrue(metrics.containsKey(MetricNames.JVM_THREAD_COUNT)); Assert.assertTrue(metrics.containsKey(MetricNames.JVM_DAEMON_THREAD_COUNT)); Assert.assertTrue(metrics.containsKey(MetricNames.JVM_FILE_DESCRIPTOR_USAGE)); }
Example 5
Source File: ScriptedReportingTask.java From localization_nifi with Apache License 2.0 | 5 votes |
/** * Performs setup operations when the processor is scheduled to run. This includes evaluating the processor's * properties, as well as reloading the script (from file or the "Script Body" property) * * @param context the context in which to perform the setup operations */ @OnScheduled public void setup(final ConfigurationContext context) { scriptingComponentHelper.setScriptEngineName(context.getProperty(scriptingComponentHelper.SCRIPT_ENGINE).getValue()); scriptingComponentHelper.setScriptPath(context.getProperty(ScriptingComponentUtils.SCRIPT_FILE).evaluateAttributeExpressions().getValue()); scriptingComponentHelper.setScriptBody(context.getProperty(ScriptingComponentUtils.SCRIPT_BODY).getValue()); String modulePath = context.getProperty(ScriptingComponentUtils.MODULES).getValue(); if (!StringUtils.isEmpty(modulePath)) { scriptingComponentHelper.setModules(modulePath.split(",")); } else { scriptingComponentHelper.setModules(new String[0]); } // Create a script engine for each possible task scriptingComponentHelper.setup(1, getLogger()); scriptToRun = scriptingComponentHelper.getScriptBody(); try { String scriptPath = scriptingComponentHelper.getScriptPath(); if (scriptToRun == null && scriptPath != null) { try (final FileInputStream scriptStream = new FileInputStream(scriptPath)) { scriptToRun = IOUtils.toString(scriptStream, Charset.defaultCharset()); } } } catch (IOException ioe) { throw new ProcessException(ioe); } vmMetrics = VirtualMachineMetrics.getInstance(); }
Example 6
Source File: AmbariReportingTask.java From localization_nifi with Apache License 2.0 | 5 votes |
@OnScheduled public void setup(final ConfigurationContext context) throws IOException { final Map<String, ?> config = Collections.emptyMap(); factory = Json.createBuilderFactory(config); client = createClient(); virtualMachineMetrics = VirtualMachineMetrics.getInstance(); previousMetrics = null; }
Example 7
Source File: DataDogReportingTask.java From localization_nifi with Apache License 2.0 | 5 votes |
@OnScheduled public void setup(final ConfigurationContext context) { metricsService = getMetricsService(); ddMetricRegistryBuilder = getMetricRegistryBuilder(); metricRegistry = getMetricRegistry(); metricsMap = getMetricsMap(); metricsPrefix = METRICS_PREFIX.getDefaultValue(); environment = ENVIRONMENT.getDefaultValue(); virtualMachineMetrics = VirtualMachineMetrics.getInstance(); ddMetricRegistryBuilder.setMetricRegistry(metricRegistry) .setTags(metricsService.getAllTagsList()); }