Skip to content

Update documentation on EventMapper #512

Description

@erawhctim

Are you requesting automatic instrumentation for a framework or library? Please describe.
N/A

Is your feature request related to a problem? Please describe.
I'm on v1.8.0 using the new RUM EventMapper feature - it works great! However, my first implementation didn't work and RUM events were being dropped by the SDK, and it took me a little while to figure out why.

After debugging I noticed the behavior in RumEventMapper that automatically drops the event if its not the same object instance originally used. I assumed I could just freely copy the event object and return a new one, but it appears that the internal mapper expects the same object to be returned.

My EventMapper impl. looked something like this, with .copy() being used:

class MyEventMapper: EventMapper<ResourceEvent> {
    override fun map(event: ResourceEvent): ResourceEvent {
        event.copy(resource = event.resource.copy(url = myNewUrl(...)))
    }
}

Given that .copy() is commonly used on data classes like this, the behavior is a bit misleading.

Describe the solution you'd like
The docs mention that null is used to indicate a dropped event, but the "same instance" requirement isn't listed.
I'd recommend dropping the requirement that custom mappers return the same instance, but if that's not feasible then this seems like a good thing to call out explicitly in the docs.

Describe alternatives you've considered
N/A

Additional context
N/A

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions