@elastic/ecs-helpers
Advanced tools
Comparing version 0.3.0 to 0.4.0
# @elastic/ecs-helpers Changelog | ||
## v0.4.0 | ||
- Add [ECS Tracing fields](https://www.elastic.co/guide/en/ecs/current/ecs-tracing.html) | ||
to `stringify()` schema. | ||
## v0.3.0 | ||
@@ -4,0 +9,0 @@ |
{ | ||
"name": "@elastic/ecs-helpers", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "ECS loggers helpers", | ||
@@ -23,3 +23,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"fast-json-stringify": "^1.16.2" | ||
"fast-json-stringify": "^2.4.1" | ||
}, | ||
@@ -26,0 +26,0 @@ "devDependencies": { |
@@ -21,2 +21,3 @@ <img align="right" width="auto" height="auto" src="https://www.elastic.co/static-res/images/elastic-logo-200.png"> | ||
### `stringify` | ||
Function that serializes (very quickly!) an ECS-format log record object. | ||
@@ -41,2 +42,8 @@ | ||
Note: This uses [fast-json-stringify](https://github.com/fastify/fast-json-stringify) | ||
for serialization. By design this chooses speed over supporting serialization | ||
of objects with circular references. This generally means that ecs-logging-js | ||
libraries will throw a "Converting circular structure to JSON" exception if an | ||
attempt is made to log an object with circular references. | ||
### `formatHttpRequest` | ||
@@ -43,0 +50,0 @@ Function that enhances an ECS object with http request data. |
@@ -97,2 +97,21 @@ // Licensed to Elasticsearch B.V under one or more agreements. | ||
} | ||
}, | ||
// https://www.elastic.co/guide/en/ecs/current/ecs-tracing.html | ||
trace: { | ||
type: 'object', | ||
properties: { | ||
id: string | ||
} | ||
}, | ||
transaction: { | ||
type: 'object', | ||
properties: { | ||
id: string | ||
} | ||
}, | ||
span: { | ||
type: 'object', | ||
properties: { | ||
id: string | ||
} | ||
} | ||
@@ -99,0 +118,0 @@ }, |
25
test.js
@@ -27,3 +27,3 @@ // Licensed to Elasticsearch B.V under one or more agreements. | ||
test('Stringify should return a valid ecs json', t => { | ||
test('stringify should return a valid ecs json', t => { | ||
const ecs = { | ||
@@ -56,3 +56,3 @@ '@timestamp': new Date().toISOString(), | ||
test.cb('formatHttpRequest and formatHttpResponse should returna valid ecs object', t => { | ||
test.cb('formatHttpRequest and formatHttpResponse should return a valid ecs object', t => { | ||
const server = stoppable(http.createServer(handler)) | ||
@@ -132,1 +132,22 @@ server.listen(0, () => { | ||
}) | ||
test('stringify should emit valid tracing fields', t => { | ||
const before = { | ||
'@timestamp': new Date().toISOString(), | ||
'log.level': 'info', | ||
message: 'hello world', | ||
ecs: { | ||
version: '1.4.0' | ||
}, | ||
trace: { id: 1 }, | ||
transaction: { id: 2 }, | ||
span: { id: 3, extra_fields: 'are dropped' } | ||
} | ||
const after = JSON.parse(stringify(before)) | ||
t.true(validate(after)) | ||
t.deepEqual(after.trace, { id: '1' }, 'trace.id is stringified') | ||
t.deepEqual(after.transaction, { id: '2' }, 'transaction.id is stringified') | ||
t.deepEqual(after.span, { id: '3' }, | ||
'span.id is stringified, extra fields are excluded') | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
24689
348
93
1
+ Addedfast-json-stringify@2.7.13(transitive)
+ Addedrfdc@1.4.1(transitive)
- Removedfast-json-stringify@1.21.0(transitive)
Updatedfast-json-stringify@^2.4.1