-
Notifications
You must be signed in to change notification settings - Fork 335
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,16 @@ class TailEvent final: public ExtendableEvent { | |
} | ||
}; | ||
|
||
struct ScriptVersion { | ||
explicit ScriptVersion(workerd::ScriptVersion::Reader version); | ||
|
||
jsg::Optional<kj::String> id; | ||
jsg::Optional<kj::String> tag; | ||
jsg::Optional<kj::String> message; | ||
|
||
JSG_STRUCT(id, tag, message); | ||
}; | ||
|
||
class TraceItem final: public jsg::Object { | ||
public: | ||
class FetchEventInfo; | ||
|
@@ -71,11 +81,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 | ||
// not show up when calling JSON.stringify() on the object if it has not been explicitly set. | ||
// At some point, we may want to align the behaviour with getScriptName() which shows up as | ||
// `null` when not explicitly set. | ||
jsg::Optional<kj::StringPtr> getScriptVersionId(); | ||
jsg::Optional<ScriptVersion> getScriptVersion(); | ||
jsg::Optional<kj::StringPtr> getDispatchNamespace(); | ||
jsg::Optional<kj::Array<kj::StringPtr>> getScriptTags(); | ||
kj::StringPtr getOutcome(); | ||
|
@@ -90,7 +96,7 @@ class TraceItem final: public jsg::Object { | |
JSG_LAZY_READONLY_INSTANCE_PROPERTY(exceptions, getExceptions); | ||
JSG_LAZY_READONLY_INSTANCE_PROPERTY(diagnosticsChannelEvents, getDiagnosticChannelEvents); | ||
JSG_LAZY_READONLY_INSTANCE_PROPERTY(scriptName, getScriptName); | ||
JSG_LAZY_READONLY_INSTANCE_PROPERTY(scriptVersionId, getScriptVersionId); | ||
JSG_LAZY_READONLY_INSTANCE_PROPERTY(scriptVersion, getScriptVersion); | ||
JSG_LAZY_READONLY_INSTANCE_PROPERTY(dispatchNamespace, getDispatchNamespace); | ||
JSG_LAZY_READONLY_INSTANCE_PROPERTY(scriptTags, getScriptTags); | ||
JSG_LAZY_READONLY_INSTANCE_PROPERTY(outcome, getOutcome); | ||
|
@@ -103,7 +109,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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would probably be better here to store There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
kj::Maybe<kj::String> dispatchNamespace; | ||
jsg::Optional<kj::Array<kj::String>> scriptTags; | ||
kj::String outcome; | ||
|
@@ -433,6 +439,7 @@ class TraceCustomEventImpl final: public WorkerInterface::CustomEvent { | |
}; | ||
|
||
#define EW_TRACE_ISOLATE_TYPES \ | ||
api::ScriptVersion, \ | ||
api::TailEvent, \ | ||
api::TraceItem, \ | ||
api::TraceItem::AlarmEventInfo, \ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Copyright (c) 2023 Cloudflare, Inc. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
# Licensed under the Apache 2.0 license found in the LICENSE file or at: | ||
# https://opensource.org/licenses/Apache-2.0 | ||
|
||
@0xd3b6bb739ff1b77a; | ||
|
||
using Cxx = import "/capnp/c++.capnp"; | ||
$Cxx.namespace("workerd"); | ||
|
||
struct ScriptVersion { | ||
id @0 :Text; | ||
# An ID that should be used to uniquely identify this version. | ||
tag @1 :Text; | ||
# An optional tag to associate with this version. | ||
message @2 :Text; | ||
# An optional message that can be used to describe this version. | ||
} |
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.
Isn't this still valid?
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.
Having looked at the other fields in here I don't actually think using
jsg::Optional
(such that unpopulated fields manifest asundefined
in JS) is actually any more inconsistent than usingjsg/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.