Skip to content

Commit 839d657

Browse files
authored
fix: possible "elasticApm.isStarted is not a function" crash (#61)
Fixes: #60
1 parent b6986be commit 839d657

File tree

6 files changed

+18
-3
lines changed

6 files changed

+18
-3
lines changed

loggers/morgan/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# @elastic/ecs-morgan-format Changelog
22

3+
## Unreleased
4+
5+
- Fix "elasticApm.isStarted is not a function" crash on startup.
6+
([#60](https://github.com/elastic/ecs-logging-nodejs/issues/60))
7+
38
## v1.0.0
49

510
- Update to @elastic/ecs-helpers@1.0.0: ecs.version is now "1.6.0",

loggers/morgan/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function ecsFormat (format = morgan.combined) {
4343
}
4444

4545
// If there is a *started* APM agent, then use it.
46-
const apm = elasticApm && elasticApm.isStarted() ? elasticApm : null
46+
const apm = elasticApm && elasticApm.isStarted && elasticApm.isStarted() ? elasticApm : null
4747
let serviceField
4848
let eventField
4949
if (apm) {

loggers/pino/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# @elastic/ecs-pino-format Changelog
22

3+
## Unreleased
4+
5+
- Fix "elasticApm.isStarted is not a function" crash on startup.
6+
([#60](https://github.com/elastic/ecs-logging-nodejs/issues/60))
7+
38
## v1.0.0
49

510
- Update to @elastic/ecs-helpers@1.0.0: ecs.version is now "1.6.0",

loggers/pino/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function createEcsPinoOptions (opts) {
5252
}
5353

5454
// If there is a *started* APM agent, then use it.
55-
const apm = elasticApm && elasticApm.isStarted() ? elasticApm : null
55+
const apm = elasticApm && elasticApm.isStarted && elasticApm.isStarted() ? elasticApm : null
5656

5757
const ecsPinoOptions = {
5858
formatters: {

loggers/winston/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# @elastic/ecs-winston-format Changelog
22

3+
## Unreleased
4+
5+
- Fix "elasticApm.isStarted is not a function" crash on startup.
6+
([#60](https://github.com/elastic/ecs-logging-nodejs/issues/60))
7+
38
## v1.0.0
49

510
- Update to @elastic/ecs-helpers@1.0.0: ecs.version is now "1.6.0",

loggers/winston/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ function ecsTransform (info, opts) {
7979
}
8080

8181
// If there is a *started* APM agent, then use it.
82-
const apm = elasticApm && elasticApm.isStarted() ? elasticApm : null
82+
const apm = elasticApm && elasticApm.isStarted && elasticApm.isStarted() ? elasticApm : null
8383

8484
// istanbul ignore else
8585
if (apm) {

0 commit comments

Comments
 (0)