Skip to content

Commit

Permalink
Rationalize nomenclature
Browse files Browse the repository at this point in the history
  • Loading branch information
szegedi committed Sep 9, 2024
1 parent 81ef859 commit 9b0df51
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions packages/dd-trace/src/profiling/profilers/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,39 +225,39 @@ class EventSerializer {
* Class that sources timeline events through Node.js performance measurement APIs.
*/
class NodeApiEventSource {
constructor (addEventCallback, entryTypes) {
this.addEventCallback = addEventCallback
this._observer = undefined
constructor (eventHandler, entryTypes) {
this.eventHandler = eventHandler
this.observer = undefined
this.entryTypes = entryTypes || Object.keys(decoratorTypes)
}

start () {
// if already started, do nothing
if (this._observer) return
if (this.observer) return

function add (items) {
for (const item of items.getEntries()) {
this.addEventCallback(item)
this.eventHandler(item)
}
}

this._observer = new PerformanceObserver(add.bind(this))
this._observer.observe({ entryTypes: this.entryTypes })
this.observer = new PerformanceObserver(add.bind(this))
this.observer.observe({ entryTypes: this.entryTypes })
}

stop () {
if (this._observer) {
this._observer.disconnect()
this._observer = undefined
if (this.observer) {
this.observer.disconnect()
this.observer = undefined
}
}
}

class DatadogInstrumentationEventSource {
constructor (addEventCallback) {
constructor (eventHandler) {
this.plugins = ['dns_lookup', 'dns_lookupservice', 'dns_resolve', 'dns_reverse', 'net'].map(m => {
const Plugin = require(`./event_plugins/${m}`)
return new Plugin(addEventCallback)
return new Plugin(eventHandler)
})

this.started = false
Expand Down Expand Up @@ -308,22 +308,22 @@ class EventsProfiler {
if (options.codeHotspotsEnabled) {
// Use Datadog instrumentation to collect events with span IDs. Still use
// Node API for GC events.
this._eventSource = new CompositeEventSource([
this.eventSource = new CompositeEventSource([
new DatadogInstrumentationEventSource(eventHandler),
new NodeApiEventSource(eventHandler, ['gc'])
])
} else {
// Use Node API instrumentation to collect events without span IDs
this._eventSource = new NodeApiEventSource(eventHandler)
this.eventSource = new NodeApiEventSource(eventHandler)
}
}

start () {
this._eventSource.start()
this.eventSource.start()
}

stop () {
this._eventSource.stop()
this.eventSource.stop()
}

profile (restart, startDate, endDate) {
Expand Down

0 comments on commit 9b0df51

Please sign in to comment.