Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullReferenceException ApmErrorLogger/GenerateApmStackTrace #1309

Closed
aheubusch opened this issue May 26, 2021 · 1 comment · Fixed by #1311
Closed

NullReferenceException ApmErrorLogger/GenerateApmStackTrace #1309

aheubusch opened this issue May 26, 2021 · 1 comment · Fixed by #1311
Assignees
Labels
agent-dotnet bug Something isn't working

Comments

@aheubusch
Copy link
Contributor

APM Agent version

Elastic.Apm 1.9.0
Elastic.Apm.Extensions.Hosting 1.9.0
Elastic.Apm.Extensions.Logging 1.9.0

Environment

.NET Core 3.1

Describe the bug

ApmErrorLogger passes a null logger to StacktraceHelper.GenerateApmStackTrace (second arg)

errorLog.StackTrace = StacktraceHelper.GenerateApmStackTrace(exception, null, "CaptureErrorLogsAsApmError",
apmAgent.ConfigurationReader, apmAgent.Components.ApmServerInfo);

which then causes a NullReferenceException. Several try/catch keep the exception from reaching user code though.
logger.Trace()?.Log("transform stack frames");

To Reproduce

public static void Main()
{
    var host = Host
        .CreateDefaultBuilder()
        .ConfigureLogging(logging => logging.ClearProviders())
        .UseElasticApm()
        .Build();

    var logger = (ILogger)host.Services.GetService(typeof(ILogger<object>));
    logger.LogError(new Exception(), "error log with exception");
}
@gregkalapos
Copy link
Contributor

😱

Thanks for reporting it - super useful summary 👍

Opened #1311 to fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agent-dotnet bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants