-
Notifications
You must be signed in to change notification settings - Fork 153
Adding logging tag to identify requests #228
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
Conversation
self._backoff.resetToMax(); | ||
} | ||
|
||
resetStream(); | ||
} else { | ||
Firestore.log('Watch.onSnapshot', 'Stream ended, sending error: ', err); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
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.
Looks mostly good. Just a few nits to think about.
src/index.js
Outdated
@@ -518,6 +518,7 @@ follow these steps, YOUR APP MAY BREAK.`); | |||
} | |||
|
|||
let transaction = new Transaction(this, previousTransaction); | |||
let requestTag = transaction.requestTag; |
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.
* @returns {string} A random 5-character wide identifier. | ||
*/ | ||
static requestTag() { | ||
return Firestore.autoId().substr(0, 5); |
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.
src/reference.js
Outdated
|
||
return this._firestore | ||
.request('listCollectionIds', request) | ||
.request('listCollectionIds', request, requestTag) |
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.
src/index.js
Outdated
@@ -1160,7 +1236,7 @@ follow these steps, YOUR APP MAY BREAK.`); | |||
* @private | |||
* @type {Firestore~logFunction} | |||
*/ | |||
Firestore.log = function() {}; | |||
Firestore.log = function(methodName, logMessage, varargs) {}; |
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.
src/index.js
Outdated
@@ -1172,13 +1248,15 @@ Firestore.log = function() {}; | |||
Firestore.setLogFunction = function(logger) { | |||
validate.isFunction('logger', logger); | |||
|
|||
Firestore.log = function(methodName, varargs) { | |||
varargs = Array.prototype.slice.call(arguments, 1); | |||
Firestore.log = function(methodName, requestTag, varargs) { |
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.
src/transaction.js
Outdated
@@ -299,7 +314,7 @@ class Transaction { | |||
} | |||
|
|||
return this._firestore | |||
.request('beginTransaction', request, /* allowRetries= */ true) | |||
.request('beginTransaction', request, this._requestTag, true) |
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.
* @private | ||
* @return {string} A unique client-generated identifier for this transaction. | ||
*/ | ||
get requestTag() { |
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.
* @param {Error} error An error object. | ||
* @return {boolean} Whether the error is permanent. | ||
*/ | ||
isPermanentError(error) { |
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.
Codecov Report
@@ Coverage Diff @@
## master #228 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 13 13
Lines 1837 1846 +9
=====================================
+ Hits 1837 1846 +9
Continue to review full report at Codecov.
|
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.
Thanks for the review. Comments addressed.
src/index.js
Outdated
@@ -518,6 +518,7 @@ follow these steps, YOUR APP MAY BREAK.`); | |||
} | |||
|
|||
let transaction = new Transaction(this, previousTransaction); | |||
let requestTag = transaction.requestTag; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
* @returns {string} A random 5-character wide identifier. | ||
*/ | ||
static requestTag() { | ||
return Firestore.autoId().substr(0, 5); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/index.js
Outdated
@@ -1160,7 +1236,7 @@ follow these steps, YOUR APP MAY BREAK.`); | |||
* @private | |||
* @type {Firestore~logFunction} | |||
*/ | |||
Firestore.log = function() {}; | |||
Firestore.log = function(methodName, logMessage, varargs) {}; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/index.js
Outdated
@@ -1172,13 +1248,15 @@ Firestore.log = function() {}; | |||
Firestore.setLogFunction = function(logger) { | |||
validate.isFunction('logger', logger); | |||
|
|||
Firestore.log = function(methodName, varargs) { | |||
varargs = Array.prototype.slice.call(arguments, 1); | |||
Firestore.log = function(methodName, requestTag, varargs) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/reference.js
Outdated
|
||
return this._firestore | ||
.request('listCollectionIds', request) | ||
.request('listCollectionIds', request, requestTag) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
* @private | ||
* @return {string} A unique client-generated identifier for this transaction. | ||
*/ | ||
get requestTag() { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
* @param {Error} error An error object. | ||
* @return {boolean} Whether the error is permanent. | ||
*/ | ||
isPermanentError(error) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
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.
LGTM with a nit.
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.
Approved based on Hiranya's review, and the fact that his comment was addressed.
For clients that use multiple streams in parallel, it is currently pretty hard to identify what log message correlate to which stream. This PR fixes this and tags the logline with a unique request ID that is used throughout an operations lifetime:
This is overall a pretty ugly implementation. If you can think of a better way, let me know.