org.springframework.boot.actuate.endpoint.PublicMetrics Java Examples
The following examples show how to use
org.springframework.boot.actuate.endpoint.PublicMetrics.
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: AdminEndPointConfiguration.java From Moss with Apache License 2.0 | 5 votes |
@Bean public MossMetricsEndpoint haloMetricsEndpoint(){ List<PublicMetrics> publicMetrics = new ArrayList<PublicMetrics>(); if (this.publicMetrics != null) { publicMetrics.addAll(this.publicMetrics); } Collections.sort(publicMetrics, AnnotationAwareOrderComparator.INSTANCE); return new MossMetricsEndpoint(publicMetrics); }
Example #2
Source File: MossMetricsEndpoint.java From Moss with Apache License 2.0 | 5 votes |
/** * Create a new {@link org.springframework.boot.actuate.endpoint.MetricsEndpoint} instance. * @param publicMetrics the metrics to expose. The collection will be sorted using the * {@link AnnotationAwareOrderComparator}. */ public MossMetricsEndpoint(Collection<PublicMetrics> publicMetrics) { super("metricsInfo"); Assert.notNull(publicMetrics, "PublicMetrics must not be null"); this.publicMetrics = new ArrayList<PublicMetrics>(publicMetrics); AnnotationAwareOrderComparator.sort(this.publicMetrics); }
Example #3
Source File: SpringBootMetricsCollector.java From client_java with Apache License 2.0 | 5 votes |
@Override public List<MetricFamilySamples> collect() { ArrayList<MetricFamilySamples> samples = new ArrayList<MetricFamilySamples>(); for (PublicMetrics publicMetrics : this.publicMetrics) { for (Metric<?> metric : publicMetrics.metrics()) { String name = Collector.sanitizeMetricName(metric.getName()); double value = metric.getValue().doubleValue(); MetricFamilySamples metricFamilySamples = new MetricFamilySamples( name, Type.GAUGE, name, Collections.singletonList( new MetricFamilySamples.Sample(name, Collections.<String>emptyList(), Collections.<String>emptyList(), value))); samples.add(metricFamilySamples); } } return samples; }
Example #4
Source File: AdminEndPointConfiguration.java From Moss with Apache License 2.0 | 4 votes |
public AdminEndPointConfiguration(ObjectProvider<Collection<PublicMetrics>> publicMetrics) { this.publicMetrics = publicMetrics.getIfAvailable(); }
Example #5
Source File: MossMetricsEndpoint.java From Moss with Apache License 2.0 | 4 votes |
public void registerPublicMetrics(PublicMetrics metrics) { this.publicMetrics.add(metrics); AnnotationAwareOrderComparator.sort(this.publicMetrics); }
Example #6
Source File: MossMetricsEndpoint.java From Moss with Apache License 2.0 | 4 votes |
public void unregisterPublicMetrics(PublicMetrics metrics) { this.publicMetrics.remove(metrics); }
Example #7
Source File: MossMetricsEndpoint.java From Moss with Apache License 2.0 | 4 votes |
@Override public HaloMetricResponse invoke() { HaloMetricResponse haloMetricResponse=new HaloMetricResponse(); Map<String, Object> result = new LinkedHashMap<String, Object>(); List<PublicMetrics> metrics = new ArrayList<PublicMetrics>(this.publicMetrics); for (PublicMetrics publicMetric : metrics) { try { for (Metric<?> metric : publicMetric.metrics()) { if(THREADS.equals(metric.getName())){ haloMetricResponse.setJvmThreadslive(String.valueOf(metric.getValue())); } if(NON_HEAP_Used.equals(metric.getName())){ haloMetricResponse.setJvmMemoryUsedNonHeap(String.valueOf(metric.getValue())); } if(HEAP_USED.equals(metric.getName())){ haloMetricResponse.setJvmMemoryUsedHeap(String.valueOf(metric.getValue())); } if(HEAP_COMMITTED.equals(metric.getName())){ haloMetricResponse.setHeapCommitted(String.valueOf(metric.getValue())); } if(HEAP_INIT.equals(metric.getName())){ haloMetricResponse.setHeapInit(String.valueOf(metric.getValue())); } if(HEAP_MAX.equals(metric.getName())){ haloMetricResponse.setHeapMax(String.valueOf(metric.getValue())); } getGcInfo(haloMetricResponse, metric); if(NONHEAP_COMMITTED.equals(metric.getName())){ haloMetricResponse.setNonheapCommitted(String.valueOf(metric.getValue())); } if(SYSTEMLOAD_AVERAGE.equals(metric.getName())){ haloMetricResponse.setSystemloadAverage(String.valueOf(metric.getValue())); } if(PROCESSORS.equals(metric.getName())){ haloMetricResponse.setProcessors(String.valueOf(metric.getValue())); } } } catch (Exception ex) { // Could not evaluate metrics } } return haloMetricResponse; }
Example #8
Source File: SpringBootMetricsCollector.java From client_java with Apache License 2.0 | 4 votes |
@Autowired public SpringBootMetricsCollector(Collection<PublicMetrics> publicMetrics) { this.publicMetrics = publicMetrics; }
Example #9
Source File: MossMetricsEndpoint.java From Moss with Apache License 2.0 | 2 votes |
/** * Create a new {@link org.springframework.boot.actuate.endpoint.MetricsEndpoint} instance. * @param publicMetrics the metrics to expose */ public MossMetricsEndpoint(PublicMetrics publicMetrics) { this(Collections.singleton(publicMetrics)); }