.NET Standard library supporting custom event reporting to the NewRelic Insights product.
Master |
---|
[NewRelicIgnore]
Decorate class properties with this attribute if you would like them to not be included when sending a custom event to NewRelic. Restricted to class properties.
[NewRelicName("FooBar")]
Decorate classes and class properties with this attribute if you would like to rename items when sending a custom event to NewRelic. Restricted to classes and class properties.
public static void LogCustomEvent(string serviceName)
{
new ServiceEvent(serviceName)
{
OperationName = "CustomEvent",
OperationLevel = OperationLevel.System,
OperationSuccess = true
}.SendAsync();
}
public static void LogCustomEvent(string serviceName)
{
new ServiceEvent(serviceName)
{
OperationName = "CustomEvent",
OperationLevel = OperationLevel.System,
OperationSuccess = false,
ErrorMessage = "Something went wrong!"
}.SendAsync();
}
[NewRelicName("ExtraCustomEvent")] // Sent as an ExtraCustomEvent.
public class CustomServiceEvent : BaseEvent
{
public CustomServiceEvent(string serviceName, Guid? requestId = null)
: base(serviceName, requestId) { }
[NewRelicIgnore]
public string Username { get; set; } // Not sent with event.
[NewRelicName("CustomPassword")]
public string Password { get; set; } // Sent as CustomPassword with event.
}