@@ -39,8 +39,6 @@ private sealed class PredictionRequestBody
39
39
{
40
40
public sealed class RequestContext
41
41
{
42
- public string CorrelationId { get ; set ; } = Guid . Empty . ToString ( ) ;
43
- public string SessionId { get ; set ; } = Guid . Empty . ToString ( ) ;
44
42
public string SubscriptionId { get ; set ; } = Guid . Empty . ToString ( ) ;
45
43
public Version VersionNumber { get ; set ; } = new Version ( 0 , 0 ) ;
46
44
}
@@ -57,6 +55,11 @@ private sealed class CommandRequestContext
57
55
public Version VersionNumber { get ; set ; } = new Version ( 0 , 0 ) ;
58
56
}
59
57
58
+ /// <summary>
59
+ /// The name of the header value that contains the platform correlation id.
60
+ /// </summary>
61
+ private const string CorrelationIdHeader = "Sml-CorrelationId" ;
62
+
60
63
private const string ThrottleByIdHeader = "X-UserId" ;
61
64
private readonly HttpClient _client ;
62
65
private readonly string _commandsEndpoint ;
@@ -285,12 +288,10 @@ public virtual void RequestPredictions(IEnumerable<string> commands)
285
288
Task . Run ( async ( ) => {
286
289
try
287
290
{
288
- AzPredictorService . ReplaceThrottleUserIdToHeader ( _client ? . DefaultRequestHeaders , _azContext . UserId ) ;
291
+ AzPredictorService . SetHttpRequestHeader ( _client ? . DefaultRequestHeaders , _azContext . UserId , _telemetryClient . CorrelationId ) ;
289
292
290
293
var requestContext = new PredictionRequestBody . RequestContext ( )
291
294
{
292
- SessionId = _telemetryClient . SessionId ,
293
- CorrelationId = _telemetryClient . CorrelationId ,
294
295
VersionNumber = this . _azContext . AzVersion
295
296
} ;
296
297
@@ -358,7 +359,7 @@ protected virtual void RequestAllPredictiveCommands()
358
359
359
360
try
360
361
{
361
- _client . DefaultRequestHeaders ? . Add ( AzPredictorService . ThrottleByIdHeader , _azContext . UserId ) ;
362
+ AzPredictorService . SetHttpRequestHeader ( _client . DefaultRequestHeaders , _azContext . UserId , _telemetryClient . CorrelationId ) ;
362
363
363
364
var httpResponseMessage = await _client . GetAsync ( _commandsEndpoint ) ;
364
365
@@ -427,21 +428,27 @@ private static string GetCommandName(string commandLine)
427
428
return commandLine . Split ( AzPredictorConstants . CommandParameterSeperator ) . First ( ) ;
428
429
}
429
430
430
- private static void ReplaceThrottleUserIdToHeader ( HttpRequestHeaders header , string value )
431
+ private static void SetHttpRequestHeader ( HttpRequestHeaders header , string idToThrottle , string correlationId )
431
432
{
432
433
if ( header != null )
433
434
{
434
435
lock ( header )
435
436
{
436
437
header . Remove ( AzPredictorService . ThrottleByIdHeader ) ;
437
438
438
- if ( ! string . IsNullOrWhiteSpace ( value ) )
439
+ if ( ! string . IsNullOrWhiteSpace ( idToThrottle ) )
440
+ {
441
+ header . Add ( AzPredictorService . ThrottleByIdHeader , idToThrottle ) ;
442
+ }
443
+
444
+ header . Remove ( AzPredictorService . CorrelationIdHeader ) ;
445
+
446
+ if ( ! string . IsNullOrWhiteSpace ( correlationId ) )
439
447
{
440
- header . Add ( AzPredictorService . ThrottleByIdHeader , value ) ;
448
+ header . Add ( AzPredictorService . CorrelationIdHeader , correlationId ) ;
441
449
}
442
450
}
443
451
}
444
-
445
452
}
446
453
}
447
454
}
0 commit comments