Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hypertrace

Package Overview
Dependencies
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hypertrace - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

13

index.js

@@ -28,2 +28,13 @@ const objectState = new Map()

setParent (parentTracer) {
this.parentObject = !parentTracer
? null
: {
className: parentTracer.className,
id: parentTracer.objectId,
props: { ...parentTracer.props },
ctx: parentTracer.ctx
}
}
trace (...args) {

@@ -91,2 +102,4 @@ const traceFunction = global[traceFunctionSymbol]

trace () { /* noop */ }
setParent () { /* noop */ }
}

@@ -93,0 +106,0 @@

2

package.json
{
"name": "hypertrace",
"version": "1.1.0",
"version": "1.2.0",
"description": "Add tracing and insights to classes. Supports Prometheus/Grafana.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -144,2 +144,8 @@ # hypertrace

#### .setParent([parentTracer])
Sets the parent tracer of this one. This means that subsequent calls to `.trace()` will have the new `parentObject`.
If `parentTracer` is null, then the current parent is removed and subsequent calls to `.trace()` will not have a `parentObject`.
#### .enabled

@@ -146,0 +152,0 @@

@@ -12,2 +12,6 @@ const { createTracer } = require('../../')

callSetParent (parentTracer) {
this.tracer.setParent(parentTracer)
}
getTracerObjectId () {

@@ -14,0 +18,0 @@ return this.tracer.objectId

@@ -545,1 +545,106 @@ const test = require('brittle')

})
test('setParent changes the parent of the object', t => {
t.teardown(teardown)
t.plan(2)
let calls = 0
setTraceFunction(({ object, parentObject }) => {
calls += 1
if (calls === 1) t.alike(parentObject.props, originalProps)
if (calls === 2) t.alike(parentObject.props, secondaryProps)
})
class OriginalParent {
constructor () {
this.tracer = createTracer(this, { props: originalProps })
}
createChild () {
return new Child(this.tracer)
}
}
class SecondaryParent {
constructor () {
this.tracer = createTracer(this, { props: secondaryProps })
}
}
class Child {
constructor (parentTracer) {
this.tracer = createTracer(this, { parent: parentTracer })
}
callTrace () {
this.tracer.trace()
}
}
const originalProps = {
some: 'val'
}
const secondaryProps = {
anther: 'val'
}
const originalParent = new OriginalParent()
const secondaryParent = new SecondaryParent()
const child = originalParent.createChild()
child.callTrace()
child.tracer.setParent(secondaryParent.tracer)
child.callTrace()
})
test('setParent with null, removed the parent', t => {
t.teardown(teardown)
t.plan(2)
let calls = 0
setTraceFunction(({ object, parentObject }) => {
calls += 1
if (calls === 1) t.alike(parentObject.props, someProps)
if (calls === 2) t.absent(parentObject)
})
class Parent {
constructor () {
this.tracer = createTracer(this, { props: someProps })
}
createChild () {
return new Child(this.tracer)
}
}
class Child {
constructor (parentTracer) {
this.tracer = createTracer(this, { parent: parentTracer })
}
callTrace () {
this.tracer.trace()
}
}
const someProps = {
some: 'val'
}
const parent = new Parent()
const child = parent.createChild()
child.callTrace()
child.tracer.setParent()
child.callTrace()
})
test('setParent called when not tracing does not throw', t => {
t.teardown(teardown)
t.plan(1)
const mod1 = new SomeModule()
const mod2 = new SomeModule()
t.execution(() => {
mod2.callSetParent(mod1.tracer)
})
})
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