Skip to content

LocalStorage for the browser and Node.js #41

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

Merged
merged 20 commits into from
Feb 19, 2016
Merged

Conversation

frankebersoll
Copy link
Contributor

This is the (quite naive) implementation of local storage that uses window.localStorage in the browser and the file system in Node; see Issue #24

Configuration

client.config.useLocalStorage();

I can see making the event directory configurable for node - currently, it uses the default .exceptionless in the application's root directory.

Performance

This could be drastically improved by using caching and background processing. We could use a combination of in-memory cache and then write the events to the file system (or local storage, which also uses the file system) in batches, so the ui is blocked for only very short times. In Node, I use synchronous file access which probably could be changed to async.
The only thing being cached now is the list of event names together with their timestamps.

ToDo

  • Test
  • Discuss performance and optimizations
  • Use encoding of timestamp in keys
  • Default path for NodeFileStorage: .express relative to the application root path
  • Customizable path for NodeFileStorage
  • Submit existing events on startup
  • Check invariant culture for coordinates
  • Change node.js user agent

Content type is not enforced, and we use one common storage for heterogeneous data (events and configuration data).
- Added NodeFileStorage
- Added DevDependency: mock-fs (https://github.com/tschaub/mock-fs)
- Modified InMemoryStorage specs to work for both kinds of storage implementations
@@ -18,6 +19,10 @@ defaults.moduleCollector = new NodeModuleCollector();
defaults.requestInfoCollector = new NodeRequestInfoCollector();
defaults.submissionAdapter = new NodeSubmissionAdapter();

Configuration.prototype.useLocalStorage = function() {
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 overrides the Configuration.useLocalStorage stub for Node.

Put code from BrowserStorage and NodeFileStorage into common base class
}

readDate(key: string) {
return Date.now();
Copy link
Member

Choose a reason for hiding this comment

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

could we get the tick count from the key?

let key = `ex-q-${new Date().toJSON()}-${Utils.randomNumber()}`;

@CLAassistant
Copy link

CLA assistant check
All committers have accepted the CLA.

@niemyjski
Copy link
Member

Looking good

frankebersoll added a commit that referenced this pull request Feb 19, 2016
LocalStorage for the browser and Node.js
@frankebersoll frankebersoll merged commit 8a76a9a into master Feb 19, 2016
@niemyjski
Copy link
Member

@frankebersoll could just use exceptionless-node/version as the user agent.

@niemyjski niemyjski deleted the feature/storage branch February 19, 2016 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants