Socket
Socket
Sign inDemoInstall

@elastic/ecs-helpers

Package Overview
Dependencies
Maintainers
75
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@elastic/ecs-helpers - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

5

CHANGELOG.md
# @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 @@

4

package.json
{
"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 @@ },

@@ -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')
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc