Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

NewRelic not receiving all NoticeError calls

api
noticeerror

#1

Hi:

I am using NewRelicDotNetAgent_x64 version 8.10.57.0. And I notice if I call NoticeError in my Rest API 3 straight times, it’d only recognize it once on New Relic.

This is my code:

    [HttpGet]
    public string Get(int id)
    {
        NewRelicExceptionLogger.LogTestmessageLimit();
        NewRelicExceptionLogger.LogTestmessageLimit();
        NewRelicExceptionLogger.LogTestmessageLimit();
        return "value";
    }

and NewRelicExceptionLogger just call NewRelic.NoticeError.

public static class NewRelicExceptionLogger //: PropertiesExceptionLogger
{
    public static void LogTestmessageLimit()
    {
        IDictionary<string, string> newRelicDictionary = new Dictionary<string, string>();
        var errorId = Guid.NewGuid();

        newRelicDictionary.Add("ErrorId", errorId.ToString());
        newRelicDictionary.Add("UserId", "12345");
        newRelicDictionary.Add("Client", "WebAppTest");
        NewRelic.Api.Agent.NewRelic.NoticeError("Web App Test Error Msg", newRelicDictionary);
    }
}

I looked in in new relic log and I only see one line of this:

[Info ] 2019-01-18 18:04:34 Instrumenting API method: (Module:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\1cf410a3\56bed1e7\assembly\dl3\442afe96\00a5e5e7_f5a7d401\NewRelic.Api.Agent.dll, AppDomain: /LM/W3SVC/2/ROOT-1-131923082596849949)[NewRelic.Api.Agent]NewRelic.Api.Agent.NewRelic.NoticeError(System.String,System.Collections.Generic.IDictionary`2[System.String,System.String])

Please assist. thanks


#2

Hi @jchen1

Hmmm?

Have you tried it inside a of a Try/ Catch block, there are some usefull api examples on this page
https://docs.newrelic.com/docs/agents/net-agent/net-agent-api/notice-error

I don’t believe it’s being called correct even once? I don’t see “Web App Test Error Msg” in your output log file.

You may also need to use it in conjunction with -> https://docs.newrelic.com/docs/agents/net-agent/net-agent-api/add-custom-parameter.

Nemo


#3

Hi @Nemo:

I try to put the NoticeError message in 3 separate exception blocks but it still only sent 1

         try
        {
            throw new Exception("dummy exception1");
        }
        catch (Exception ex)
        {
            NewRelicExceptionLogger.LogTestmessageLimit();
        }

        try
        {
            throw new Exception("dummy exception2");
        }
        catch (Exception ex)
        {
            NewRelicExceptionLogger.LogTestmessageLimit();
        }

        try
        {
            throw new Exception("dummy exception3");
        }
        catch (Exception ex)
        {
            NewRelicExceptionLogger.LogTestmessageLimit();
        }

#4

@jchen1 -

The agent will capture at most one exception per transaction so you are seeing expected behavior.

See the documentation for that api call here:

For each transaction, the agent only retains the exception and attributes from the first call to NoticeError() .

That part is easy to miss on a first read.

I hope that helps.