< Summary

Class:Azure.Data.AppConfiguration.CustomHeadersPolicy
Assembly:Azure.Data.AppConfiguration
File(s):C:\Git\azure-sdk-for-net\sdk\appconfiguration\Azure.Data.AppConfiguration\src\CustomHeadersPolicy.cs
Covered lines:17
Uncovered lines:0
Coverable lines:17
Total lines:53
Line coverage:100% (17 of 17)
Covered branches:12
Total branches:12
Branch coverage:100% (12 of 12)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.cctor()-100%100%
OnSendingRequest(...)-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\appconfiguration\Azure.Data.AppConfiguration\src\CustomHeadersPolicy.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using System.Collections.Generic;
 6using System.Diagnostics;
 7using Azure.Core;
 8using Azure.Core.Pipeline;
 9
 10namespace Azure.Data.AppConfiguration
 11{
 12    internal class CustomHeadersPolicy : HttpPipelineSynchronousPolicy
 13    {
 14        private const string ActivityId = "Azure.CustomDiagnosticHeaders";
 15
 216        private static readonly Dictionary<string, bool> SupportedHeaders = new Dictionary<string, bool>(StringComparer.
 217        {
 218            { "x-ms-client-request-id", true },
 219            { "x-ms-correlation-request-id", false },
 220            { "correlation-context", false }
 221        };
 22
 23        public override void OnSendingRequest(HttpMessage message)
 24        {
 79225            Activity activity = Activity.Current;
 146026            while (activity != null && activity.OperationName != ActivityId)
 27            {
 66828                activity = activity.Parent;
 29            }
 30
 79231            if (activity == null)
 32            {
 76833                return;
 34            }
 35
 14436            foreach (KeyValuePair<string, string> tag in activity.Tags)
 37            {
 4838                if (SupportedHeaders.TryGetValue(tag.Key, out bool isClientRequestId))
 39                {
 3640                    if (isClientRequestId)
 41                    {
 42                        // ClientRequestId policy will set the header from this Request property
 1243                        message.Request.ClientRequestId = tag.Value;
 44                    }
 45                    else
 46                    {
 2447                        message.Request.Headers.Add(tag.Key, tag.Value);
 48                    }
 49                }
 50            }
 2451        }
 52    }
 53}

Methods/Properties

.cctor()
OnSendingRequest(...)