Skip to content

Return structured data instead of JSON string for extension fields #4

Description

@Wentao0312

Summary

We suggest improving how the library returns data intended for insertion into extension fields. Currently, the library returns a JSON blob as a string, which introduces unnecessary overhead for consumers.

Problem

At the moment, extension data is returned as a JSON string. To access specific fields (e.g., treatment group for Amazon reporting), consumers must:

  1. Unmarshal the JSON string into a struct/map
  2. Extract the required fields

This adds extra CPU overhead and allocations, especially in high-throughput systems where this operation happens frequently.

Impact

  • Increased marshaling/unmarshaling overhead
  • latency in hot paths
  • Higher CPU and memory usage under load

Expected behavior

The library should return structured data directly, allowing consumers to access fields without additional decoding.

Suggestion

Instead of returning a JSON string, consider returning:

  • a map[string]interface{}
    or
  • a well-defined struct representing the extension schema

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions