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

fix: add severity to user function error reporting #393

Merged
merged 3 commits into from
Jul 18, 2022

Conversation

pvlugter
Copy link
Member

@pvlugter pvlugter marked this pull request as draft July 12, 2022 02:45
Comment on lines +281 to +287
/** @internal */
enum UserFunctionErrorSeverity {
UNSPECIFIED = 0,
ERROR = 1,
WARNING = 2,
INFO = 3,
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Forgot that the protocol types can only be used in type position. Using an enum compiles in a reference to it, but these types are not packaged in the dist. So mirror the severity enum here for switches. Seems a bit awkward, so maybe the protocol typing and whether that gets included in the package, should be revisited.

sdk/src/kalix.ts Outdated
Comment on lines 620 to 622
case UserFunctionErrorSeverity.INFO:
case UserFunctionErrorSeverity.WARNING:
console.log(msg);
Copy link
Member Author

Choose a reason for hiding this comment

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

There is a console.warn but it's an alias for console.error, which prints to stderr. This puts warnings on stdout with console.log instead, as GCP logging will mark stderr as ERRORs. But maybe having it use console.warn and print to stderr is better anyway?

Copy link
Contributor

Choose a reason for hiding this comment

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

If we don't have any more fine grained output then I think console.warn/stderr makes sense.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, will update to use console.{info,warn,error}. And we can then switch to a proper logging layer later, with structured JSON output. Follow up issue will be https://github.com/lightbend/kalix-proxy/issues/618.

@pvlugter pvlugter marked this pull request as ready for review July 13, 2022 00:35
@pvlugter
Copy link
Member Author

Rebased and ready for review now.

sdk/src/kalix.ts Outdated
Comment on lines 620 to 622
case UserFunctionErrorSeverity.INFO:
case UserFunctionErrorSeverity.WARNING:
console.log(msg);
Copy link
Contributor

Choose a reason for hiding this comment

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

If we don't have any more fine grained output then I think console.warn/stderr makes sense.

break;
}

let msg = `${messageType} reported from Kalix system: ${code} ${message}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

BTW, shouldn't this be JSON anyway?

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, no structured JSON logging anywhere at the moment. Older issue is https://github.com/lightbend/kalix-proxy/issues/618. Could make sense to have our own small logging API, that users can also make use of, from the context or something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kalix-runtime Runtime and SDKs sub-team typescript-sdk
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants