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

[serverless] lazy load SDKs #5089

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
18 changes: 12 additions & 6 deletions packages/dd-trace/src/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@ const DynamicInstrumentation = require('./debugger')
const telemetry = require('./telemetry')
const nomenclature = require('./service-naming')
const PluginManager = require('./plugin_manager')
const remoteConfig = require('./appsec/remote_config')
const AppsecSdk = require('./appsec/sdk')
const dogstatsd = require('./dogstatsd')
const NoopDogStatsDClient = require('./noop/dogstatsd')
const spanleak = require('./spanleak')
const { SSIHeuristics } = require('./profiling/ssi-heuristics')
const appsecStandalone = require('./appsec/standalone')
const LLMObsSDK = require('./llmobs/sdk')

class LazyModule {
constructor (provider) {
Expand Down Expand Up @@ -89,7 +86,7 @@ class Tracer extends NoopProxy {
}

if (config.remoteConfig.enabled && !config.isCiVisibility) {
const rc = remoteConfig.enable(config, this._modules.appsec)
const rc = require('./appsec/remote_config').enable(config, this._modules.appsec)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is required in other places. Should the lazy loading happen in the module instead instead?


rc.setProductHandler('APM_TRACING', (action, conf) => {
if (action === 'unapply') {
Expand Down Expand Up @@ -214,8 +211,17 @@ class Tracer extends NoopProxy {
const prioritySampler = appsecStandalone.configure(config)
this._tracer = new DatadogTracer(config, prioritySampler)
this.dataStreamsCheckpointer = this._tracer.dataStreamsCheckpointer
this.appsec = new AppsecSdk(this._tracer, config)
this.llmobs = new LLMObsSDK(this._tracer, this._modules.llmobs, config)

if (config.appsec.enabled) {
const AppsecSdk = require('./appsec/sdk')
this.appsec = new AppsecSdk(this._tracer, config)
}

if (config.llmobs.enabled) {
const LLMObsSDK = require('./llmobs/sdk')
this.llmobs = new LLMObsSDK(this._tracer, this._modules.llmobs, config)
}

this._tracingInitialized = true
}
if (config.iast.enabled) {
Expand Down
Loading