< Summary

Class:Azure.Core.Pipeline.TelemetryPolicy
Assembly:Azure.Core
File(s):C:\Git\azure-sdk-for-net\sdk\core\Azure.Core\src\Pipeline\Internal\TelemetryPolicy.cs
Covered lines:8
Uncovered lines:0
Coverable lines:8
Total lines:30
Line coverage:100% (8 of 8)
Covered branches:2
Total branches:2
Branch coverage:100% (2 of 2)

Metrics

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

File(s)

C:\Git\azure-sdk-for-net\sdk\core\Azure.Core\src\Pipeline\Internal\TelemetryPolicy.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System.Runtime.InteropServices;
 5
 6namespace Azure.Core.Pipeline
 7{
 8    internal class TelemetryPolicy : HttpPipelineSynchronousPolicy
 9    {
 10        private readonly string _header;
 11
 6212        public TelemetryPolicy(string componentName, string componentVersion, string? applicationId)
 13        {
 6214            var platformInformation = $"({RuntimeInformation.FrameworkDescription}; {RuntimeInformation.OSDescription})"
 6215            if (applicationId != null)
 16            {
 417                _header = $"{applicationId} azsdk-net-{componentName}/{componentVersion} {platformInformation}";
 18            }
 19            else
 20            {
 5821                _header = $"azsdk-net-{componentName}/{componentVersion} {platformInformation}";
 22            }
 5823        }
 24
 25        public override void OnSendingRequest(HttpMessage message)
 26        {
 164227            message.Request.Headers.Add(HttpHeader.Names.UserAgent, _header);
 164228        }
 29    }
 30}

Methods/Properties

.ctor(...)
OnSendingRequest(...)