Skip to content

logging may send entries in incorrect order #2014

@ofrobots

Description

@ofrobots

Two successive calls to Log.prototype.write should preserve the order of the log entries, as written to the Logging service. I am noticing my log entries showing up out of order.

I think the problem is due to the async behaviour in Log.prototype.decorateEntries_:

Log.prototype.decorateEntries_ = function(entries, callback) {
  var self = this;

  async.map(entries, function(entry, callback) {
    if (!(entry instanceof Entry)) {
      entry = self.entry(entry);
    }

    var decoratedEntry = entry.toJSON();
    decoratedEntry.logName = self.formattedName_;

    self.metadata_.assignDefaultResource(decoratedEntry, function(err, entry) {
      // Ignore errors (the API will speak up if it has an issue).
      callback(null, entry || decoratedEntry);
    });
  }, callback);
};

Two successive calls to the above, within the timer resolution of JavaScript Date.now() (i.e. having the same timestamp), may get written to the network out of order depending on which log entry gets called back first from assignDefaultResource.

Metadata

Metadata

Assignees

Labels

api: loggingIssues related to the Cloud Logging API.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions