Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PROF-10484] refactor: use standard profiler in serverless contexts #4652

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/dd-trace/src/profiling/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
'use strict'

const { Profiler, ServerlessProfiler } = require('./profiler')
const { Profiler } = require('./profiler')
const WallProfiler = require('./profilers/wall')
const SpaceProfiler = require('./profilers/space')
const { AgentExporter } = require('./exporters/agent')
const { FileExporter } = require('./exporters/file')
const { ConsoleLogger } = require('./loggers/console')

const profiler = process.env.AWS_LAMBDA_FUNCTION_NAME ? new ServerlessProfiler() : new Profiler()
const profiler = new Profiler()

module.exports = {
profiler,
Expand Down
25 changes: 1 addition & 24 deletions packages/dd-trace/src/profiling/profiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,29 +198,6 @@ class Profiler extends EventEmitter {
}
}

class ServerlessProfiler extends Profiler {
constructor () {
super()
this._profiledIntervals = 0
this._interval = 1
this._flushAfterIntervals = undefined
}

_setInterval () {
this._timeoutInterval = this._interval * 1000
this._flushAfterIntervals = this._config.flushInterval / 1000
}

async _collect (snapshotKind, restart = true) {
if (this._profiledIntervals >= this._flushAfterIntervals || !restart) {
this._profiledIntervals = 0
await super._collect(snapshotKind, restart)
} else {
this._profiledIntervals += 1
this._capture(this._timeoutInterval, new Date())
// Don't submit profile until 65 (flushAfterIntervals) intervals have elapsed
}
}
}
const ServerlessProfiler = Profiler

module.exports = { Profiler, ServerlessProfiler }
Loading
Loading