55
66var https = require ( 'https' ) ;
77
8- const VERSION = '0.5.5 ' ;
8+ const VERSION = '0.5.6 ' ;
99
1010const STRING = 'string' ; // example: 'some message'
1111const STRING_ARRAY = 'string-array' ; // example: ['one message', 'two message', ...]
@@ -23,6 +23,7 @@ const DD_API_KEY = process.env.DD_API_KEY || '<DATADOG_API_KEY>';
2323const DD_SITE = process . env . DD_SITE || 'datadoghq.com' ;
2424const DD_HTTP_URL = process . env . DD_URL || 'http-intake.logs.' + DD_SITE ;
2525const DD_HTTP_PORT = process . env . DD_PORT || 443 ;
26+ const DD_REQUEST_TIMEOUT_MS = 10000 ;
2627const DD_TAGS = process . env . DD_TAGS || '' ; // Replace '' by your comma-separated list of tags
2728const DD_SERVICE = process . env . DD_SERVICE || 'azure' ;
2829const DD_SOURCE = process . env . DD_SOURCE || 'azure' ;
@@ -138,7 +139,8 @@ class HTTPClient {
138139 'Content-Type' : 'application/json' ,
139140 'DD-API-KEY' : DD_API_KEY ,
140141 'DD-EVP-ORIGIN' : 'azure'
141- }
142+ } ,
143+ timeout : DD_REQUEST_TIMEOUT_MS
142144 } ;
143145 this . scrubber = new Scrubber ( this . context , SCRUBBER_RULE_CONFIGS ) ;
144146 this . batcher = new Batcher (
@@ -193,6 +195,10 @@ class HTTPClient {
193195 . on ( 'error' , error => {
194196 reject ( error ) ;
195197 } ) ;
198+ req . on ( 'timeout' , ( ) => {
199+ req . destroy ( ) ;
200+ reject ( `request timed out after ${ DD_REQUEST_TIMEOUT_MS } ms` ) ;
201+ } )
196202 req . write ( this . scrubber . scrub ( JSON . stringify ( record ) ) ) ;
197203 req . end ( ) ;
198204 } ) ;
0 commit comments