@@ -9,6 +9,7 @@ const coalesce = require('koalas')
99const tagger = require ( './tagger' )
1010const { isTrue, isFalse } = require ( './util' )
1111const uuid = require ( 'crypto-randomuuid' )
12+ const { GIT_REPOSITORY_URL , GIT_COMMIT_SHA } = require ( './plugins/util/tags' )
1213
1314const fromEntries = Object . fromEntries || ( entries =>
1415 entries . reduce ( ( obj , [ k , v ] ) => Object . assign ( obj , { [ k ] : v } ) , { } ) )
@@ -408,6 +409,11 @@ ken|consumer_?(?:id|key|secret)|sign(?:ed|ature)?|auth(?:entication|orization)?)
408409 true
409410 )
410411
412+ const DD_TRACE_GIT_METADATA_ENABLED = coalesce (
413+ process . env . DD_TRACE_GIT_METADATA_ENABLED ,
414+ true
415+ )
416+
411417 const ingestion = options . ingestion || { }
412418 const dogstatsd = coalesce ( options . dogstatsd , { } )
413419 const sampler = {
@@ -522,6 +528,19 @@ ken|consumer_?(?:id|key|secret)|sign(?:ed|ature)?|auth(?:entication|orization)?)
522528 this . isGitUploadEnabled = this . isCiVisibility &&
523529 ( this . isIntelligentTestRunnerEnabled && ! isFalse ( DD_CIVISIBILITY_GIT_UPLOAD_ENABLED ) )
524530
531+ this . gitMetadataEnabled = isTrue ( DD_TRACE_GIT_METADATA_ENABLED )
532+
533+ if ( this . gitMetadataEnabled ) {
534+ this . repositoryUrl = coalesce (
535+ process . env . DD_GIT_REPOSITORY_URL ,
536+ this . tags [ GIT_REPOSITORY_URL ]
537+ )
538+ this . commitSHA = coalesce (
539+ process . env . DD_GIT_COMMIT_SHA ,
540+ this . tags [ GIT_COMMIT_SHA ]
541+ )
542+ }
543+
525544 this . stats = {
526545 enabled : isTrue ( DD_TRACE_STATS_COMPUTATION_ENABLED )
527546 }
0 commit comments