Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kjin committed Apr 2, 2018
1 parent 7833e8f commit cb9af00
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/trace-writer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,21 +140,19 @@ export class TraceWriter extends common.Service {

this.getHostname((hostname) => {
this.getInstanceId((instanceId) => {
this.defaultLabels = {};
// tslint:disable-next-line:no-any
const labels: {[key: string]: any} = {};
const labels: LabelObject = {};
labels[TraceLabels.AGENT_DATA] =
'node ' + pjson.name + ' v' + pjson.version;
labels[TraceLabels.GCE_HOSTNAME] = hostname;
if (instanceId) {
labels[TraceLabels.GCE_INSTANCE_ID] = instanceId;
labels[TraceLabels.GCE_INSTANCE_ID] = `${instanceId}`;
}
const moduleName = this.config.serviceContext.service || hostname;
labels[TraceLabels.GAE_MODULE_NAME] = moduleName;

const moduleVersion = this.config.serviceContext.version;
if (moduleVersion) {
labels[TraceLabels.GAE_MODULE_VERSION] = moduleVersion;
labels[TraceLabels.GAE_MODULE_VERSION] = `${moduleVersion}`;
const minorVersion = this.config.serviceContext.minorVersion;
if (minorVersion) {
let versionLabel = '';
Expand All @@ -165,11 +163,8 @@ export class TraceWriter extends common.Service {
labels[TraceLabels.GAE_VERSION] = versionLabel;
}
}
// Coerce values to strings.
for (const key of Object.keys(labels)) {
this.defaultLabels[key] = `${labels[key]}`;
}
Object.freeze(this.defaultLabels);
Object.freeze(labels);
this.defaultLabels = labels;
if (--pendingOperations === 0) {
cb();
}
Expand Down

0 comments on commit cb9af00

Please sign in to comment.