Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Conversation

@thomasconner
Copy link
Contributor

Description

This PR adds logging to the SDK.

Changes

  • Log outgoing requests and incoming responses.
  • Log active user activity.
  • Log queries.

@thomasconner thomasconner self-assigned this May 16, 2017
@thomasconner thomasconner requested a review from tejasranade May 16, 2017 18:29
@codecov-io
Copy link

codecov-io commented May 16, 2017

Codecov Report

Merging #126 into master will increase coverage by 0.07%.
The diff coverage is 84.61%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #126      +/-   ##
==========================================
+ Coverage   90.51%   90.58%   +0.07%     
==========================================
  Files          77       77              
  Lines        6461     6521      +60     
  Branches     1041     1043       +2     
==========================================
+ Hits         5848     5907      +59     
- Misses        613      614       +1
Impacted Files Coverage Δ
src/request/src/network.js 92.11% <100%> (ø) ⬆️
src/request/src/rack.js 77.3% <77.77%> (+1.21%) ⬆️
src/request/src/response.js 98.05% <80%> (-0.61%) ⬇️
src/request/src/request.js 91.21% <80%> (+3.1%) ⬆️
src/request/src/middleware/src/storage/index.js 82.87% <83.33%> (+1.18%) ⬆️
src/query.js 93.46% <90.9%> (+0.89%) ⬆️
src/request/src/cache.js 96.56% <92.3%> (-2.06%) ⬇️
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0044c66...4fe3074. Read the comment docs.


toPlainObject() {
return {
id: this.id,
Copy link
Contributor

Choose a reason for hiding this comment

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

@thomasconner Is there any other value to the id outside of logging it here? Do we tie the request ID, for example, through the pipeline that the request goes through?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This id is generated by the SDK and used to match up log statements for requests. Multiple requests might be logged at the same time and without some kind of identifier it would be hard to match log statements that are related. We need to communicate that this is not related to the X-Kinvey-Request-Id header by adding the information to the troubleshooting guide.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the related JIRA ticket.

}
};
};
log.setLevel(log.getLevel());
Copy link
Contributor

Choose a reason for hiding this comment

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

@thomasconner this looks odd. This should be a No-Op if getters and setters do what they're supposed to :)

package.json Outdated
"local-storage": "1.4.2",
"lodash": "4.17.4",
"loglevel": "1.4.1",
"loglevel": "github:thomasconner/loglevel",
Copy link
Contributor

Choose a reason for hiding this comment

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

@thomasconner what were the changes you made to the package? Do you plan to keep your fork updated periodically from the master?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I submitted a PR that was merged into the loglevel master branch. We can use the latest release of loglevel instead of a personally maintained version.

src/query.js Outdated
const json = this.toPlainObject();
data = sift(json.filter, data);

Log.debug('After applying query filter to data', data);
Copy link
Contributor

Choose a reason for hiding this comment

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

@thomasconner Have you considered that this data could be quite large and flood the log? Would it make sense to truncate or just print the count instead, for example?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes we probably should not log the actual data. I think we will just log the length of the data to begin.

@thomasconner thomasconner merged commit 4fe3074 into master Aug 15, 2017
@thomasconner thomasconner deleted the MLIBZ-1802_logs branch August 15, 2017 18:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants