• /
  • ログイン
  • 無料アカウント

NoticeError (.NET agent API)

Syntax

NewRelic.Api.Agent.NewRelic.NoticeError(exception $exception[, IDictionary $attributes])
NewRelic.Api.Agent.NewRelic.NoticeError(string $error_message, IDictionary $attributes)
NewRelic.Api.Agent.NewRelic.NoticeError(string $error_message, IDictionary $attributes, bool $is_expected)

Notice an error and report to New Relic, along with optional custom attributes.

Requirements

Compatible with all agent versions.

Compatible with all app types.

Description

Notice an error and report it to New Relic along with optional custom attributes. For each transaction, the agent only retains the exception and attributes from the first call to NoticeError(). You can pass an actual exception, or pass a string to capture an arbitrary error message.

If this method is invoked within a transaction, the agent reports the exception within the parent transaction. If it is invoked outside of a transaction, the agent creates an error trace and categorizes the error in the New Relic UI as a NewRelic.Api.Agent.NoticeError API Call. If invoked outside of a transaction, the NoticeError call will not contribute to the error rate of an application.

ヒント

The agent adds the attributes only to the traced error, and does not send them to New Relic. To add custom attributes, see AddCustomParameter().

ヒント

For an overview of error configuration in APM, see Manage errors in APM.

Parameters

Parameter

Description

NewRelic.Api.Agent.NewRelic.NoticeError(exception $exception[, IDictionary $attributes])

$exception

exception

Required. The exception you want to instrument. Only the first 10,000 characters from the stack trace are retained.

$attributes

IDictionary

Optional. Specify key/value pairs of attributes to annotate the error message.

NewRelic.Api.Agent.NewRelic.NoticeError(string $error_message, IDictionary $attributes)

$error_message

string

Required. Specify a string to report to New Relic as though it's an exception. Only the first 1,000 characters are retained.

$attributes

IDictionary

Required (can be null). Specify key/value pairs of attributes to annotate the error message. To send no attributes, pass null.

NewRelic.Api.Agent.NewRelic.NoticeError(string $error_message, IDictionary $attributes, bool $is_expected)

$error_message

string

Required. Specify a string to report to New Relic as though it's an exception. Only the first 1,000 characters are retained.

$attributes

IDictionary

Required (can be null). Specify key/value pairs of attributes to annotate the error message. To send no attributes, pass null.

$is_expected

bool

Mark error as expected so that it won't affect Apdex score and error rate.

Examples

Pass an exception without custom attributes

try
{
var ImNotABool = "43";
bool.Parse(ImNotABool);
}
catch (Exception ex)
{
NewRelic.Api.Agent.NewRelic.NoticeError(ex);
}

Pass an exception with custom attributes

try
{
var ImNotABool = "43";
bool.Parse(ImNotABool);
}
catch (Exception ex)
{
var errorAttributes = new Dictionary<string, string>() {{"foo", "bar"},{"baz", "luhr"}};
NewRelic.Api.Agent.NewRelic.NoticeError(ex, errorAttributes);
}

Pass an error message string with custom attributes

try
{
var ImNotABool = "43";
bool.Parse(ImNotABool);
}
catch (Exception)
{
var errorAttributes = new Dictionary<string, string>{{"foo", "bar"},{"baz", "luhr"}};
NewRelic.Api.Agent.NewRelic.NoticeError("String error message", errorAttributes);
}

Pass an error message string without custom attributes

try
{
var ImNotABool = "43";
bool.Parse(ImNotABool);
}
catch (Exception)
{
NewRelic.Api.Agent.NewRelic.NoticeError("String error message", null);
}

Pass an error message string and mark it as expected

try
{
var ImNotABool = "43";
bool.Parse(ImNotABool);
}
catch (Exception)
{
NewRelic.Api.Agent.NewRelic.NoticeError("String error message", null, true);
}

その他のヘルプ

さらに支援が必要な場合は、これらのサポートと学習リソースを確認してください:

問題を作成するこのページを編集する
Copyright © 2020 New Relic Inc.