@@ -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 } ) , { } ) )
@@ -412,6 +413,11 @@ ken|consumer_?(?:id|key|secret)|sign(?:ed|ature)?|auth(?:entication|orization)?)
412413 true
413414 )
414415
416+ const DD_TRACE_GIT_METADATA_ENABLED = coalesce (
417+ process . env . DD_TRACE_GIT_METADATA_ENABLED ,
418+ true
419+ )
420+
415421 const ingestion = options . ingestion || { }
416422 const dogstatsd = coalesce ( options . dogstatsd , { } )
417423 const sampler = {
@@ -526,6 +532,19 @@ ken|consumer_?(?:id|key|secret)|sign(?:ed|ature)?|auth(?:entication|orization)?)
526532 this . isGitUploadEnabled = this . isCiVisibility &&
527533 ( this . isIntelligentTestRunnerEnabled && ! isFalse ( DD_CIVISIBILITY_GIT_UPLOAD_ENABLED ) )
528534
535+ this . gitMetadataEnabled = isTrue ( DD_TRACE_GIT_METADATA_ENABLED )
536+
537+ if ( this . gitMetadataEnabled ) {
538+ this . repositoryUrl = coalesce (
539+ process . env . DD_GIT_REPOSITORY_URL ,
540+ this . tags [ GIT_REPOSITORY_URL ]
541+ )
542+ this . commitSHA = coalesce (
543+ process . env . DD_GIT_COMMIT_SHA ,
544+ this . tags [ GIT_COMMIT_SHA ]
545+ )
546+ }
547+
529548 this . stats = {
530549 enabled : isTrue ( DD_TRACE_STATS_COMPUTATION_ENABLED )
531550 }
0 commit comments