@@ -134,8 +134,8 @@ export class TraceWriter extends common.Service {
134134 this . logger . error (
135135 'TraceWriter#initialize: Unable to acquire the project number' ,
136136 'automatically from the GCP metadata service. Please provide a' ,
137- 'valid project ID as environmental variable GCLOUD_PROJECT, or as ' ,
138- `config.projectId passed to start. Original error: ${ err } ` ) ;
137+ 'valid project ID as environmental variable GCLOUD_PROJECT, or' ,
138+ `as config.projectId passed to start. Original error: ${ err } ` ) ;
139139 cb ( err ) ;
140140 } ) ;
141141
@@ -190,8 +190,9 @@ export class TraceWriter extends common.Service {
190190 if ( err . code !== 'ENOTFOUND' ) {
191191 // We are running on GCP.
192192 this . logger . warn (
193- 'TraceWriter#getHostname: Unable to retrieve GCE hostname' ,
194- `from the GCP metadata service. Original error: ${ err } ` ) ;
193+ 'TraceWriter#getHostname: Encountered an error while' ,
194+ 'retrieving GCE hostname from the GCP metadata service' ,
195+ `(metadata.google.internal): ${ err } ` ) ;
195196 }
196197 cb ( os . hostname ( ) ) ;
197198 } ) ;
@@ -206,8 +207,9 @@ export class TraceWriter extends common.Service {
206207 if ( err . code !== 'ENOTFOUND' ) {
207208 // We are running on GCP.
208209 this . logger . warn (
209- 'TraceWriter#getInstanceId: Unable to retrieve GCE instance ID' ,
210- `from the GCP metadata service. Original error: ${ err } ` ) ;
210+ 'TraceWriter#getInstanceId: Encountered an error while' ,
211+ 'retrieving GCE instance ID from the GCP metadata service' ,
212+ `(metadata.google.internal): ${ err } ` ) ;
211213 }
212214 cb ( ) ;
213215 } ) ;
@@ -328,15 +330,16 @@ export class TraceWriter extends common.Service {
328330 * @param json The stringified json representation of the queued traces.
329331 */
330332 publish ( json : string ) {
331- const uri = `https:// cloudtrace.googleapis.com/v1/projects/ ${
332- this . projectId } /traces`;
333+ const hostname = ' cloudtrace.googleapis.com' ;
334+ const uri = `https:// ${ hostname } /v1/projects/ ${ this . projectId } /traces`;
333335 const options = { method : 'PATCH' , uri, body : json , headers} ;
334336 this . logger . info ( 'TraceWriter#publish: Publishing to ' + uri ) ;
335337 this . request ( options , ( err , body ?, response ?) => {
336- const statusCode = ( response && response . statusCode ) || 'unknown' ;
338+ const statusCode = response && response . statusCode ;
337339 if ( err ) {
338- this . logger . error ( `TraceWriter#publish: Received error status code ${
339- statusCode } . Original error: ${ err } `) ;
340+ this . logger . error ( `TraceWriter#publish: Received error ${
341+ statusCode ? `with status code ${ statusCode } ` :
342+ '' } while publishing traces to ${ hostname } : ${ err } `) ;
340343 } else {
341344 this . logger . info (
342345 `TraceWriter#publish: Published w/ status code: ${ statusCode } ` ) ;
0 commit comments