< Summary

Class:Azure.Core.Pipeline.DiagnosticScopeFactory
Assembly:Azure.Analytics.Synapse.Spark
File(s):C:\Git\azure-sdk-for-net\sdk\core\Azure.Core\src\Shared\DiagnosticScopeFactory.cs
Covered lines:12
Uncovered lines:1
Coverable lines:13
Total lines:46
Line coverage:92.3% (12 of 13)
Covered branches:5
Total branches:6
Branch coverage:83.3% (5 of 6)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-100%100%
get_IsActivityEnabled()-100%100%
CreateScope(...)-83.33%75%

File(s)

C:\Git\azure-sdk-for-net\sdk\core\Azure.Core\src\Shared\DiagnosticScopeFactory.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using System.Diagnostics;
 6using System.Reflection;
 7
 8#nullable enable
 9
 10namespace Azure.Core.Pipeline
 11{
 12#pragma warning disable CA1001 // Types that own disposable fields should be disposable
 13    internal class DiagnosticScopeFactory
 14#pragma warning restore CA1001 // Types that own disposable fields should be disposable
 15    {
 16        private readonly string? _resourceProviderNamespace;
 17        private readonly DiagnosticListener? _source;
 18
 1619        public DiagnosticScopeFactory(string clientNamespace, string? resourceProviderNamespace, bool isActivityEnabled)
 20        {
 1621            _resourceProviderNamespace = resourceProviderNamespace;
 1622            IsActivityEnabled = isActivityEnabled;
 1623            if (IsActivityEnabled)
 24            {
 1625                _source = new DiagnosticListener(clientNamespace);
 26            }
 1627        }
 28
 1629        public bool IsActivityEnabled { get; }
 30
 31        public DiagnosticScope CreateScope(string name)
 32        {
 16833            if (_source == null)
 34            {
 035                return default;
 36            }
 16837            var scope = new DiagnosticScope(name, _source);
 38
 16839            if (_resourceProviderNamespace != null)
 40            {
 16841                scope.AddAttribute("az.namespace", _resourceProviderNamespace);
 42            }
 16843            return scope;
 44        }
 45    }
 46}