cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

This product reached the end of support date on March 31, 2021.

Single Mobile Application reporting to multiple monitoring backends

roy
Newcomer

Good day. We are wanting to implement Dynatrace on our native iOS and Android mobile applications. We are utilizing a single build for each of our environments (ie. Dev, QA, UAT etc) which means that we want a separate Dynatrace instance for each environment. How do we set up the mobile apps to support multiple Dynatrace endpoints? Ie. if Dev, use this Dynatrace ID, if QA, use this Dynatrace ID. Thank you.

3 REPLIES 3

harp
Dynatrace Pro
Dynatrace Pro

how/when does the mobile App know which environment is to be used? If this is available at application start time you can do a manual agent startup with the desired agent endpoint. Switching in-flight is a bit more tricky as it requires the agent to first completely shut down and then start again with the new endpoint which is not a use case the agent API is designed for... Also until the switch is performed all monitoring data is sent to the previously configured environment.

roy
Newcomer

Hi Patrick. Appreciate your prompt response. The switching is done in-flight. The way the app is designed is the username is prefixed with a value that defines the environment. Obviously this prefix can not be utilized in production. As you described, how possible is it to shut down the agent and start with new agent? Is there some documentation that I can have a look at that will steer me?

harp
Dynatrace Pro
Dynatrace Pro

iOS:


  • in Info.plist set DTXAutoStart to false
  • call startupWithApplicationName:serverURL:allowAnyCert:certificatePath: when the prefix is available to startup the agent with the desired endpoint

this does not require an agent shutdown and relaunch, but it also does not capture any data before the agent is started (so only after user login).

If yo want to capture datat from app start you need to


  • call the startup method at earliest time possible (e.g. on applicationDidFinishLaunching)
  • store the last agent endpoint/set a default one for first launch
  • on user change shutdown the agent with the shutdown() API and restart it again using startupWithApplicationName:serverURL:allowAnyCert:certificatePath: with the new settings (keep in mind to store them to have them available at next app startup for stating the agent with those settings). also shutdown() was only designed to terminate the agent and not for a restart. I does some finalizaion, flushing data etc in a background thread, so it runs some time after it returned. Therfore you need to wait a bit before restarting the agent (I suggest ~3sec).
  • manual instrumentation calls see https://www.dynatrace.com/support/doc/appmon/user-experience-management/mobile-uem/how-to-instrument...

As said I know this is not a perfect solution but the agent is not designed for in-flight endpoint switching. A better approach would be different builds for different environments.