elastic / apm-agent-ios

Apache License 2.0
31 stars 14 forks source link

User Context and Custom Context #230

Open rbarbish opened 1 month ago

rbarbish commented 1 month ago

We are going to be implementing the Elastic APM Agent into our iOS and Android apps but recently discovered User Context and Custom Context was implemented in Android but not in iOS yet per https://www.elastic.co/guide/en/observability/8.12/data-model-metadata.html

Is this effort actively in development to add this to the iOS Agent? Is there an ETA for the release? And it is correct that there is no way to add custom metadata to iOS traces? I also noticed iOS was missing from the "Labels" section on the link.

Thanks, Ross

bryce-b commented 1 month ago

Hi @rbarbish, I don't believe these APIs are provided through the Android agent either; maybe you're looking at the Java agent? The Elastic iOS and Android agent are built on top of OpenTelemetry, which, at this time, doesn't provide a good way to add attributes dynamically to data signals (i.e.: the username which can update throughout app usage). There are currently a number of efforts in OpenTelemetry to solve this problem, and will likely be an API change/addition on the Otel side of things.

rbarbish commented 1 month ago

Thanks @bryce-b for the reply, you're right I mistook the Java agent for the Android agent. Hmm, well the crux of my problem here is that we need to include the user email address (login) or user guid in the metadata of the traces from iOS and Android apps.

I suppose a workaround for this would be to add the "Session ID (guid)" of the Elastic Session (let elasticSessionId = SessionManager.instance.session(false)) to the Intercom User Properties. It looks like this session id does not change between app launches, but would be a decent way if a user submits a support ticket to search for their Elastic traces. Is there any Elastic session id that is unique to a specific launch of the app?

bryce-b commented 1 month ago

We decided to have our session identifiers refresh using a timeout rather than an app background, so there's no way to guarantee a session id will be unique to an app launch.
An alternative that may work for you is to record an event when a user logs in or logs out, and that way you'll be able to use that event to find a session ID and link a session to a user.