org.springframework.boot.actuate.metrics.MetricsEndpoint Java Examples
The following examples show how to use
org.springframework.boot.actuate.metrics.MetricsEndpoint.
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: ActuatorCommand.java From ssh-shell-spring-boot with Apache License 2.0 | 6 votes |
/** * Metrics method * * @param name metrics name to display * @param tags tags to filter with * @return metrics */ @ShellMethod(key = "metrics", value = "Display metrics endpoint.") @ShellMethodAvailability("metricsAvailability") public Object metrics( @ShellOption(value = {"-n", "--name"}, help = "Metric name to get", defaultValue = ShellOption.NULL) String name, @ShellOption(value = {"-t", "--tags"}, help = "Tags (key=value, separated by coma)", defaultValue = ShellOption.NULL) String tags ) { if (name != null) { MetricsEndpoint.MetricResponse result = metrics.metric(name, tags != null ? Arrays.asList(tags.split(",") ) : null); if (result == null) { String tagsStr = tags != null ? " and tags: " + tags : ""; throw new IllegalArgumentException("No result for metrics name: " + name + tagsStr); } return result; } return metrics.listNames(); }
Example #2
Source File: ActuatorThreadSummaryDimension.java From sofa-dashboard-client with Apache License 2.0 | 5 votes |
/** * Read thread size from metric response * * @param response metric response * @return thread size */ private int getThreadSize(MetricResponse response) { List<MetricsEndpoint.Sample> measurements = response.getMeasurements(); if (measurements != null && !measurements.isEmpty()) { MetricsEndpoint.Sample defaultSample = measurements.get(0); return defaultSample.getValue().intValue(); } return 0; }
Example #3
Source File: ActuatorMemoryDimension.java From sofa-dashboard-client with Apache License 2.0 | 5 votes |
/** * Read metrics sample size as MB * * @param response metric response from actuator * @return size as MB */ @NonNull private int readSampleSizeAsMB(MetricResponse response) { List<MetricsEndpoint.Sample> measurements = response.getMeasurements(); if (measurements != null && !measurements.isEmpty()) { MetricsEndpoint.Sample defaultSample = measurements.get(0); return convertBitToMB(defaultSample.getValue()); } return 0; }
Example #4
Source File: ActuatorCommand.java From ssh-shell-spring-boot with Apache License 2.0 | 5 votes |
public ActuatorCommand(ApplicationContext applicationContext, Environment environment, SshShellProperties properties, SshShellHelper helper, @Lazy AuditEventsEndpoint audit, @Lazy BeansEndpoint beans, @Lazy ConditionsReportEndpoint conditions, @Lazy ConfigurationPropertiesReportEndpoint configprops, @Lazy EnvironmentEndpoint env, @Lazy HealthEndpoint health, @Lazy HttpTraceEndpoint httptrace, @Lazy InfoEndpoint info, @Lazy LoggersEndpoint loggers, @Lazy MetricsEndpoint metrics, @Lazy MappingsEndpoint mappings, @Lazy ScheduledTasksEndpoint scheduledtasks, @Lazy ShutdownEndpoint shutdown, @Lazy ThreadDumpEndpoint threaddump) { this.applicationContext = applicationContext; this.environment = environment; this.properties = properties; this.helper = helper; this.audit = audit; this.beans = beans; this.conditions = conditions; this.configprops = configprops; this.env = env; this.health = health; this.httptrace = httptrace; this.info = info; this.loggers = loggers; this.metrics = metrics; this.mappings = mappings; this.scheduledtasks = scheduledtasks; this.shutdown = shutdown; this.threaddump = threaddump; }
Example #5
Source File: AppDimensionConfiguration.java From sofa-dashboard-client with Apache License 2.0 | 4 votes |
@Bean @ConditionalOnMissingBean public ActuatorMemoryDimension createMemoryDimension(MetricsEndpoint endpoint) { return new ActuatorMemoryDimension(endpoint); }
Example #6
Source File: AppDimensionConfiguration.java From sofa-dashboard-client with Apache License 2.0 | 4 votes |
@Bean @ConditionalOnMissingBean public ActuatorThreadSummaryDimension createThreadSummaryDimension(MetricsEndpoint endpoint) { return new ActuatorThreadSummaryDimension(endpoint); }
Example #7
Source File: ActuatorThreadSummaryDimension.java From sofa-dashboard-client with Apache License 2.0 | 4 votes |
public ActuatorThreadSummaryDimension(MetricsEndpoint endpoint) { this.endpoint = endpoint; }
Example #8
Source File: ActuatorMemoryDimension.java From sofa-dashboard-client with Apache License 2.0 | 4 votes |
public ActuatorMemoryDimension(MetricsEndpoint endpoint) { this.endpoint = endpoint; Collections.addAll(heapTags, TAG_HEAP); Collections.addAll(noneHeapTags, TAG_NON_HEAP); Collections.addAll(noneHeapMetaSpaceTags, TAG_NON_HEAP, TAG_METASPACE); }
Example #9
Source File: DimensionTestContext.java From sofa-dashboard-client with Apache License 2.0 | 4 votes |
@Bean public ActuatorMemoryDimension createMemoryDimension(MetricsEndpoint endpoint) { return new ActuatorMemoryDimension(endpoint); }
Example #10
Source File: DimensionTestContext.java From sofa-dashboard-client with Apache License 2.0 | 4 votes |
@Bean public ActuatorThreadSummaryDimension createThreadSummaryDimension(MetricsEndpoint endpoint) { return new ActuatorThreadSummaryDimension(endpoint); }
Example #11
Source File: ActuatorCommand.java From ssh-shell-spring-boot with Apache License 2.0 | 4 votes |
/** * @return whether `metrics` command is available */ public Availability metricsAvailability() { return availability("metrics", MetricsEndpoint.class); }
Example #12
Source File: AbstractCommandTest.java From ssh-shell-spring-boot with Apache License 2.0 | 4 votes |
@Test void testMetrics() { assertEquals(metrics.listNames().getNames().size(), ((MetricsEndpoint.ListNamesResponse) cmd.metrics(null, null)).getNames().size()); }
Example #13
Source File: AbstractCommandTest.java From ssh-shell-spring-boot with Apache License 2.0 | 4 votes |
@Test void testMetricsName() { assertEquals(metrics.metric("jvm.memory.max", null).getName(), ((MetricsEndpoint.MetricResponse) cmd.metrics("jvm.memory.max", null)).getName()); }
Example #14
Source File: AbstractCommandTest.java From ssh-shell-spring-boot with Apache License 2.0 | 4 votes |
@Test void testMetricsTags() { assertEquals(metrics.metric("jvm.memory.max", Collections.singletonList("area:heap")).getName(), ((MetricsEndpoint.MetricResponse) cmd.metrics("jvm.memory.max", "area:heap")).getName()); }
Example #15
Source File: MetricsCommand.java From sshd-shell-spring-boot with Apache License 2.0 | 4 votes |
MetricsCommand(@Value("${sshd.system.command.roles.metrics}") String[] systemRoles, MetricsEndpoint metricsEndpoint) { super(systemRoles); this.metricsEndpoint = metricsEndpoint; }