
Security News
Official Go SDK for MCP in Development, Stable Release Expected in August
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
hypertrace
Advanced tools
Add tracing and insights to classes. One of the goals of the module is that there is close to zero overhead when tracing is not enabled. This is achieved by not enabling tracing on objects created before tracing was enabled.
There is support for Prometheus/Grafana through hypertrace-prometheus to get better visual insights into an application's behavior.
$ npm i hypertrace
First create tracers in the classes where insights are needed
some-module.js
import { createTracer } from 'hypertrace'
export default class SomeModule {
constructor () {
this.tracer = createTracer(this, {
props: {
some: 'property'
}
})
}
createChild () {
const child = new Child(this.tracer)
return child
}
}
class Child {
constructor (parentTracer) {
this.tracer = createTracer(this, {
parent: parentTracer,
props: {
another: 'value'
}
})
}
foo (val) {
this.tracer.trace({ val })
}
}
Then add .setTraceFunction()
when traces are needed. It's important that this happens before classes that use Hypertrace are instantiated. Otherwise the tracer will not be enabled for those objects.
app.js
import SomeModule from 'some-module'
import { setTraceFunction } from 'hypertrace'
// Log everytime .trace() is being called.
// Important to call `setTraceFunction` BEFORE objects are instantiated and calls `createTracer`
setTraceFunction(({ object, parentObject, caller, args, customProperties }) => {
console.log({
object,
parentObject,
caller,
args,
customProperties
})
})
const mod = new SomeModule() // Inherently calls `createTracer`
const child = mod.createChild()
child.foo(123)
/*
Prints out:
{
object: {
className: 'Child',
id: 1,
props: {
another: 'value'
}
},
parentObject: {
className: 'SomeModule',
id: 1,
props: {
some: 'property'
}
},
caller: {
functionName: 'foo',
filename: '/Users/.../Some.js',
line: 29,
column: 17,
props: {
val: 123
}
}
}
*/
Create a new Hypertrace instance inside a class. Often used in the constructor
.
If this is called before setTraceFunction
then it will return a cummy class. This means that there will be close to zero overhead when tracing is not needed.
class SomeClass {
constructor() {
this.tracer = createTracer(this)
}
}
Args are optional. They are passed to trace function, but are not used with Prometheus, because there is a limitation with Prometehus that label names cannot be set dynamically.
class SomeClass {
constructor() {
this.tracer = new Hypertrace(this)
}
fn (some, val) {
this.tracer.trace({ some, val })
}
}
A flag that says if the tracer is enabled for this Hypertrace. This is true
if a trace function was set before initiating, and false
if not.
The objectId
of this instance.
The className
of this instance.
The props
passed when this instance was created.
The ctx
of this instance. If createTracer(this)
then ctx = this
.
Set a global trace function that is invoked everytime .trace()
is being called.
Important: Tracing is only enabled for objects created after setTraceFunction
is called.
ctx
, className
, id
, and props
parent
then it contains ctx
, className
, id
, and props
functionName
, filename
, line
, column
, and `propsRemove the global trace function. Calls to createTracer
after this will return a dummy object to reduce runtime overhead.
FAQs
Add tracing and insights to classes. Supports Prometheus/Grafana.
The npm package hypertrace receives a total of 1,976 weekly downloads. As such, hypertrace popularity was classified as popular.
We found that hypertrace demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
Security News
New research reveals that LLMs often fake understanding, passing benchmarks but failing to apply concepts or stay internally consistent.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.