|
|
|
@ -12,6 +12,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
|
|
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
|
|
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
|
import org.springframework.core.env.ConfigurableEnvironment;
|
|
|
|
|
|
|
|
|
|
import com.taobao.arthas.agent.attach.ArthasAgent;
|
|
|
|
|
|
|
|
|
@ -25,6 +26,9 @@ import com.taobao.arthas.agent.attach.ArthasAgent;
|
|
|
|
|
public class ArthasConfiguration {
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(ArthasConfiguration.class);
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
ConfigurableEnvironment environment;
|
|
|
|
|
|
|
|
|
|
@ConfigurationProperties(prefix = "arthas")
|
|
|
|
|
@ConditionalOnMissingBean
|
|
|
|
|
@Bean
|
|
|
|
@ -36,7 +40,16 @@ public class ArthasConfiguration {
|
|
|
|
|
@Bean
|
|
|
|
|
public ArthasAgent arthasAgent(@Autowired Map<String, String> arthasConfigMap,
|
|
|
|
|
@Autowired ArthasProperties arthasProperties) throws Throwable {
|
|
|
|
|
arthasConfigMap = StringUtils.removeDashKey(arthasConfigMap);
|
|
|
|
|
arthasConfigMap = StringUtils.removeDashKey(arthasConfigMap);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @see org.springframework.boot.context.ContextIdApplicationContextInitializer#getApplicationId(ConfigurableEnvironment)
|
|
|
|
|
*/
|
|
|
|
|
String appName = environment.getProperty("spring.application.name");
|
|
|
|
|
if (arthasConfigMap.get("appName") == null && appName != null) {
|
|
|
|
|
arthasConfigMap.put("appName", appName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 给配置全加上前缀
|
|
|
|
|
Map<String, String> mapWithPrefix = new HashMap<String, String>(arthasConfigMap.size());
|
|
|
|
|
for (Entry<String, String> entry : arthasConfigMap.entrySet()) {
|
|
|
|
|