-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(core): Add processing metadata to scope and event #4252
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
Conversation
size-limit report
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No use is (yet) made of this - that will come in future PRs.
What is the end goal (use case)?
(Didn't review tests since CI is failing).
return this._notifyEventProcessors([...getGlobalEventProcessors(), ...this._eventProcessors], event, hint); | ||
} | ||
|
||
/** | ||
* Add data which will be accessible during event processing but won't get sent to Sentry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There shouldn't be docs about the behavior of other places: hard to maintain and easy to have it wrong with new changes.
* Add data which will be accessible during event processing but won't get sent to Sentry | |
* Add data which will be accessible during event processing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the entire point of this field, though - it's the scratch pad, where you can stick anything you want without worrying about having to pluck it (and only it) out, maybe deleting the whole container, etc. We just delete this entire field before the event is sent, and we know we haven't accidentally deleted too much or too little. (That's why it's called processingMetadata - it's data that's only useful for the SDK's event processing pipeline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand, but I think that information should live where the container is removed. Not blocking, your call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disagree - otherwise, how does someone reading the code know it's safe to stick stuff there, without worrying about it getting sent to Sentry? Its entire raison d'etre is to be a local (and local only) datastore, which doesn't actually turn into anything. Kinda like os.tmpdir()
in node.
The fact that we're even having this conversation makes me wonder if there's a better name for it, though. Can you think of a name which would make it clearer what it's there for? localProcessingMetadata
? Maybe it would help to stick a _
at the front? WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renaming sounds good. The names I can think of are probably too long; for example, sdkEventProcessingMetadata
. I rather sdk
over local
since IMO it's more accurate and easier to understand. I don't like eventProcessingMetadata
since it doesn't reference it happening in the SDK. I've been some time thinking about this and can't get a good name (good also including short), so choose what you think fits best. I'm only opinionated against adding _
to the prefix, it's easy to relate it to a private class attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another thing to consider is that the name must be very clear and should not be mixed with debug_meta
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went with sdkProcessingMetadata
. Slightly shorter than sdkEventProcessingMetadata
, but hopefully specific enough to get the point across.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t think this is the approach we should take.
It adds bundle size without a huge amount of value. I’d rather we just use event processors in conjugation with the _extra
field on the scope instead of making a new field.
Actually, once this gets applied just in the example I linked in the PR description (UPDATE: also quoted below), it ends up decreasing bundle size - combining this PR and that change, it ends up replacing 542 characters with 238 characters in If we don't make this change, the data in question can remain in
Thoughts? |
Ok I understand your reasoning. Do you mind clearly outlining each of these examples and what they are setting that needs to be removed? |
Ok I spent my lunch break thinking about this and you have convinced me - we need a hook right before request basically. This would be solved if we had a hooks systems though, but it's unrealistic to depend on that coming to fruition. I would like to choose a better name (though I understand the implicit difficulty of that statement :P) - and maybe discuss with the other sdk teams to see if we it's worthwhile publishing in develop as a "hey not every sdk needs this, but maybe if you find it useful?" thing. The example list would be useful as well for future readers of this PR. |
Sure, here's each, along with the alternative:
Given the above, there's also a hybrid option of just making the internal event schema change and leaving the scope out of it. (I can't guarantee that there might not be an example in the future which needs the scope piece, though.) |
Huh. Interesting. I see how you're getting that from this, but that's a much broader change than this PR was ever intended to make. All I'm really trying to do here is split data which should be deleted away from data which shouldn't be deleted in a simpler way (that deleted data being stuff used by the processing pipeline but not meant for the actual event).
If this is about a hook, I totally agree with you. But given that the point of this is to have a processing pipeline scratchpad, I feel like the current name works. (I'm not wedded to exactly that name, but my point is that some variation on the current name seems right to me.) |
b8be386
to
40b6815
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the change. +1 to have hooks, but I think we can move forward with this.
Should we add the feature of hooks to the backlog? cc @smeubank.
return this._notifyEventProcessors([...getGlobalEventProcessors(), ...this._eventProcessors], event, hint); | ||
} | ||
|
||
/** | ||
* Add data which will be accessible during event processing but won't get sent to Sentry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand, but I think that information should live where the container is removed. Not blocking, your call.
I'm all for hooks, but again, that's totally separate from what this PR is about. If there were a |
Yes, that's why I'm suggesting to move forward with this PR and add the hook system to the backlog as a feature request. |
This pull request has gone three weeks without activity. In another week, I will close it. But! If you comment or otherwise update it, I will reset the clock, and if you label it "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
40b6815
to
7b6cb1c
Compare
… data (#4388) In #4252, a new `sdkProcessingMetadata` field was added to the `Scope` and `Event` interfaces, to provide a place to put data which is needed for in-SDK event processing but shouldn't be sent to Sentry. This refactors one step in that processing... process... to use the new field, eliminating the need to pull the data out of `debug_meta` before the event is sent.
There are various situations where it's helpful to be able to provide data to the event processing pipeline, without that data necessarily being sent to Sentry. (See here for one example where we're already doing this. It also comes up in the as-yet-unmerged dynamic sampling code, and has come up once more in nextjs work I'm doing.)
Rather than piggyback that data in
debug_meta
, and then have to do a "is there still anything in it, or should I delete it" dance after that data is pulled back out, it would simpler if we just had a spot where we could chuck anything we wanted with the knowledge that all of the data there will get filtered out of the final event.This PR introduces such a spot, called
sdkProcessingMetadata
, both on the scope (so that the data can get set at any point prior to the event getting captured) and in the event. No use is (yet) made of this - that will come in future PRs.Note: While there is a public setter for this data on the scope, I'm thinking of this as an internal API, and therefore am not planning to document it for users.