dd-trace 3.42.0 → 3.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +5 -0
- package/package.json +4 -4
- package/packages/datadog-instrumentations/src/apollo-server-core.js +41 -0
- package/packages/datadog-instrumentations/src/apollo-server.js +83 -0
- package/packages/datadog-instrumentations/src/child-process.js +4 -5
- package/packages/datadog-instrumentations/src/couchbase.js +5 -4
- package/packages/datadog-instrumentations/src/crypto.js +2 -1
- package/packages/datadog-instrumentations/src/dns.js +2 -1
- package/packages/datadog-instrumentations/src/graphql.js +18 -4
- package/packages/datadog-instrumentations/src/helpers/hooks.js +9 -2
- package/packages/datadog-instrumentations/src/helpers/instrument.js +8 -3
- package/packages/datadog-instrumentations/src/helpers/register.js +18 -2
- package/packages/datadog-instrumentations/src/http/client.js +4 -16
- package/packages/datadog-instrumentations/src/http/server.js +7 -4
- package/packages/datadog-instrumentations/src/http2/client.js +3 -1
- package/packages/datadog-instrumentations/src/http2/server.js +3 -1
- package/packages/datadog-instrumentations/src/jest.js +1 -1
- package/packages/datadog-instrumentations/src/net.js +10 -2
- package/packages/datadog-instrumentations/src/next.js +15 -5
- package/packages/datadog-instrumentations/src/rhea.js +15 -9
- package/packages/datadog-plugin-cucumber/src/index.js +34 -2
- package/packages/datadog-plugin-cypress/src/plugin.js +60 -8
- package/packages/datadog-plugin-graphql/src/resolve.js +26 -18
- package/packages/datadog-plugin-http/src/client.js +1 -1
- package/packages/datadog-plugin-jest/src/index.js +38 -4
- package/packages/datadog-plugin-mocha/src/index.js +32 -1
- package/packages/datadog-plugin-next/src/index.js +32 -6
- package/packages/datadog-plugin-playwright/src/index.js +17 -1
- package/packages/dd-trace/src/appsec/activation.js +29 -0
- package/packages/dd-trace/src/appsec/addresses.js +1 -0
- package/packages/dd-trace/src/appsec/api_security_sampler.js +48 -0
- package/packages/dd-trace/src/appsec/blocked_templates.js +4 -1
- package/packages/dd-trace/src/appsec/blocking.js +95 -43
- package/packages/dd-trace/src/appsec/channels.js +4 -1
- package/packages/dd-trace/src/appsec/graphql.js +146 -0
- package/packages/dd-trace/src/appsec/index.js +29 -40
- package/packages/dd-trace/src/appsec/remote_config/capabilities.js +6 -1
- package/packages/dd-trace/src/appsec/remote_config/index.js +40 -15
- package/packages/dd-trace/src/appsec/sdk/user_blocking.js +1 -1
- package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +25 -13
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +30 -1
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +30 -1
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +36 -4
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-itr-configuration.js +18 -1
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +26 -1
- package/packages/dd-trace/src/ci-visibility/telemetry.js +130 -0
- package/packages/dd-trace/src/config.js +104 -58
- package/packages/dd-trace/src/encode/agentless-ci-visibility.js +14 -1
- package/packages/dd-trace/src/encode/coverage-ci-visibility.js +14 -0
- package/packages/dd-trace/src/exporters/common/agent-info-exporter.js +4 -0
- package/packages/dd-trace/src/exporters/common/form-data.js +4 -0
- package/packages/dd-trace/src/opentracing/tracer.js +2 -2
- package/packages/dd-trace/src/plugins/ci_plugin.js +44 -8
- package/packages/dd-trace/src/plugins/index.js +5 -0
- package/packages/dd-trace/src/plugins/util/exec.js +23 -2
- package/packages/dd-trace/src/plugins/util/git.js +94 -19
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +3 -2
- package/packages/dd-trace/src/priority_sampler.js +30 -38
- package/packages/dd-trace/src/profiling/exporters/agent.js +1 -0
- package/packages/dd-trace/src/profiling/profiler.js +7 -6
- package/packages/dd-trace/src/profiling/profilers/events.js +18 -13
- package/packages/dd-trace/src/profiling/profilers/shared.js +34 -4
- package/packages/dd-trace/src/profiling/profilers/space.js +2 -1
- package/packages/dd-trace/src/profiling/profilers/wall.js +17 -12
- package/packages/dd-trace/src/proxy.js +4 -0
- package/packages/dd-trace/src/sampling_rule.js +130 -0
- package/packages/dd-trace/src/span_sampler.js +6 -64
- package/packages/dd-trace/src/telemetry/index.js +43 -5
|
@@ -109,13 +109,6 @@ class Config {
|
|
|
109
109
|
log.use(this.logger)
|
|
110
110
|
log.toggle(this.debug, this.logLevel, this)
|
|
111
111
|
|
|
112
|
-
this.tags = {}
|
|
113
|
-
|
|
114
|
-
tagger.add(this.tags, process.env.DD_TAGS)
|
|
115
|
-
tagger.add(this.tags, process.env.DD_TRACE_TAGS)
|
|
116
|
-
tagger.add(this.tags, process.env.DD_TRACE_GLOBAL_TAGS)
|
|
117
|
-
tagger.add(this.tags, options.tags)
|
|
118
|
-
|
|
119
112
|
const DD_TRACING_ENABLED = coalesce(
|
|
120
113
|
process.env.DD_TRACING_ENABLED,
|
|
121
114
|
true
|
|
@@ -184,33 +177,12 @@ class Config {
|
|
|
184
177
|
false
|
|
185
178
|
)
|
|
186
179
|
|
|
187
|
-
const DD_SERVICE = options.service ||
|
|
188
|
-
process.env.DD_SERVICE ||
|
|
189
|
-
process.env.DD_SERVICE_NAME ||
|
|
190
|
-
this.tags.service ||
|
|
191
|
-
process.env.AWS_LAMBDA_FUNCTION_NAME ||
|
|
192
|
-
process.env.FUNCTION_NAME || // Google Cloud Function Name set by deprecated runtimes
|
|
193
|
-
process.env.K_SERVICE || // Google Cloud Function Name set by newer runtimes
|
|
194
|
-
process.env.WEBSITE_SITE_NAME || // set by Azure Functions
|
|
195
|
-
pkg.name ||
|
|
196
|
-
'node'
|
|
197
180
|
const DD_SERVICE_MAPPING = coalesce(
|
|
198
181
|
options.serviceMapping,
|
|
199
182
|
process.env.DD_SERVICE_MAPPING ? fromEntries(
|
|
200
183
|
process.env.DD_SERVICE_MAPPING.split(',').map(x => x.trim().split(':'))
|
|
201
184
|
) : {}
|
|
202
185
|
)
|
|
203
|
-
const DD_ENV = coalesce(
|
|
204
|
-
options.env,
|
|
205
|
-
process.env.DD_ENV,
|
|
206
|
-
this.tags.env
|
|
207
|
-
)
|
|
208
|
-
const DD_VERSION = coalesce(
|
|
209
|
-
options.version,
|
|
210
|
-
process.env.DD_VERSION,
|
|
211
|
-
this.tags.version,
|
|
212
|
-
pkg.version
|
|
213
|
-
)
|
|
214
186
|
const DD_TRACE_STARTUP_LOGS = coalesce(
|
|
215
187
|
options.startupLogs,
|
|
216
188
|
process.env.DD_TRACE_STARTUP_LOGS,
|
|
@@ -435,6 +407,10 @@ ken|consumer_?(?:id|key|secret)|sign(?:ed|ature)?|auth(?:entication|orization)?)
|
|
|
435
407
|
maybeFile(appsec.blockedTemplateJson),
|
|
436
408
|
maybeFile(process.env.DD_APPSEC_HTTP_BLOCKED_TEMPLATE_JSON)
|
|
437
409
|
)
|
|
410
|
+
const DD_APPSEC_GRAPHQL_BLOCKED_TEMPLATE_JSON = coalesce(
|
|
411
|
+
maybeFile(appsec.blockedTemplateGraphql),
|
|
412
|
+
maybeFile(process.env.DD_APPSEC_GRAPHQL_BLOCKED_TEMPLATE_JSON)
|
|
413
|
+
)
|
|
438
414
|
const DD_APPSEC_AUTOMATED_USER_EVENTS_TRACKING = coalesce(
|
|
439
415
|
appsec.eventTracking && appsec.eventTracking.mode,
|
|
440
416
|
process.env.DD_APPSEC_AUTOMATED_USER_EVENTS_TRACKING,
|
|
@@ -546,6 +522,19 @@ ken|consumer_?(?:id|key|secret)|sign(?:ed|ature)?|auth(?:entication|orization)?)
|
|
|
546
522
|
0
|
|
547
523
|
)
|
|
548
524
|
|
|
525
|
+
const DD_INSTRUMENTATION_INSTALL_ID = coalesce(
|
|
526
|
+
process.env.DD_INSTRUMENTATION_INSTALL_ID,
|
|
527
|
+
null
|
|
528
|
+
)
|
|
529
|
+
const DD_INSTRUMENTATION_INSTALL_TIME = coalesce(
|
|
530
|
+
process.env.DD_INSTRUMENTATION_INSTALL_TIME,
|
|
531
|
+
null
|
|
532
|
+
)
|
|
533
|
+
const DD_INSTRUMENTATION_INSTALL_TYPE = coalesce(
|
|
534
|
+
process.env.DD_INSTRUMENTATION_INSTALL_TYPE,
|
|
535
|
+
null
|
|
536
|
+
)
|
|
537
|
+
|
|
549
538
|
const ingestion = options.ingestion || {}
|
|
550
539
|
const dogstatsd = coalesce(options.dogstatsd, {})
|
|
551
540
|
const sampler = {
|
|
@@ -579,7 +568,6 @@ ken|consumer_?(?:id|key|secret)|sign(?:ed|ature)?|auth(?:entication|orization)?)
|
|
|
579
568
|
this.dsmEnabled = isTrue(DD_DATA_STREAMS_ENABLED)
|
|
580
569
|
this.openAiLogsEnabled = DD_OPENAI_LOGS_ENABLED
|
|
581
570
|
this.apiKey = DD_API_KEY
|
|
582
|
-
this.env = DD_ENV
|
|
583
571
|
this.url = DD_CIVISIBILITY_AGENTLESS_URL ? new URL(DD_CIVISIBILITY_AGENTLESS_URL)
|
|
584
572
|
: getAgentUrl(DD_TRACE_AGENT_URL, options)
|
|
585
573
|
this.site = coalesce(options.site, process.env.DD_SITE, 'datadoghq.com')
|
|
@@ -591,9 +579,7 @@ ken|consumer_?(?:id|key|secret)|sign(?:ed|ature)?|auth(?:entication|orization)?)
|
|
|
591
579
|
this.clientIpEnabled = DD_TRACE_CLIENT_IP_ENABLED
|
|
592
580
|
this.clientIpHeader = DD_TRACE_CLIENT_IP_HEADER
|
|
593
581
|
this.plugins = !!coalesce(options.plugins, true)
|
|
594
|
-
this.service = DD_SERVICE
|
|
595
582
|
this.serviceMapping = DD_SERVICE_MAPPING
|
|
596
|
-
this.version = DD_VERSION
|
|
597
583
|
this.dogstatsd = {
|
|
598
584
|
hostname: coalesce(dogstatsd.hostname, process.env.DD_DOGSTATSD_HOSTNAME, this.hostname),
|
|
599
585
|
port: String(coalesce(dogstatsd.port, process.env.DD_DOGSTATSD_PORT, 8125))
|
|
@@ -644,6 +630,7 @@ ken|consumer_?(?:id|key|secret)|sign(?:ed|ature)?|auth(?:entication|orization)?)
|
|
|
644
630
|
obfuscatorValueRegex: DD_APPSEC_OBFUSCATION_PARAMETER_VALUE_REGEXP,
|
|
645
631
|
blockedTemplateHtml: DD_APPSEC_HTTP_BLOCKED_TEMPLATE_HTML,
|
|
646
632
|
blockedTemplateJson: DD_APPSEC_HTTP_BLOCKED_TEMPLATE_JSON,
|
|
633
|
+
blockedTemplateGraphql: DD_APPSEC_GRAPHQL_BLOCKED_TEMPLATE_JSON,
|
|
647
634
|
eventTracking: {
|
|
648
635
|
enabled: ['extended', 'safe'].includes(DD_APPSEC_AUTOMATED_USER_EVENTS_TRACKING),
|
|
649
636
|
mode: DD_APPSEC_AUTOMATED_USER_EVENTS_TRACKING
|
|
@@ -685,6 +672,37 @@ ken|consumer_?(?:id|key|secret)|sign(?:ed|ature)?|auth(?:entication|orization)?)
|
|
|
685
672
|
// Requires an accompanying DD_APM_OBFUSCATION_MEMCACHED_KEEP_COMMAND=true in the agent
|
|
686
673
|
this.memcachedCommandEnabled = isTrue(DD_TRACE_MEMCACHED_COMMAND_ENABLED)
|
|
687
674
|
|
|
675
|
+
this.stats = {
|
|
676
|
+
enabled: isTrue(DD_TRACE_STATS_COMPUTATION_ENABLED)
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
this.traceId128BitGenerationEnabled = isTrue(DD_TRACE_128_BIT_TRACEID_GENERATION_ENABLED)
|
|
680
|
+
this.traceId128BitLoggingEnabled = isTrue(DD_TRACE_128_BIT_TRACEID_LOGGING_ENABLED)
|
|
681
|
+
|
|
682
|
+
this.isGCPFunction = isGCPFunction
|
|
683
|
+
this.isAzureFunctionConsumptionPlan = isAzureFunctionConsumptionPlan
|
|
684
|
+
|
|
685
|
+
this.spanLeakDebug = Number(DD_TRACE_SPAN_LEAK_DEBUG)
|
|
686
|
+
|
|
687
|
+
this.installSignature = {
|
|
688
|
+
id: DD_INSTRUMENTATION_INSTALL_ID,
|
|
689
|
+
time: DD_INSTRUMENTATION_INSTALL_TIME,
|
|
690
|
+
type: DD_INSTRUMENTATION_INSTALL_TYPE
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
this._applyDefaults()
|
|
694
|
+
this._applyEnvironment()
|
|
695
|
+
this._applyOptions(options)
|
|
696
|
+
this._applyRemote({})
|
|
697
|
+
this._merge()
|
|
698
|
+
|
|
699
|
+
tagger.add(this.tags, {
|
|
700
|
+
service: this.service,
|
|
701
|
+
env: this.env,
|
|
702
|
+
version: this.version,
|
|
703
|
+
'runtime-id': uuid()
|
|
704
|
+
})
|
|
705
|
+
|
|
688
706
|
if (this.gitMetadataEnabled) {
|
|
689
707
|
this.repositoryUrl = removeUserSensitiveInfo(
|
|
690
708
|
coalesce(
|
|
@@ -717,31 +735,6 @@ ken|consumer_?(?:id|key|secret)|sign(?:ed|ature)?|auth(?:entication|orization)?)
|
|
|
717
735
|
}
|
|
718
736
|
}
|
|
719
737
|
}
|
|
720
|
-
|
|
721
|
-
this.stats = {
|
|
722
|
-
enabled: isTrue(DD_TRACE_STATS_COMPUTATION_ENABLED)
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
this.traceId128BitGenerationEnabled = isTrue(DD_TRACE_128_BIT_TRACEID_GENERATION_ENABLED)
|
|
726
|
-
this.traceId128BitLoggingEnabled = isTrue(DD_TRACE_128_BIT_TRACEID_LOGGING_ENABLED)
|
|
727
|
-
|
|
728
|
-
this.isGCPFunction = isGCPFunction
|
|
729
|
-
this.isAzureFunctionConsumptionPlan = isAzureFunctionConsumptionPlan
|
|
730
|
-
|
|
731
|
-
this.spanLeakDebug = Number(DD_TRACE_SPAN_LEAK_DEBUG)
|
|
732
|
-
|
|
733
|
-
tagger.add(this.tags, {
|
|
734
|
-
service: this.service,
|
|
735
|
-
env: this.env,
|
|
736
|
-
version: this.version,
|
|
737
|
-
'runtime-id': uuid()
|
|
738
|
-
})
|
|
739
|
-
|
|
740
|
-
this._applyDefaults()
|
|
741
|
-
this._applyEnvironment()
|
|
742
|
-
this._applyOptions(options)
|
|
743
|
-
this._applyRemote({})
|
|
744
|
-
this._merge()
|
|
745
738
|
}
|
|
746
739
|
|
|
747
740
|
// Supports only a subset of options for now.
|
|
@@ -756,48 +749,93 @@ ken|consumer_?(?:id|key|secret)|sign(?:ed|ature)?|auth(?:entication|orization)?)
|
|
|
756
749
|
}
|
|
757
750
|
|
|
758
751
|
_applyDefaults () {
|
|
752
|
+
const {
|
|
753
|
+
AWS_LAMBDA_FUNCTION_NAME,
|
|
754
|
+
FUNCTION_NAME,
|
|
755
|
+
K_SERVICE,
|
|
756
|
+
WEBSITE_SITE_NAME
|
|
757
|
+
} = process.env
|
|
758
|
+
|
|
759
|
+
const service = AWS_LAMBDA_FUNCTION_NAME ||
|
|
760
|
+
FUNCTION_NAME || // Google Cloud Function Name set by deprecated runtimes
|
|
761
|
+
K_SERVICE || // Google Cloud Function Name set by newer runtimes
|
|
762
|
+
WEBSITE_SITE_NAME || // set by Azure Functions
|
|
763
|
+
pkg.name ||
|
|
764
|
+
'node'
|
|
765
|
+
|
|
759
766
|
const defaults = this._defaults = {}
|
|
760
767
|
|
|
768
|
+
this._setValue(defaults, 'service', service)
|
|
769
|
+
this._setValue(defaults, 'env', undefined)
|
|
770
|
+
this._setValue(defaults, 'version', pkg.version)
|
|
761
771
|
this._setUnit(defaults, 'sampleRate', undefined)
|
|
762
772
|
this._setBoolean(defaults, 'logInjection', false)
|
|
763
773
|
this._setArray(defaults, 'headerTags', [])
|
|
774
|
+
this._setValue(defaults, 'tags', {})
|
|
764
775
|
}
|
|
765
776
|
|
|
766
777
|
_applyEnvironment () {
|
|
767
778
|
const {
|
|
768
|
-
|
|
779
|
+
DD_ENV,
|
|
769
780
|
DD_LOGS_INJECTION,
|
|
770
|
-
|
|
781
|
+
DD_SERVICE,
|
|
782
|
+
DD_SERVICE_NAME,
|
|
783
|
+
DD_TAGS,
|
|
784
|
+
DD_TRACE_GLOBAL_TAGS,
|
|
785
|
+
DD_TRACE_HEADER_TAGS,
|
|
786
|
+
DD_TRACE_SAMPLE_RATE,
|
|
787
|
+
DD_TRACE_TAGS,
|
|
788
|
+
DD_VERSION
|
|
771
789
|
} = process.env
|
|
772
790
|
|
|
791
|
+
const tags = {}
|
|
773
792
|
const env = this._env = {}
|
|
774
793
|
|
|
794
|
+
tagger.add(tags, DD_TAGS)
|
|
795
|
+
tagger.add(tags, DD_TRACE_TAGS)
|
|
796
|
+
tagger.add(tags, DD_TRACE_GLOBAL_TAGS)
|
|
797
|
+
|
|
798
|
+
this._setValue(env, 'service', DD_SERVICE || DD_SERVICE_NAME || tags.service)
|
|
799
|
+
this._setValue(env, 'env', DD_ENV || tags.env)
|
|
800
|
+
this._setValue(env, 'version', DD_VERSION || tags.version)
|
|
775
801
|
this._setUnit(env, 'sampleRate', DD_TRACE_SAMPLE_RATE)
|
|
776
802
|
this._setBoolean(env, 'logInjection', DD_LOGS_INJECTION)
|
|
777
803
|
this._setArray(env, 'headerTags', DD_TRACE_HEADER_TAGS)
|
|
804
|
+
this._setTags(env, 'tags', tags)
|
|
778
805
|
}
|
|
779
806
|
|
|
780
807
|
_applyOptions (options) {
|
|
781
808
|
const opts = this._options = this._options || {}
|
|
809
|
+
const tags = {}
|
|
782
810
|
|
|
783
811
|
options = Object.assign({ ingestion: {} }, options, opts)
|
|
784
812
|
|
|
813
|
+
tagger.add(tags, options.tags)
|
|
814
|
+
|
|
815
|
+
this._setValue(opts, 'service', options.service || tags.service)
|
|
816
|
+
this._setValue(opts, 'env', options.env || tags.env)
|
|
817
|
+
this._setValue(opts, 'version', options.version || tags.version)
|
|
785
818
|
this._setUnit(opts, 'sampleRate', coalesce(options.sampleRate, options.ingestion.sampleRate))
|
|
786
819
|
this._setBoolean(opts, 'logInjection', options.logInjection)
|
|
787
820
|
this._setArray(opts, 'headerTags', options.headerTags)
|
|
821
|
+
this._setTags(opts, 'tags', tags)
|
|
788
822
|
}
|
|
789
823
|
|
|
790
824
|
_applyRemote (options) {
|
|
791
825
|
const opts = this._remote = this._remote || {}
|
|
826
|
+
const tags = {}
|
|
792
827
|
const headerTags = options.tracing_header_tags
|
|
793
828
|
? options.tracing_header_tags.map(tag => {
|
|
794
829
|
return tag.tag_name ? `${tag.header}:${tag.tag_name}` : tag.header
|
|
795
830
|
})
|
|
796
831
|
: undefined
|
|
797
832
|
|
|
833
|
+
tagger.add(tags, options.tracing_tags)
|
|
834
|
+
|
|
798
835
|
this._setUnit(opts, 'sampleRate', options.tracing_sampling_rate)
|
|
799
836
|
this._setBoolean(opts, 'logInjection', options.log_injection_enabled)
|
|
800
837
|
this._setArray(opts, 'headerTags', headerTags)
|
|
838
|
+
this._setTags(opts, 'tags', tags)
|
|
801
839
|
}
|
|
802
840
|
|
|
803
841
|
_setBoolean (obj, name, value) {
|
|
@@ -837,6 +875,14 @@ ken|consumer_?(?:id|key|secret)|sign(?:ed|ature)?|auth(?:entication|orization)?)
|
|
|
837
875
|
}
|
|
838
876
|
}
|
|
839
877
|
|
|
878
|
+
_setTags (obj, name, value) {
|
|
879
|
+
if (!value || Object.keys(value).length === 0) {
|
|
880
|
+
return this._setValue(obj, name, null)
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
this._setValue(obj, name, value)
|
|
884
|
+
}
|
|
885
|
+
|
|
840
886
|
_setValue (obj, name, value) {
|
|
841
887
|
obj[name] = value
|
|
842
888
|
}
|
|
@@ -3,8 +3,13 @@ const { truncateSpan, normalizeSpan } = require('./tags-processors')
|
|
|
3
3
|
const { AgentEncoder } = require('./0.4')
|
|
4
4
|
const { version: ddTraceVersion } = require('../../../../package.json')
|
|
5
5
|
const id = require('../../../dd-trace/src/id')
|
|
6
|
-
const
|
|
6
|
+
const {
|
|
7
|
+
distributionMetric,
|
|
8
|
+
TELEMETRY_ENDPOINT_PAYLOAD_SERIALIZATION_MS,
|
|
9
|
+
TELEMETRY_ENDPOINT_PAYLOAD_EVENTS_COUNT
|
|
10
|
+
} = require('../ci-visibility/telemetry')
|
|
7
11
|
|
|
12
|
+
const ENCODING_VERSION = 1
|
|
8
13
|
const ALLOWED_CONTENT_TYPES = ['test_session_end', 'test_module_end', 'test_suite_end', 'test']
|
|
9
14
|
|
|
10
15
|
const TEST_SUITE_KEYS_LENGTH = 12
|
|
@@ -247,6 +252,8 @@ class AgentlessCiVisibilityEncoder extends AgentEncoder {
|
|
|
247
252
|
}
|
|
248
253
|
|
|
249
254
|
_encode (bytes, trace) {
|
|
255
|
+
const startTime = Date.now()
|
|
256
|
+
|
|
250
257
|
const rawEvents = trace.map(formatSpan)
|
|
251
258
|
|
|
252
259
|
const testSessionEvents = rawEvents.filter(
|
|
@@ -261,9 +268,15 @@ class AgentlessCiVisibilityEncoder extends AgentEncoder {
|
|
|
261
268
|
for (const event of events) {
|
|
262
269
|
this._encodeEvent(bytes, event)
|
|
263
270
|
}
|
|
271
|
+
distributionMetric(
|
|
272
|
+
TELEMETRY_ENDPOINT_PAYLOAD_SERIALIZATION_MS,
|
|
273
|
+
{ endpoint: 'test_cycle' },
|
|
274
|
+
Date.now() - startTime
|
|
275
|
+
)
|
|
264
276
|
}
|
|
265
277
|
|
|
266
278
|
makePayload () {
|
|
279
|
+
distributionMetric(TELEMETRY_ENDPOINT_PAYLOAD_EVENTS_COUNT, { endpoint: 'test_cycle' }, this._eventCount)
|
|
267
280
|
const bytes = this._traceBytes
|
|
268
281
|
const eventsOffset = this._eventsOffset
|
|
269
282
|
const eventsCount = this._eventCount
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
const { AgentEncoder } = require('./0.4')
|
|
3
3
|
const Chunk = require('./chunk')
|
|
4
4
|
|
|
5
|
+
const {
|
|
6
|
+
distributionMetric,
|
|
7
|
+
TELEMETRY_ENDPOINT_PAYLOAD_SERIALIZATION_MS,
|
|
8
|
+
TELEMETRY_ENDPOINT_PAYLOAD_EVENTS_COUNT
|
|
9
|
+
} = require('../ci-visibility/telemetry')
|
|
5
10
|
const FormData = require('../exporters/common/form-data')
|
|
6
11
|
|
|
7
12
|
const COVERAGE_PAYLOAD_VERSION = 2
|
|
@@ -21,8 +26,16 @@ class CoverageCIVisibilityEncoder extends AgentEncoder {
|
|
|
21
26
|
}
|
|
22
27
|
|
|
23
28
|
encode (coverage) {
|
|
29
|
+
const startTime = Date.now()
|
|
30
|
+
|
|
24
31
|
this._coveragesCount++
|
|
25
32
|
this.encodeCodeCoverage(this._coverageBytes, coverage)
|
|
33
|
+
|
|
34
|
+
distributionMetric(
|
|
35
|
+
TELEMETRY_ENDPOINT_PAYLOAD_SERIALIZATION_MS,
|
|
36
|
+
{ endpoint: 'code_coverage' },
|
|
37
|
+
Date.now() - startTime
|
|
38
|
+
)
|
|
26
39
|
}
|
|
27
40
|
|
|
28
41
|
encodeCodeCoverage (bytes, coverage) {
|
|
@@ -73,6 +86,7 @@ class CoverageCIVisibilityEncoder extends AgentEncoder {
|
|
|
73
86
|
}
|
|
74
87
|
|
|
75
88
|
makePayload () {
|
|
89
|
+
distributionMetric(TELEMETRY_ENDPOINT_PAYLOAD_EVENTS_COUNT, { endpoint: 'code_coverage' }, this._coveragesCount)
|
|
76
90
|
const bytes = this._coverageBytes
|
|
77
91
|
|
|
78
92
|
const coveragesOffset = this._coveragesOffset
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const { URL, format } = require('url')
|
|
2
2
|
|
|
3
3
|
const request = require('./request')
|
|
4
|
+
const { incrementCountMetric, TELEMETRY_EVENTS_ENQUEUED_FOR_SERIALIZATION } = require('../../ci-visibility/telemetry')
|
|
4
5
|
|
|
5
6
|
function fetchAgentInfo (url, callback) {
|
|
6
7
|
request('', {
|
|
@@ -49,6 +50,9 @@ class AgentInfoExporter {
|
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
_export (payload, writer = this._writer, timerKey = '_timer') {
|
|
53
|
+
if (this._config.isCiVisibility) {
|
|
54
|
+
incrementCountMetric(TELEMETRY_EVENTS_ENQUEUED_FOR_SERIALIZATION, {}, payload.length)
|
|
55
|
+
}
|
|
52
56
|
writer.append(payload)
|
|
53
57
|
|
|
54
58
|
const { flushInterval } = this._config
|
|
@@ -22,10 +22,10 @@ class DatadogTracer {
|
|
|
22
22
|
constructor (config) {
|
|
23
23
|
const Exporter = getExporter(config.experimental.exporter)
|
|
24
24
|
|
|
25
|
+
this._config = config
|
|
25
26
|
this._service = config.service
|
|
26
27
|
this._version = config.version
|
|
27
28
|
this._env = config.env
|
|
28
|
-
this._tags = config.tags
|
|
29
29
|
this._logInjection = config.logInjection
|
|
30
30
|
this._debug = config.debug
|
|
31
31
|
this._prioritySampler = new PrioritySampler(config.env, config.sampler)
|
|
@@ -64,7 +64,7 @@ class DatadogTracer {
|
|
|
64
64
|
integrationName: options.integrationName
|
|
65
65
|
}, this._debug)
|
|
66
66
|
|
|
67
|
-
span.addTags(this.
|
|
67
|
+
span.addTags(this._config.tags)
|
|
68
68
|
span.addTags(options.tags)
|
|
69
69
|
|
|
70
70
|
return span
|
|
@@ -20,6 +20,14 @@ const {
|
|
|
20
20
|
const Plugin = require('./plugin')
|
|
21
21
|
const { COMPONENT } = require('../constants')
|
|
22
22
|
const log = require('../log')
|
|
23
|
+
const {
|
|
24
|
+
incrementCountMetric,
|
|
25
|
+
distributionMetric,
|
|
26
|
+
TELEMETRY_EVENT_CREATED,
|
|
27
|
+
TELEMETRY_ITR_SKIPPED
|
|
28
|
+
} = require('../ci-visibility/telemetry')
|
|
29
|
+
const { CI_PROVIDER_NAME, GIT_REPOSITORY_URL, GIT_COMMIT_SHA, GIT_BRANCH } = require('./util/tags')
|
|
30
|
+
const { OS_VERSION, OS_PLATFORM, OS_ARCHITECTURE, RUNTIME_NAME, RUNTIME_VERSION } = require('./util/env')
|
|
23
31
|
|
|
24
32
|
module.exports = class CiPlugin extends Plugin {
|
|
25
33
|
constructor (...args) {
|
|
@@ -71,6 +79,7 @@ module.exports = class CiPlugin extends Plugin {
|
|
|
71
79
|
...testSessionSpanMetadata
|
|
72
80
|
}
|
|
73
81
|
})
|
|
82
|
+
this.telemetry.ciVisEvent(TELEMETRY_EVENT_CREATED, 'session')
|
|
74
83
|
this.testModuleSpan = this.tracer.startSpan(`${this.constructor.id}.test_module`, {
|
|
75
84
|
childOf: this.testSessionSpan,
|
|
76
85
|
tags: {
|
|
@@ -79,6 +88,7 @@ module.exports = class CiPlugin extends Plugin {
|
|
|
79
88
|
...testModuleSpanMetadata
|
|
80
89
|
}
|
|
81
90
|
})
|
|
91
|
+
this.telemetry.ciVisEvent(TELEMETRY_EVENT_CREATED, 'module')
|
|
82
92
|
})
|
|
83
93
|
|
|
84
94
|
this.addSub(`ci:${this.constructor.id}:itr:skipped-suites`, ({ skippedSuites, frameworkVersion }) => {
|
|
@@ -97,25 +107,49 @@ module.exports = class CiPlugin extends Plugin {
|
|
|
97
107
|
}
|
|
98
108
|
}).finish()
|
|
99
109
|
})
|
|
110
|
+
this.telemetry.count(TELEMETRY_ITR_SKIPPED, { testLevel: 'suite' }, skippedSuites.length)
|
|
100
111
|
})
|
|
101
112
|
}
|
|
102
113
|
|
|
114
|
+
get telemetry () {
|
|
115
|
+
const testFramework = this.constructor.id
|
|
116
|
+
return {
|
|
117
|
+
ciVisEvent: function (name, testLevel, tags = {}) {
|
|
118
|
+
incrementCountMetric(name, {
|
|
119
|
+
testLevel,
|
|
120
|
+
testFramework,
|
|
121
|
+
isUnsupportedCIProvider: this.isUnsupportedCIProvider,
|
|
122
|
+
...tags
|
|
123
|
+
})
|
|
124
|
+
},
|
|
125
|
+
count: function (name, tags, value = 1) {
|
|
126
|
+
incrementCountMetric(name, tags, value)
|
|
127
|
+
},
|
|
128
|
+
distribution: function (name, tags, measure) {
|
|
129
|
+
distributionMetric(name, tags, measure)
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
103
134
|
configure (config) {
|
|
104
135
|
super.configure(config)
|
|
105
136
|
this.testEnvironmentMetadata = getTestEnvironmentMetadata(this.constructor.id, this.config)
|
|
106
137
|
this.codeOwnersEntries = getCodeOwnersFileEntries()
|
|
107
138
|
|
|
108
139
|
const {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
140
|
+
[GIT_REPOSITORY_URL]: repositoryUrl,
|
|
141
|
+
[GIT_COMMIT_SHA]: sha,
|
|
142
|
+
[OS_VERSION]: osVersion,
|
|
143
|
+
[OS_PLATFORM]: osPlatform,
|
|
144
|
+
[OS_ARCHITECTURE]: osArchitecture,
|
|
145
|
+
[RUNTIME_NAME]: runtimeName,
|
|
146
|
+
[RUNTIME_VERSION]: runtimeVersion,
|
|
147
|
+
[GIT_BRANCH]: branch,
|
|
148
|
+
[CI_PROVIDER_NAME]: ciProviderName
|
|
117
149
|
} = this.testEnvironmentMetadata
|
|
118
150
|
|
|
151
|
+
this.isUnsupportedCIProvider = !ciProviderName
|
|
152
|
+
|
|
119
153
|
this.testConfiguration = {
|
|
120
154
|
repositoryUrl,
|
|
121
155
|
sha,
|
|
@@ -170,6 +204,8 @@ module.exports = class CiPlugin extends Plugin {
|
|
|
170
204
|
}
|
|
171
205
|
}
|
|
172
206
|
|
|
207
|
+
this.telemetry.ciVisEvent(TELEMETRY_EVENT_CREATED, 'test', { hasCodeOwners: !!codeOwners })
|
|
208
|
+
|
|
173
209
|
const testSpan = this.tracer
|
|
174
210
|
.startSpan(`${this.constructor.id}.test`, {
|
|
175
211
|
childOf,
|
|
@@ -59,6 +59,11 @@ module.exports = {
|
|
|
59
59
|
get 'mysql2' () { return require('../../../datadog-plugin-mysql2/src') },
|
|
60
60
|
get 'net' () { return require('../../../datadog-plugin-net/src') },
|
|
61
61
|
get 'next' () { return require('../../../datadog-plugin-next/src') },
|
|
62
|
+
get 'node:dns' () { return require('../../../datadog-plugin-dns/src') },
|
|
63
|
+
get 'node:http' () { return require('../../../datadog-plugin-http/src') },
|
|
64
|
+
get 'node:http2' () { return require('../../../datadog-plugin-http2/src') },
|
|
65
|
+
get 'node:https' () { return require('../../../datadog-plugin-http/src') },
|
|
66
|
+
get 'node:net' () { return require('../../../datadog-plugin-net/src') },
|
|
62
67
|
get 'oracledb' () { return require('../../../datadog-plugin-oracledb/src') },
|
|
63
68
|
get 'openai' () { return require('../../../datadog-plugin-openai/src') },
|
|
64
69
|
get 'paperplane' () { return require('../../../datadog-plugin-paperplane/src') },
|
|
@@ -1,10 +1,31 @@
|
|
|
1
1
|
const cp = require('child_process')
|
|
2
2
|
const log = require('../../log')
|
|
3
|
+
const { distributionMetric, incrementCountMetric } = require('../../ci-visibility/telemetry')
|
|
3
4
|
|
|
4
|
-
const sanitizedExec = (
|
|
5
|
+
const sanitizedExec = (
|
|
6
|
+
cmd,
|
|
7
|
+
flags,
|
|
8
|
+
operationMetric,
|
|
9
|
+
durationMetric,
|
|
10
|
+
errorMetric
|
|
11
|
+
) => {
|
|
12
|
+
let startTime
|
|
13
|
+
if (operationMetric) {
|
|
14
|
+
incrementCountMetric(operationMetric.name, operationMetric.tags)
|
|
15
|
+
}
|
|
16
|
+
if (durationMetric) {
|
|
17
|
+
startTime = Date.now()
|
|
18
|
+
}
|
|
5
19
|
try {
|
|
6
|
-
|
|
20
|
+
const result = cp.execFileSync(cmd, flags, { stdio: 'pipe' }).toString().replace(/(\r\n|\n|\r)/gm, '')
|
|
21
|
+
if (durationMetric) {
|
|
22
|
+
distributionMetric(durationMetric.name, durationMetric.tags, Date.now() - startTime)
|
|
23
|
+
}
|
|
24
|
+
return result
|
|
7
25
|
} catch (e) {
|
|
26
|
+
if (errorMetric) {
|
|
27
|
+
incrementCountMetric(errorMetric.name, { ...errorMetric.tags, exitCode: e.status })
|
|
28
|
+
}
|
|
8
29
|
log.error(e)
|
|
9
30
|
return ''
|
|
10
31
|
}
|