Kibana version :
7.13.4
Elasticsearch version :
7.13.4
APM Agent language and version :
C#, 1.11.1
Original install method (e.g. download page, yum, deb, from source, etc.) and version :
Nuget package
Description of the problem including expected versus actual behavior. Please include screenshots (if relevant) :
Hi,
I have a .net core(3.1) application which essentially is a background service running as a windows service. I'm implementing the "BackgroundService" from .net similar to the example in the following link: Background tasks with hosted services in ASP.NET Core | Microsoft Docs
I'm configuring the apm agent by using ".UseAllElasticApm()" on the hosted service and "UseElasticApm" on the Redis connection that I have.
My issue is that I'm getting an exception when my service tries stop by calling
await base.StopAsync(cancellationToken);
The error is: "WARN Elastic.Apm {PayloadSenderV2} Exception during execution of the filter on transaction
System.NullReferenceException: Object reference not set to an instance of an object.
at Elastic.Apm.Filters.ErrorContextSanitizerFilter.Filter(IError error)
at Elastic.Apm.Report.PayloadSenderV2.TryExecuteFilter[T](List`1 filters, T item)"
Steps to reproduce :
Run a dotnet background service
Call base.StopAsync()
Errors in browser console (if relevant) :
Provide logs and/or server output (if relevant) :
forloop
(Russ Cam)
October 25, 2021, 4:06am
2
Hi @diosifidis . The following error
diosifidis:
The error is: "WARN Elastic.Apm {PayloadSenderV2} Exception during execution of the filter on transaction
System.NullReferenceException: Object reference not set to an instance of an object.
at Elastic.Apm.Filters.ErrorContextSanitizerFilter.Filter(IError error)
at Elastic.Apm.Report.PayloadSenderV2.TryExecuteFilter[T](List`1 filters, T item)"
I believe is the same issue as
opened 02:37PM - 01 Oct 21 UTC
closed 04:55AM - 06 Oct 21 UTC
bug
agent-dotnet
### APM Agent version
1.11.1
### Environment
APM server 7.14
**.NET Fram… ework/Core name and version**
NET Core 3.1.413
**Application Target Framework(s)**
netcoreapp3.1
### Describe the bug
PayloadSenderV2 throws exception when Asp.net core HealthChecks is checking a dependency which fails.
### To Reproduce
I noticed a Warning in log when Health Check in my application is testing a failed dependency which is down and health check is reporting an error. I've tried to reproduce this issue in smaller sample but so far with no luck.
#### Expected behavior
No Exception
#### Actual behavior
```
[11:41:45 WRN] {PayloadSenderV2} Exception during execution of the filter on transaction
System.NullReferenceException: Object reference not set to an instance of an object.
at Elastic.Apm.Filters.ErrorContextSanitizerFilter.Filter(IError error)
at Elastic.Apm.Report.PayloadSenderV2.TryExecuteFilter[T](List`1 filters, T item)
```
Error value which is received doesn't have Context filled. I think this may be the case for health check requests that they are not normal Http Request but they are executed from healthcheck-ui automatically every x seconds, but this is only my guess.
```
{Error{Id: 71062bdb2bbf2fcf2f5ce5307c818e7c, TraceId: fce5e93fe1dcc643b1b69e1172abd2ae, ParentId: 9a8d3663dd710241, TransactionId: 9a8d3663dd710241}}
ConfigSnapshot: {Elastic.Apm.Config.ConfigSnapshotFromReader}
Context: null
Culprit: "Failed outgoing HTTP request"
Exception: {CapturedException{Type: System.Net.Http.HttpRequestException, Message: No connection could be made because the target machine actively refused it., Handled: False, Code: null}}
Id: "71062bdb2bbf2fcf2f5ce5307c818e7c"
Log: null
ParentId: "9a8d3663dd710241"
Timestamp: 1633085851482142
TraceId: "fce5e93fe1dcc643b1b69e1172abd2ae"
Transaction: {TransactionData{IsSampled: False, Type: request}}
TransactionId: "9a8d3663dd710241"
```
```
https://github.com/elastic/apm-agent-dotnet/blob/1.11/src/Elastic.Apm/Filters/ErrorContextSanitizerFilter.cs
internal class ErrorContextSanitizerFilter
{
public IError Filter(IError error)
{
if (error is Error realError)
{
// I suspect this realError.Context throws exception as it was null
if (realError.Context.Request?.Headers != null && realError.ConfigSnapshot != null)
{
foreach (var key in realError.Context?.Request?.Headers?.Keys.ToList())
{
if (WildcardMatcher.IsAnyMatch(realError.ConfigSnapshot.SanitizeFieldNames, key))
realError.Context.Request.Headers[key] = Consts.Redacted;
}
}
}
return error;
}
}
```
Could you give some guidance how I could track this error?
This has been addressed in
elastic:master
← russcam:bug/1503
opened 06:46AM - 05 Oct 21 UTC
Fixes elastic/apm-agent-dotnet#1503
and will be in the next release.
system
(system)
Closed
November 15, 2021, 12:07am
3
This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.