Skip to content

Commit 6e0566d

Browse files
authored
feat: add internal/testing-only opts._elasticApm to facilitate APM agent tests (#84)
1 parent bf780cf commit 6e0566d

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

loggers/pino/CHANGELOG.md

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

3+
## v1.2.0
4+
5+
- Add an *internal testing-only* option (`opts._elasticApm`) to pass in the
6+
current loaded "elastic-apm-node" module for use in APM tracing integration.
7+
This option will be used by tests in the APM agent where the current agent
8+
import name is a local path rather than "elastic-apm-node" that this code
9+
normally uses.
10+
311
## v1.1.2
412

513
- Fix a circular-require for code that uses both this package and

loggers/pino/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,13 @@ function createEcsPinoOptions (opts) {
6565
let apm = null
6666
let apmServiceName = null
6767
if (apmIntegration) {
68-
if (!triedElasticApmImport) {
68+
// istanbul ignore if
69+
if (opts && opts._elasticApm) {
70+
// `opts._elasticApm` is an internal/testing-only option to be used
71+
// for testing in the APM agent where the import is a local path
72+
// rather than "elastic-apm-node".
73+
elasticApm = opts._elasticApm
74+
} else if (!triedElasticApmImport) {
6975
triedElasticApmImport = true
7076
// We lazily require this module here instead of at the top-level to
7177
// avoid a possible circular-require if the user code does

loggers/pino/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@elastic/ecs-pino-format",
3-
"version": "1.1.2",
3+
"version": "1.2.0",
44
"description": "A formatter for the pino logger compatible with Elastic Common Schema.",
55
"main": "index.js",
66
"files": [

0 commit comments

Comments
 (0)