• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

icerpc / icerpc-csharp / 19544213315

20 Nov 2025 04:37PM UTC coverage: 83.625% (+0.07%) from 83.553%
19544213315

Pull #4133

github

web-flow
Merge dcb130a99 into 0c2c72855
Pull Request #4133: Target .NET 10

12093 of 14461 relevant lines covered (83.62%)

2967.95 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

64.0
src/IceRpc/Internal/LogTaskExceptionObserver.cs
1
// Copyright (c) ZeroC, Inc.
2

3
using IceRpc.Transports;
4
using Microsoft.Extensions.Logging;
5

6
namespace IceRpc.Internal;
7

8
/// <summary>Implements <see cref="ITaskExceptionObserver" /> using a <see cref="ILogger" />.</summary>
9
internal class LogTaskExceptionObserver : ITaskExceptionObserver
10
{
11
    private readonly ILogger _logger;
12

13
    [System.Diagnostics.CodeAnalysis.SuppressMessage(
14
        "Performance",
15
        "CA1873:Avoid potentially expensive logging",
16
        Justification = "GetLogLevel is a trivial switch on the exception type and is required to categorize the log.")]
17
    public void DispatchFailed(
18
        IncomingRequest request,
19
        TransportConnectionInformation connectionInformation,
20
        Exception exception) =>
21
        _logger.LogDispatchFailed(
1✔
22
            GetLogLevel(exception),
1✔
23
            request.Operation,
1✔
24
            request.Path,
1✔
25
            connectionInformation.RemoteNetworkAddress,
1✔
26
            exception);
1✔
27

28
    [System.Diagnostics.CodeAnalysis.SuppressMessage(
29
        "Performance",
30
        "CA1873:Avoid potentially expensive logging",
31
        Justification = "GetLogLevel is a trivial switch on the exception type and is required to categorize the log.")]
32
    public void DispatchRefused(TransportConnectionInformation connectionInformation, Exception exception) =>
33
        _logger.LogDispatchRefused(GetLogLevel(exception), connectionInformation.RemoteNetworkAddress, exception);
×
34

35
    [System.Diagnostics.CodeAnalysis.SuppressMessage(
36
        "Performance",
37
        "CA1873:Avoid potentially expensive logging",
38
        Justification = "GetLogLevel is a trivial switch on the exception type and is required to categorize the log.")]
39
    public void RequestPayloadContinuationFailed(
40
        OutgoingRequest request,
41
        TransportConnectionInformation connectionInformation,
42
        Exception exception) =>
43
        _logger.LogRequestPayloadContinuationFailed(
×
44
            GetLogLevel(exception),
×
45
            request.Operation,
×
46
            request.ServiceAddress.Path,
×
47
            connectionInformation.RemoteNetworkAddress,
×
48
            exception);
×
49

50
    internal LogTaskExceptionObserver(ILogger logger) => _logger = logger;
18✔
51

52
    private static LogLevel GetLogLevel(Exception exception) =>
53
        exception switch
1✔
54
        {
1✔
55
            // expected during shutdown for example
1✔
56
            OperationCanceledException => LogLevel.Trace,
1✔
57

1✔
58
            // usually expected, e.g. peer aborts connection
1✔
59
            IceRpcException => LogLevel.Debug,
×
60

1✔
61
            // unexpected: from the application code (like a payload read exception) or bug in IceRpc
1✔
62
            _ => LogLevel.Warning
×
63
        };
1✔
64
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc