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

Replace scriptVersionId with scriptVersion object in worker trace events #1476

Merged
merged 1 commit into from
Dec 11, 2023

Conversation

jp4a50
Copy link
Contributor

@jp4a50 jp4a50 commented Dec 6, 2023

Follow up to #1445.

We have since decided that we want to expose additional fields (provisionally tag and message) associated with the script version. As such, we replace the string scriptVersionId field with a scriptVersion object in the JS API.

The API is not used yet so we don't need to worry about backwards compatibility here.

@jp4a50 jp4a50 requested a review from jasnell December 6, 2023 15:07
@jp4a50 jp4a50 requested review from a team as code owners December 6, 2023 15:07
src/workerd/api/trace.h Outdated Show resolved Hide resolved
@jp4a50 jp4a50 force-pushed the jphillips/script-version branch 2 times, most recently from e59a8f3 to b9f5ecc Compare December 6, 2023 17:58
@@ -45,6 +45,17 @@ class TailEvent final: public ExtendableEvent {
}
};

struct ScriptVersion {
public:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public:

@@ -103,7 +110,7 @@ class TraceItem final: public jsg::Object {
kj::Array<jsg::Ref<TraceException>> exceptions;
kj::Array<jsg::Ref<TraceDiagnosticChannelEvent>> diagnosticChannelEvents;
kj::Maybe<kj::String> scriptName;
jsg::Optional<kj::String> scriptVersionId;
kj::Maybe<kj::Own<workerd::ScriptVersion::Reader>> scriptVersion;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would probably be better here to store kj::Maybe<ScriptVersion> rather than the kj::Own<...>` but consider that non-blocking.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially did that but then realized that I needed to copy the ScriptVersion to implement getScriptVersion, so it seemed easier to just retain the capnp object and pass it to the constructor each time rather than additionally having logic to copy a ScriptVersion.

@@ -71,11 +82,7 @@ class TraceItem final: public jsg::Object {
kj::ArrayPtr<jsg::Ref<TraceException>> getExceptions();
kj::ArrayPtr<jsg::Ref<TraceDiagnosticChannelEvent>> getDiagnosticChannelEvents();
kj::Maybe<kj::StringPtr> getScriptName();
// TODO(someday): we expose this as jsg::Optional for now, since that ensures that the property will
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this still valid?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having looked at the other fields in here I don't actually think using jsg::Optional (such that unpopulated fields manifest as undefined in JS) is actually any more inconsistent than using jsg/kj::Maybe so I don't think it's actually worth changing it in the future, especially since it will lead to a subtle change in behaviour of an existing field.

@@ -0,0 +1,17 @@
# Copyright (c) 2023 Cloudflare, Inc.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason this is hanging out on it's own, and not in worker-interface.capnp?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it can be pulled in as a isolated dependency for other (internal) uses.

@jp4a50 jp4a50 force-pushed the jphillips/script-version branch from b9f5ecc to 762f543 Compare December 11, 2023 13:33
@jp4a50
Copy link
Contributor Author

jp4a50 commented Dec 11, 2023

Last push is rebase only.

@jp4a50 jp4a50 force-pushed the jphillips/script-version branch from 762f543 to 7a68f76 Compare December 11, 2023 13:34
@jp4a50 jp4a50 merged commit 34eff06 into main Dec 11, 2023
11 checks passed
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

Successfully merging this pull request may close these issues.

3 participants