# Spring boot starter for API setup to self-attach

**URL:** <https://discuss.elastic.co/t/spring-boot-starter-for-api-setup-to-self-attach/203333>\
**Category:** APM\
**Tags:** java\
**Created:** [October 13, 2019, 5:36am UTC](https://discuss.elastic.co/t/spring-boot-starter-for-api-setup-to-self-attach/203333 "2019-10-13T05:36:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![surenraju](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/surenraju/32/62606_2.png) [@surenraju](https://discuss.elastic.co/u/surenraju)\
**Post date:** [October 13, 2019, 5:36am UTC](https://discuss.elastic.co/t/spring-boot-starter-for-api-setup-to-self-attach/203333/1 "2019-10-13T05:36:14Z")

</div>

Elastic Search Version: 7.3.1  
APM Server Version: 7.3.1  
APM Client Version: APM Java Agent: 1.x (current)  
APM Agent language and version: Java 1.8

@felixbarny

We are going to use Elastic stack for microservices. Our micro services are spring boot based.

I am writing a spring starter project to automatically attach APM server so that every micro service need not write code to attach apm servers but they just need to include elastic-apm-starter to the microservice.

I am planning to user "**attach(Map\<String, String\> configuration)**" method from ElasticApmAttacher. I am implementing a APMConfiguration bean to load properties from **application.properties** and a provide method which returns configuration as **Map\<String, String\>**

```
    @Configuration
    @ConfigurationProperties(prefix = "elastic.apm")
    public class ElasticAPMConfiguration {
    
         public Map<String, String> getConfiguration() {
           //...    
          }
   }

```

Main idea for doing this is, i want to push the configuration from external configuration management tool.

As per you code, we are loading this properties and passing it to elastic APM once.

> <https://github.com/elastic/apm-agent-java/blob/master/apm-agent-attach/src/main/java/co/elastic/apm/attach/ElasticApmAttacher.java#L102>

How does the elastic apm agent'ss dynamic configuration changes made available for Elastic APM?

For example, as per documentation, **elastic.apm.active** is a dynamic property. If i change **elastic.apm.active** in my **application.properties** how to push this change to APM agent?

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [October 15, 2019, 7:27am UTC](https://discuss.elastic.co/t/spring-boot-starter-for-api-setup-to-self-attach/203333/2 "2019-10-15T07:27:43Z")

</div>

Hi and thanks for the question.

The way to apply changes to dynamic configurations is by updating it's value in one of the configuration sources. Since the `elasticapm.properties` file is irrelevant in your case, you would need to set a new value to the system property (or environment variable). If you can register a listener that will get notified when new configuration options are available, it can programmatically set new values to the system properties, thus apply the new config.

Please note that we recently added [the ability to centrally apply agent configuration through Kibana](https://www.elastic.co/guide/en/kibana/current/agent-configuration.html) (still in beta). Currently, this feature only includes the transaction sample rate, but [we are working on expanding it](https://github.com/elastic/apm/issues/138). The `active` configuration is a prime candidate for that, but it will not be included in 7.5 because we first want to make sure we apply the same semantics to it across our agents. Hopefully, it will be supported as well some time in the near future.

I hope this helps.

---

<div class="post-metadata">

**Author:** ![surenraju](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/surenraju/32/62606_2.png) [@surenraju](https://discuss.elastic.co/u/surenraju)\
**Post date:** [October 15, 2019, 11:58am UTC](https://discuss.elastic.co/t/spring-boot-starter-for-api-setup-to-self-attach/203333/3 "2019-10-15T11:58:08Z")

</div>

@Eyal_Koren Thanks for the suggestions. Approach you proposed seems a good option. Howevere we are looking for native support for elastic itself. Hopefully we will get this in near future.

Also is there any plan to provide a starter project? Probably we can also open source the starter project for elastic APM agent which we are developing.

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [October 15, 2019, 1:05pm UTC](https://discuss.elastic.co/t/spring-boot-starter-for-api-setup-to-self-attach/203333/4 "2019-10-15T13:05:53Z")

</div>

There are no current such plans.  
If you are interested in open-sourcing it, that would be awesome!! The [apm-contrib](https://github.com/elastic/apm-contrib/tree/master/apm-agent-java) repo seems like a proper home for such project.  
Just make sure it is generic enough to be reused for as many use cases as possible, and it is documented properly.  
Thanks!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 5, 2019, 9:05am UTC](https://discuss.elastic.co/t/spring-boot-starter-for-api-setup-to-self-attach/203333/5 "2019-11-05T09:05:57Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
