-
Notifications
You must be signed in to change notification settings - Fork 604
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
logging: support native types #1374
Conversation
@zbjornson - could you take a look and see if this works the way you envisioned? $ npm install --save stephenplusplus/gcloud-node#spp--1352 |
@stephenplusplus will do later today or this weekend, thanks! 😀 |
Kinda confused, because it looks like the existing code was intended to send bona fide proto Timestamps when |
It's probably me who is missing something, so please let me know! What I found was the
So it didn't appear that embedded properties could be authentic Timestamps. Maybe I'm getting my wires crossed and the timestamps are supported in some other way? |
Ah right. Based on https://github.com/GoogleCloudPlatform/gcloud-node/pull/1374/files#diff-d4c994c2d3998577634f0671d459bae5L335, I was hoping that the (Follow-up before that chunk of code is removed: any possibility of using a different proto for LogEntry that adds timestamp_type?) That and the CI failure aside, this seems to be working well so far. |
I don't believe so. I think our hands are tied. @filipjs? |
Correct, json_payload adheres to the JSON spec. |
(Sorry to prolong this discussion in a PR.) Timestamps in the entry itself are nice for querying, in cases like
I'm a bit lost in this code, but under the hood this actually uses the |
I'd agree having timestamps supported in the payload would be nice. Is there somewhere @zbjornson should open a feature request, if this is indeed something you'd consider? And back to the technical part, we do use |
Hey, sorry for the late response.
No, this uses the jsonPayload field, which is the Struct proto mentioned earlier.
We receive JSON and change it to proto. Since timestamp representation is just a string, we wouldn't be able to tell what type the given field should be.
No, jsonPayload is the correct field. But if you put a timestamp as a string inside JSON, that will still work. When reading logs back using the API, you can parse the string back to timestamp, since you know the type of field. |
Exactly. I haven't yet dumped logs into BigQuery, but that would be the other place the type would matter. Not sure if you can easily convert types when doing that. |
I was looking at this bit that is removed in this PR: - timestampValue: {
- seconds: secondsRounded,
- nanos: Math.floor((seconds - secondsRounded) * 1e9)
- } which matches up with the Timestamp proto. It seems like it should be possible to send that timestampValue object and convert back server-side regardless of whether jsonPayload or protoPayload is used? /me doesn't know how the server-side works |
f3ca13e
to
c7d27b1
Compare
@callmehiphop PTAL. |
ping @callmehiphop |
@@ -332,24 +364,20 @@ GrpcService.convertValue_ = function(value) { | |||
convertedValue = { | |||
structValue: GrpcService.objToStruct_(value) | |||
}; | |||
} else if (is.date(value)) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
I think this is safe to merge. // @callmehiphop |
Fixes #1352
When writing a log entry, this will stringify Date, Error, and regex types... or more accurately, anything given will be passed to
String(value)
.Also, this adds a change that will take a raw "LogEntry" from "ListLogEntries()" and convert the verbose protobuf object into a normal JS object. (See
{module:grpc-service#structToObj_}
and{module:grpc-service#decodeValue_}
)