Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Axiom- js: Option to flatten data when ingesting #46

Open
prokopec-simon opened this issue Jul 25, 2023 · 3 comments
Open

Axiom- js: Option to flatten data when ingesting #46

prokopec-simon opened this issue Jul 25, 2023 · 3 comments

Comments

@prokopec-simon
Copy link

Hi,
I have a minor issue with Axiom-js. The fact that data ingesting uses basic JSON.stringify to convert data to JSON means it fails in cases where it runs into a circular JSON situation. This situation is not something super rare, exceptions or request logging often contains circular structures.

One way to deal with it is to flatten the JSON before ingesting. Would it be possible to add an option to flatten the data if needed? I don't think it would cause any issue if it flattened it by default, but I would have to check the possible performance change. The best option, to me, seems to be having a flattening option in the IngestOptions next to the timestamp options and the CSV delimiter here.

To replicate the issue:

axiom = new Axiom({
    token: process.env.AXIOM_TOKEN,
    orgId: process.env.AXIOM_ORG_ID,
  });

  async circularJsonLog() {
    const obj = { prop1: 'Test', prop2: null };
    obj.prop2 = obj;

    this.axiom.ingest('logs', obj);
  }

I would be willing to create a PR but I reckon the JSON serialization is on multiple places and discussing it with someone would probably take a lot more time than someone changing it themselves.

Thank you.

@schehata
Copy link
Collaborator

schehata commented Aug 1, 2023

hi @prokopec-simon. sorry for my late reply. The json serialization is in two places, webVitals and logger, I believe we don't need to do that for webVitals. would be happy to review your PR on the logger json serialization.

@prokopec-simon
Copy link
Author

Any chance anyone could have a look at the mentioned PR?

@schehata
Copy link
Collaborator

hi @prokopec-simon , sorry it took so long, I reviewed your change, looks great, I left a comment, we need to make sure the build step works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants