Skip to content

Failed to gather throughput from audit|System.NullReferenceException: Object reference not set to an instance of an object. #4827

@ramonsmits

Description

@ramonsmits

Describe the bug

Description

Log shows this ERROR entry:

2025-02-20 12:28:42.5872|30|Error|Particular.LicensingComponent.AuditThroughput.AuditThroughputCollectorHostedService|Failed to gather throughput from audit|System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
   at System.Linq.Lookup`2.Create(IEnumerable`1 source, Func`2 keySelector, IEqualityComparer`1 comparer)
   at System.Linq.GroupedEnumerable`2.GetEnumerator()
   at System.Linq.Enumerable.SelectEnumerableIterator`2.ToArray()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.OrderedEnumerable`1.ToList()
   at ServiceControl.CompositeViews.MessageCounting.GetAuditCountsForEndpointApi.ProcessResults(AuditCountsForEndpointContext input, QueryResult`1[] results) in /_/src/ServiceControl/CompositeViews/AuditCounts/GetAuditCountsForEndpointApi.cs:line 34
   at ServiceControl.CompositeViews.Messages.ScatterGatherApi`3.AggregateResults(TIn input, QueryResult`1[] results) in /_/src/ServiceControl/CompositeViews/Messages/ScatterGatherApi.cs:line 77
   at ServiceControl.CompositeViews.Messages.ScatterGatherApi`3.Execute(TIn input, String pathAndQuery) in /_/src/ServiceControl/CompositeViews/Messages/ScatterGatherApi.cs:line 63
   at ServiceControl.Infrastructure.Api.AuditCountApi.GetEndpointAuditCounts(String endpoint, CancellationToken token) in /_/src/ServiceControl/Infrastructure/Api/AuditCountApi.cs:line 14
   at Particular.LicensingComponent.AuditThroughput.AuditQuery.GetAuditCountForEndpoint(String endpointUrlName, CancellationToken cancellationToken) in /_/src/Particular.LicensingComponent/AuditThroughput/AuditQuery.cs:line 39
   at Particular.LicensingComponent.AuditThroughput.AuditThroughputCollectorHostedService.GatherThroughput(CancellationToken cancellationToken) in /_/src/Particular.LicensingComponent/AuditThroughput/AuditThroughputCollectorHostedService.cs:line 75
   at Particular.LicensingComponent.AuditThroughput.AuditThroughputCollectorHostedService.ExecuteAsync(CancellationToken cancellationToken) in /_/src/Particular.LicensingComponent/AuditThroughput/AuditThroughputCollectorHostedService.cs:line 35

Logs also show this as ERROR:

2025-02-20 12:25:57.3494|21|Error|Particular.LicensingComponent.BrokerThroughput.BrokerThroughputCollectorHostedService|Could not start BrokerThroughputCollectorHostedService, due to initialisation errors:
TenantId is a required setting
ClientId is a required setting
ClientSecret is a required setting

It feels that the log level is off for this one. This shouldn't be logged as ERROR but as INFO, maybe a WARN.

Expected behavior

No NullReferenceException should ever be logged and log level for Could not start BrokerThroughputCollectorHostedService is too high.

Actual behavior

NullReferenceException causing an Error log entry, and other Error log entry.

Versions

Please list the version of the relevant packages or applications in which the bug exists.

6.3.2

Steps to reproduce

x

Relevant log output

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions