[ENC-2031] Add new 'encore:trace' annotation + Other small changes #1022
+3,687
−1,062
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains several changes;
New
//encore:trace
AnnotationAny function can now be annotated with
//encore:trace
and will automatically be picked up as a span in Encore's tracing system, even if it is called outside of the context of a API request, PubSub consumer or test. (i.e. this means your background processes, such as a temporal worker can now be annotated! 🎉 )The annotation supports two options parameters:
name
; by default this is the package name and function name, but if overridden becomes what ever you set this to. This can be a string with no whitespace (likeping_google
) or a quoted string with whitespace (like"Wait for message to match"
).type
: by default this isinternal
, however the following additional types are supported;request_handler
,call
,producer
&consumer
. The only effect of using these types is a change of icon within the trace UI.All request parameters and response data are automatically captured into the trace and the last
error
return type is used to indicate if the span was successful or not.Example Uses
Screenshots
A call made to
systemStartup
from a background thread is seen as a new tracego-routine-4
andwait for message to match
are both marked as traced, and you can see API calls made within them as separate spansAll parameters and response variables are captured, including the error state
The Dash API now caches the last known compile error
This change was requested by @simon-johansson so that when you navigate pages in the dashboard and change between running apps, the UI can show if the app currently has a compile error or not. Previously the behaviour was the UI would show the app running fine as nothing cached the error state or not.
The error is now also aways syntax highlighted (there was a bug where the daemon wasn't running in a process which supported colour, so it defaulted to no colour, even though we know web browsers support color).
Addition of a new JSON schema for the
encore.app
fileThe schema is already live at https://encore.dev/schemas/appfile.schema.json - however now when new apps are created we'll automatically add the
$schema
tag as the first tag, which means editors like IntelliJ, GoLand and VSCode will automatically provide autocompletitions and documentation for theencore.app
file.Model Design for a new Go Trace system
There's also an unused file being committed which includes a model design for a new tracing system which would be compatible with OpenTelemtry that @eandre will pickup and full flush out in future PR's