-
Notifications
You must be signed in to change notification settings - Fork 595
Add preview metadata to buffered tail traces #6375
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
base: main
Are you sure you want to change the base?
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 |
|---|---|---|
|
|
@@ -498,11 +498,32 @@ TraceEventInfo TraceEventInfo::clone() const { | |
| return TraceEventInfo(KJ_MAP(item, traces) { return item.clone(); }); | ||
| } | ||
|
|
||
| TracePreview::TracePreview(kj::String id, kj::String slug, kj::String name) | ||
| : id(kj::mv(id)), | ||
| slug(kj::mv(slug)), | ||
| name(kj::mv(name)) {} | ||
|
|
||
| TracePreview::TracePreview(rpc::Trace::Preview::Reader reader) | ||
| : id(kj::str(reader.getId())), | ||
| slug(kj::str(reader.getSlug())), | ||
| name(kj::str(reader.getName())) {} | ||
|
|
||
| void TracePreview::copyTo(rpc::Trace::Preview::Builder builder) const { | ||
| builder.setId(id); | ||
| builder.setSlug(slug); | ||
| builder.setName(name); | ||
| } | ||
|
|
||
| TracePreview TracePreview::clone() const { | ||
| return TracePreview(kj::str(id), kj::str(slug), kj::str(name)); | ||
| } | ||
|
|
||
| TraceEventInfo::TraceItem::TraceItem(kj::Maybe<kj::String> scriptName) | ||
| : scriptName(kj::mv(scriptName)) {} | ||
|
|
||
| TraceEventInfo::TraceItem::TraceItem(rpc::Trace::TraceEventInfo::TraceItem::Reader reader) | ||
| : scriptName(kj::str(reader.getScriptName())) {} | ||
| : scriptName(reader.hasScriptName() ? kj::Maybe<kj::String>(kj::str(reader.getScriptName())) | ||
|
Author
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. Opencode drive by changed this because it thinks the old implementation has a bug... IMO seems suss and I'm going to revert this line but hello @danlapid I just wanted to flag it to you incase opencode smarter than me
Contributor
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 think it's right. The previous code didn't preserve the emptiness of the I think this matters in practice too since the worker may be deployed without a script name in some cases. I suspect the failures you're seeing on the internal build are due to this changing behaviour in cases where script name is empty. It likely results in a trace item having a |
||
| : kj::none) {} | ||
|
|
||
| void TraceEventInfo::TraceItem::copyTo( | ||
| rpc::Trace::TraceEventInfo::TraceItem::Builder builder) const { | ||
|
|
@@ -697,6 +718,7 @@ Trace::Trace(kj::Maybe<kj::String> stableId, | |
| kj::Array<kj::String> scriptTags, | ||
| kj::Maybe<kj::String> entrypoint, | ||
| ExecutionModel executionModel, | ||
| kj::Maybe<tracing::TracePreview> preview, | ||
| kj::Maybe<kj::String> durableObjectId) | ||
| : stableId(kj::mv(stableId)), | ||
| scriptName(kj::mv(scriptName)), | ||
|
|
@@ -705,6 +727,7 @@ Trace::Trace(kj::Maybe<kj::String> stableId, | |
| scriptId(kj::mv(scriptId)), | ||
| scriptTags(kj::mv(scriptTags)), | ||
| entrypoint(kj::mv(entrypoint)), | ||
| preview(kj::mv(preview)), | ||
| durableObjectId(kj::mv(durableObjectId)), | ||
| executionModel(executionModel) {} | ||
| Trace::Trace(rpc::Trace::Reader reader) { | ||
|
|
@@ -764,6 +787,10 @@ void Trace::copyTo(rpc::Trace::Builder builder) const { | |
| builder.setEntrypoint(e); | ||
| } | ||
|
|
||
| KJ_IF_SOME(p, preview) { | ||
| p.copyTo(builder.initPreview()); | ||
| } | ||
|
|
||
| KJ_IF_SOME(id, durableObjectId) { | ||
| builder.setDurableObjectId(id); | ||
| } | ||
|
|
@@ -874,6 +901,10 @@ void Trace::mergeFrom(rpc::Trace::Reader reader, PipelineLogLevel pipelineLogLev | |
| entrypoint = kj::str(reader.getEntrypoint()); | ||
| } | ||
|
|
||
| if (reader.hasPreview()) { | ||
| preview = tracing::TracePreview(reader.getPreview()); | ||
| } | ||
|
|
||
| if (reader.hasDurableObjectId()) { | ||
| durableObjectId = kj::str(reader.getDurableObjectId()); | ||
| } | ||
|
|
||
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 think we should make this a JSG struct instead of a JSG dict. I think dicts are meant to be for when you don't know the keys at compile time. See
getScriptVersionfor inspiration.