File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -415,7 +415,7 @@ private static IApiRequestFactory CreateApiRequestFactory(ExporterSettings expor
415415 productName : "discovery" ,
416416 tcpTimeout : tcpTimeout ,
417417 BuildHeaders ( containerId ) ,
418- ( ) => new MinimalAgentHeaderHelper ( ) ,
418+ ( ) => new MinimalAgentHeaderHelper ( containerId ) ,
419419 uri => uri ) ;
420420 }
421421 }
Original file line number Diff line number Diff line change @@ -11,6 +11,13 @@ namespace Datadog.Trace.HttpOverStreams;
1111internal class MinimalAgentHeaderHelper : HttpHeaderHelperBase
1212{
1313 private static string ? _metadataHeaders = null ;
14+ private static string ? _metadataHeadersWithContainerId = null ;
15+ private readonly string ? _containerId ;
16+
17+ public MinimalAgentHeaderHelper ( string ? containerId = null )
18+ {
19+ _containerId = containerId ;
20+ }
1421
1522 protected override string MetadataHeaders
1623 {
@@ -22,6 +29,18 @@ protected override string MetadataHeaders
2229 _metadataHeaders = string . Concat ( headers ) ;
2330 }
2431
32+ if ( _containerId != null )
33+ {
34+ if ( _metadataHeadersWithContainerId == null )
35+ {
36+ // Assuming we'd always get the same container ID. The first time, we use its value to build the header,
37+ // then it's just a marker that we want the header with the containerID in it, and we don't look at its value.
38+ _metadataHeadersWithContainerId = _metadataHeaders + $ "{ AgentHttpHeaderNames . ContainerId } : { _containerId } { DatadogHttpValues . CrLf } ";
39+ }
40+
41+ return _metadataHeadersWithContainerId ;
42+ }
43+
2544 return _metadataHeaders ;
2645 }
2746 }
You can’t perform that action at this time.
0 commit comments