@@ -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 } ) , { } ) )
@@ -405,6 +406,11 @@ ken|consumer_?(?:id|key|secret)|sign(?:ed|ature)?|auth(?:entication|orization)?)
405406 true
406407 )
407408
409+ const DD_TRACE_GIT_METADATA_ENABLED = coalesce (
410+ process . env . DD_TRACE_GIT_METADATA_ENABLED ,
411+ true
412+ )
413+
408414 const ingestion = options . ingestion || { }
409415 const dogstatsd = coalesce ( options . dogstatsd , { } )
410416 const sampler = {
@@ -519,6 +525,19 @@ ken|consumer_?(?:id|key|secret)|sign(?:ed|ature)?|auth(?:entication|orization)?)
519525 this . isGitUploadEnabled = this . isCiVisibility &&
520526 ( this . isIntelligentTestRunnerEnabled && ! isFalse ( DD_CIVISIBILITY_GIT_UPLOAD_ENABLED ) )
521527
528+ this . gitMetadataEnabled = isTrue ( DD_TRACE_GIT_METADATA_ENABLED )
529+
530+ if ( this . gitMetadataEnabled ) {
531+ this . repositoryUrl = coalesce (
532+ process . env . DD_GIT_REPOSITORY_URL ,
533+ this . tags [ GIT_REPOSITORY_URL ]
534+ )
535+ this . commitSHA = coalesce (
536+ process . env . DD_GIT_COMMIT_SHA ,
537+ this . tags [ GIT_COMMIT_SHA ]
538+ )
539+ }
540+
522541 this . stats = {
523542 enabled : isTrue ( DD_TRACE_STATS_COMPUTATION_ENABLED )
524543 }
0 commit comments