question

Roy H. avatar image
Roy H. asked ·

Single Mobile Application reporting to multiple monitoring backends

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.

appmon6.5uemandroidios
10 |2000000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 50.0 MiB each and 250.0 MiB total.

Patrick H. avatar image
Patrick H. answered ·

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-an-ios-app/ios-manual-instrumentation/

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.

Share
10 |2000000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 50.0 MiB each and 250.0 MiB total.

Roy H. avatar image
Roy H. answered ·

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?

Share
10 |2000000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 50.0 MiB each and 250.0 MiB total.

Patrick H. avatar image
Patrick H. answered ·

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.

Share
10 |2000000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 50.0 MiB each and 250.0 MiB total.