File tree 6 files changed +25
-4
lines changed
apm-client/http-apm-client
apm-client/http-apm-client/lib
6 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,10 @@ See the <<upgrade-to-v4>> guide.
45
45
[float]
46
46
===== Bug fixes
47
47
48
+ * Fix bug where `NODE_ENV` environment value was not used as a default for
49
+ the <<environment>> config setting. The bug was introduced in v4.2.0.
50
+ ({issues}3807[#3807])
51
+
48
52
* Improve Fastify instrumentation to no longer cause the https://fastify.dev/docs/latest/Reference/Warnings/#FSTDEP017[`FSTDEP017`]
49
53
and https://fastify.dev/docs/latest/Reference/Warnings/#FSTDEP018[`FSTDEP018`]
50
54
deprecation warnings. ({pull}3814[#3814])
Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ See also the "Cloud & Extra Metadata" section below.
56
56
specific framework, use this config option to log its version
57
57
- ` configuredHostname ` - A user-configured hostname, if any, e.g. from the ` ELASTIC_APM_HOSTNAME ` envvar.
58
58
See < https://github.com/elastic/apm/blob/main/specs/agents/metadata.md#hostname > .
59
- - ` environment ` - Environment name (default: ` process.env.NODE_ENV || 'development'` )
59
+ - ` environment ` - Environment name (e.g. 'development', 'production' )
60
60
- ` containerId ` - Docker container id, if not given will be parsed from ` /proc/self/cgroup `
61
61
- ` kubernetesNodeName ` - Kubernetes node name
62
62
- ` kubernetesNamespace ` - Kubernetes namespace
Original file line number Diff line number Diff line change @@ -252,8 +252,6 @@ Client.prototype.config = function (opts) {
252
252
if ( ! this . _conf . serverTimeout && this . _conf . serverTimeout !== 0 )
253
253
this . _conf . serverTimeout = 15000 ;
254
254
if ( ! this . _conf . serverUrl ) this . _conf . serverUrl = 'http://127.0.0.1:8200' ;
255
- if ( ! this . _conf . environment )
256
- this . _conf . environment = process . env . NODE_ENV || 'development' ;
257
255
if ( ! this . _conf . truncateKeywordsAt ) this . _conf . truncateKeywordsAt = 1024 ;
258
256
if ( ! this . _conf . truncateStringsAt ) this . _conf . truncateStringsAt = 1024 ;
259
257
if ( ! this . _conf . truncateCustomKeysAt ) this . _conf . truncateCustomKeysAt = 1024 ;
Original file line number Diff line number Diff line change @@ -188,7 +188,7 @@ const CONFIG_SCHEMA = [
188
188
{
189
189
name : 'environment' ,
190
190
configType : 'string' ,
191
- defaultValue : 'development' ,
191
+ defaultValue : process . env . NODE_ENV || 'development' ,
192
192
envVar : 'ELASTIC_APM_ENVIRONMENT' ,
193
193
} ,
194
194
{
Original file line number Diff line number Diff line change @@ -230,6 +230,7 @@ function validOpts(opts) {
230
230
agentVersion : 'my-agent-version' ,
231
231
serviceName : 'my-service-name' ,
232
232
userAgent : 'my-user-agent' ,
233
+ environment : 'development' ,
233
234
} ,
234
235
opts ,
235
236
) ;
Original file line number Diff line number Diff line change @@ -395,6 +395,24 @@ const testFixtures = [
395
395
) ;
396
396
} ,
397
397
} ,
398
+ {
399
+ name : 'use agent - NODE_ENV envvar sets "environment"' ,
400
+ script : 'fixtures/use-agent.js' ,
401
+ cwd : __dirname ,
402
+ noConvenienceConfig : true ,
403
+ env : {
404
+ NODE_ENV : 'this-is-from-node-env' ,
405
+ TEST_APM_START_OPTIONS : JSON . stringify ( {
406
+ configFile : 'fixtures/use-agent-config.js' ,
407
+ } ) ,
408
+ } ,
409
+ checkScriptResult : ( t , err , stdout ) => {
410
+ t . error ( err , `use-agent.js script succeeded: err=${ err } ` ) ;
411
+ const useAgentLogs = getUseAgentLogs ( stdout ) ;
412
+ const resolvedConfig = JSON . parse ( useAgentLogs [ 2 ] ) ;
413
+ t . equal ( resolvedConfig . environment , 'this-is-from-node-env' ) ;
414
+ } ,
415
+ } ,
398
416
{
399
417
name : 'use agent - should support key/value pairs formats (string & object)' ,
400
418
script : 'fixtures/use-agent.js' ,
You can’t perform that action at this time.
0 commit comments