小编Ton*_*ita的帖子

将Spring Boot Actuator指标(和Dropwizard指标)导出到Statsd

我正在尝试将端点上可见的所有指标导出/metricsStatsdMetricWriter.

到目前为止,我有以下配置类:

package com.tonyghita.metricsdriven.service.config;

import com.codahale.metrics.MetricRegistry;
import com.ryantenney.metrics.spring.config.annotation.EnableMetrics;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.actuate.autoconfigure.ExportMetricReader;
import org.springframework.boot.actuate.autoconfigure.ExportMetricWriter;
import org.springframework.boot.actuate.metrics.reader.MetricReader;
import org.springframework.boot.actuate.metrics.reader.MetricRegistryMetricReader;
import org.springframework.boot.actuate.metrics.statsd.StatsdMetricWriter;
import org.springframework.boot.actuate.metrics.writer.MetricWriter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
@EnableMetrics(proxyTargetClass = true)
public class MetricsConfig {
    private static final Logger LOGGER = LoggerFactory.getLogger(MetricsConfig.class);

    @Value("${statsd.host:localhost}")
    private String host = "localhost";

    @Value("${statsd.port:8125}")
    private int port;

    @Autowired
    private MetricRegistry metricRegistry;

    @Bean
    @ExportMetricReader
    public MetricReader metricReader() {
        return new MetricRegistryMetricReader(metricRegistry);
    }

    @Bean
    @ExportMetricWriter
    public MetricWriter metricWriter() …
Run Code Online (Sandbox Code Playgroud)

spring-boot spring-boot-actuator

9
推荐指数
3
解决办法
2万
查看次数

使用Amazon RDS进行部署时,Capistrano超时

我似乎无法让Capistrano与AmazonRDS很好地配合.我已经到处查看有关正确设置的任何信息,但没有找到任何信息.现在,当我cap deploy,这个过程超时.

这是我的deploy.rb:

set :deploy_to, "/opt/bitnami/apps/annarbortshirtcompany.com/cms/" 
set :scm, :git
set :repository,  "ssh://user@ec2-repository.compute-1.amazonaws.com/~/repo/cms.git"
set :deploy_via, :remote_cache

set :user, "user"
ssh_options[:keys] = [File.join(ENV["HOME"], "EC2", "admin.pem")]
ssh_options[:forward_agent] = true
set :branch, "master"
set :use_sudo, true

set :location, "ec2-webserver.compute-1.amazonaws.com"
role :web, location
role :app, location
role :db, "cmsinstance.c7r8frl6npxn.us-east-1.rds.amazonaws.com", :primary => true

# If you are using Passenger mod_rails uncomment this:
namespace :deploy do
  task :start do ; end
  task :stop do ; end
  task :restart, :roles => :app, :except => { :no_release …
Run Code Online (Sandbox Code Playgroud)

capistrano amazon-rds

8
推荐指数
1
解决办法
2511
查看次数

在Spring 4中干掉一个通用的RedisTemplate

我已经读过你可以@Autowired在Spring 4中使用泛型,这很棒.

我有一个抽象RedisService类,我希望有@Autowired一个通用的RestTemplate,如下所示:

public abstract class RedisService<T> implements InitializingBean {

private final String VALUE_KEY_PREFIX;
private final String SET_KEY;

@Autowired
private RedisTemplate<String, T> valueTemplate;

@Autowired
private StringRedisTemplate stringTemplate;

private SetOperations<String, String> setOperations;
private ValueOperations<String, T> valueOperations; 
// and so on...
}
Run Code Online (Sandbox Code Playgroud)

我的Java配置为valueTemplate使他能@Autowired那么看起来像:

@Bean
public RedisTemplate<String, MyTypeA> myTypeARedisTemplate() {
    RedisTemplate<String, MyTypeA> template = new RedisTemplate<>();

    template.setKeySerializer(stringRedisSerializer());
    template.setHashKeySerializer(stringRedisSerializer());
    template.setValueSerializer(new Jackson2JsonRedisSerializer<>(MyTypeA.class));
    template.setConnectionFactory(jedisConnectionFactory());

    return template;
}

@Bean
public RedisTemplate<String, MyTypeB> myTypeBRedisTemplate() {
    RedisTemplate<String, MyTypeB> template …
Run Code Online (Sandbox Code Playgroud)

java generics spring dry redis

6
推荐指数
1
解决办法
2274
查看次数