apm-agent-rum-js
apm-agent-rum-js copied to clipboard
apm.setCustomContext() shallow merging behavior
Hi. Per your documentation the behavior when calling apm.setCustomContext(...)
is:
For each call, the properties of the context argument are shallow merged with the context previously given.
For my project this behavior is problematic. Is there any way to replace the existing context each time setCustomContext(...)
is called?
You can workaround with this solution proposed here - https://github.com/elastic/apm-agent-rum-js/issues/1085#issuecomment-933945338
Thanks @vigneshshanmugam However, it looks like apm.config(...)
accepts an object of type AgentConfigOptions
and there is no config
property on that object. I have instead opted to do the following workaround:
apm.setCustomContext({ context: customContext });
This way the context
property of the object is being completely overwritten during each invocation of apm.setCustomContext(...)
Thank you!
Glad you found a workaround, Will update the docs to make it easier for other users. Thanks!