NewRelic
Public Types | Static Public Member Functions | Public Attributes | Protected Attributes | Static Protected Attributes | List of all members
NewRelicAgent Class Reference
Inheritance diagram for NewRelicAgent:

Public Types

enum  FeatureFlag : int {
  InteractionTracing = 1 << 1, SwiftInteractionTracing = 1 << 2, CrashReporting = 1 << 3, URLSessionInstrumentation = 1 << 4,
  HttpResponseBodyCapture = 1 << 5, AnalyticsEvents = 1 << 6, ExperimentalNetworkingInstrumentation = 1 << 13
}
 FeatureFlag is used internally by the agents More...
 
enum  NetworkFailureCode : int {
  Unknown = -1, Cancelled = -999, BadURL = -1000, TimedOut = -1001,
  UnsupportedURL = -1002, CannotFindHost = -1003, CannotConnectToHost = -1004, DataLengthExceedsMaximum = -1103,
  NetworkConnectionLost = -1005, DNSLookupFailed = -1006, HTTPTooManyRedirects = -1007, ResourceUnavailable = -1008,
  NotConnectedToInternet = -1009, RedirectToNonExistentLocation = -1010, BadServerResponse = -1011, UserCancelledAuthentication = -1012,
  UserAuthenticationRequired = -1013, ZeroByteResource = -1014, CannotDecodeRawData = -1015, CannotDecodeContentData = -1016,
  CannotParseResponse = -1017, InternationalRoamingOff = -1018, CallIsActive = -1019, DataNotAllowed = -1020,
  RequestBodyStreamExhausted = -1021, FileDoesNotExist = -1100, FileIsDirectory = -1101, NoPermissionsToReadFile = -1102,
  SecureConnectionFailed = -1200, ServerCertificateHasBadDate = -1201, ServerCertificateUntrusted = -1202, ServerCertificateHasUnknownRoot = -1203,
  ServerCertificateNotYetValid = -1204, ClientCertificateRejected = -1205, ClientCertificateRequired = -1206, CannotLoadFromNetwork = -2000,
  CannotCreateFile = -3000, CannotOpenFile = -3001, CannotCloseFile = -3002, CannotWriteToFile = -3003,
  CannotRemoveFile = -3004, CannotMoveFile = -3005, DownloadDecodingFailedMidStream = -3006, DownloadDecodingFailedToComplete = -3007
}
 Network failure codes are used to map networking errors when using noticeNetworkFailure(...) used the value that best describes your network error More...
 
enum  AgentLogLevel : int {
  NONE = 0, ERROR = 1, WARNING = 2, INFO = 3,
  VERBOSE = 4, DEBUG = 5
}
 used internally
 
enum  NRTraceType : int {
  None = 0, ViewLoading, Layout, Database,
  Images, Json, Network
}
 
enum  MetricUnit : int {
  PERCENT, BYTES, SECONDS, BYTES_PER_SECOND,
  OPERATIONS
}
 

Static Public Member Functions

static void CrashNow (string message)
 Used to test New Relic crash reporting. Calling this message will cause an immediate crash More...
 
static void EnableFeatures (int features)
 used internally More...
 
static void DisableFeatures (int features)
 used internally More...
 
static void EnableCrashReporting (bool enabled)
 used internally More...
 
static void SetApplicationVersion (string version)
 used internally More...
 
static void SetApplicationBuild (string buildNumber)
 used internally More...
 
static string CurrentSessionId ()
 returns the current session idetifier used by New Relic. More...
 
static string StartInteractionWithName (string name)
 This method will start an interaction trace using name as the name shown in New Relic. The interaction will record all instrumented methods until a timout occurs or More...
 
static void StopCurrentInteraction (string interactionIdentifier)
 This method will stop the Interaction trace associated with interactionIdentifier which is returned by StartInteractionWithName() It's not necessary to call this method to complete an interaction trace. (An interaction trace will intelligently complete on its own.) However, use this method if you want a more discrete interaction period. More...
 
static void StartTracingMethod (String methodName, string className, Timer timer, NRTraceType category)
 This method adds a new method trace to the currently running Interaction Trace. If no interaction trace is running, nothing will happen. This method should be called at the beginning of the method you wish to instrument. The timer parameter is a New Relic defined object that only needs to be created just prior to calling this method and must stay in memory until it is passed to the endTracingMethodWithTimer() method call at the end of the custom instrumented method. More...
 
static void EndTracingMethodWithTimer (Timer timer)
 This method should be called at the end of any method you instrument with startTracingMethod(). Failure to do so will result in an unhealthy trace timeout of the currently running interaction. If no interaction is running this method is a no-op. More...
 
static void RecordMetricWithName (string name, string category)
 This method will record a metric without units and a value of 1 More...
 
static void RecordMetricWithName (string name, string category, double value)
 This method will record a metric without units More...
 
static void RecordMetricWithName (string name, string category, double value, MetricUnit valueUnits)
 This method adds on the last with the addition of setting the value Unit The unit names may be mixed case and must consist strictly of alphabetical characters as well as the _, % and / symbols. Case is preserved. Recommendation: Use uncapitalized words, spelled out in full. For example, use second not Sec. While there are a few predefined units please feel free to add your own by typecasting an NSString. More...
 
static void RecordMetricWithName (string name, string category, double value, MetricUnit valueUnits, MetricUnit countUnits)
 This method adds on the last with the addition of setting the optional parameter countUnits. The unit names may be mixed case and must consist strictly of alphabetical characters as well as the _, % and / symbols. Case is preserved. Recommendation: Use uncapitalized words, spelled out in full. For example, use second not Sec. While there are a few predefined units please feel free to add your own by typecasting an NSString. More...
 
static void NoticeNetworkRequest (string URL, string httpMethod, Timer timer, Dictionary< string, object > headers, int httpStatusCode, int bytesSent, int bytesReceived, byte[] responseData, Dictionary< string, object > parameters)
 New Relic will track the URL, response time, status code, and data send/received. If the response headers dictionary contains a X-NewRelic-AppData header, New Relic will track the association between the mobile app and the web server and display the correlation and the server vs. network vs. queue time in the New Relic UI. More...
 
static void NoticeNetworkFailure (string url, string httpMethod, Timer timer, NewRelicAgent.NetworkFailureCode failureCode, string message)
 records a failed network transaction. More...
 
static bool RecordEvent (string name, Dictionary< string, object > attributes)
 Records an Insights Event More...
 
static void SetMaxEventPoolSize (uint size)
 Sets the size of the max event pool. default 1000 events at a time. if more events are recorded before maxEventBufferTime seconds elapsed, events will be sampled using a Reservoir Sampling algorithm. If maxEventBufferTime seconds elapse, the existing event buffer will be transmitted and then emptied. More...
 
static void SetMaxEventBufferTime (uint seconds)
 Change the maximum length of time before the SDK sends queued events to New Relic. the default timeout is 600 seconds. If the user keeps your app open for longer than that, any stored events will be transmitted and the timer resets. More...
 
static bool SetAttribute (string name, string value)
 records an attribute that will be added to all events in this app install More...
 
static bool SetAttribute (string name, double value)
 records an attribute that will be added to all events in this app install More...
 
static bool IncrementAttribute (string name)
 increments an attribute that will be added to all events in this app install if no attribute exists one will be created with value of 1 More...
 
static bool IncrementAttribute (string name, double amount)
 increments an attribute that will be added to all events in this app install if no attribute exists one will be created with value of amount More...
 
static bool RemoveAttribute (string name)
 Removes the attribute with name More...
 
static bool RemoveAllAttributes ()
 Removes all attributes. More...
 

Public Attributes

string iOSApplicationToken = "<NewRelicAppToken>"
 The application token provided by NewRelic Set through the Unity object interface More...
 
string androidApplicationToken = "<NewRelicAppToken>"
 
string applicationVersion = ""
 The application version. Default to value set by Unity To override the default value set this field through the Unity object interface. More...
 
string applicationBuild = ""
 The application build. default to value set by Unity To override the default value set this field through the Unity object interface. More...
 
AgentLogLevel logLevel = AgentLogLevel.ERROR
 The detail of logging provided by New Relic for internal operations. defaults to ERROR More...
 
Boolean usingSSL = true
 Enable or disable SSL for New Relic data posts defaults to true More...
 
Boolean crashReporting = true
 Enable or disable New Relic crash reporting defaults to true More...
 
Boolean httpResponseBodyCapture = true
 enable or disable http response body capture. New Relic will capture a portion of http response bodies to allow for http error debugging. defaults to true More...
 
Boolean analyticsEvents = true
 enable or disable Insights events, allows for custom events to be recorded as well defaults to true (only settable in Android) More...
 

Protected Attributes

NewRelic agentInstance = null
 
String interactionId = null
 

Static Protected Attributes

static NewRelicAgent instance = null
 

Member Enumeration Documentation

enum NewRelicAgent.FeatureFlag : int
strong

FeatureFlag is used internally by the agents

Network failure codes are used to map networking errors when using noticeNetworkFailure(...) used the value that best describes your network error

Member Function Documentation

static void NewRelicAgent.CrashNow ( string  message)
inlinestatic

Used to test New Relic crash reporting. Calling this message will cause an immediate crash

Parameters
messageException error message
static string NewRelicAgent.CurrentSessionId ( )
inlinestatic

returns the current session idetifier used by New Relic.

Returns
The session identifier.
static void NewRelicAgent.DisableFeatures ( int  features)
inlinestatic

used internally

Parameters
featuresa bit-wise ored value indicating which features should be disabled
static void NewRelicAgent.EnableCrashReporting ( bool  enabled)
inlinestatic

used internally

Parameters
enabledIf set to true enabled.
static void NewRelicAgent.EnableFeatures ( int  features)
inlinestatic

used internally

Parameters
featuresa bit-wise ored value indicating which features should be enabled
static void NewRelicAgent.EndTracingMethodWithTimer ( Timer  timer)
inlinestatic

This method should be called at the end of any method you instrument with startTracingMethod(). Failure to do so will result in an unhealthy trace timeout of the currently running interaction. If no interaction is running this method is a no-op.

Parameters
timerThe timer used in the StartTracingMethod()
static bool NewRelicAgent.IncrementAttribute ( string  name)
inlinestatic

increments an attribute that will be added to all events in this app install if no attribute exists one will be created with value of 1

Returns
true, if attribute was set, false otherwise.
Parameters
namethe attribute name
static bool NewRelicAgent.IncrementAttribute ( string  name,
double  amount 
)
inlinestatic

increments an attribute that will be added to all events in this app install if no attribute exists one will be created with value of amount

Returns
true, if attribute was incremented, false otherwise.
Parameters
nameName.
amountAmount.
static void NewRelicAgent.NoticeNetworkFailure ( string  url,
string  httpMethod,
Timer  timer,
NewRelicAgent.NetworkFailureCode  failureCode,
string  message 
)
inlinestatic

records a failed network transaction.

Parameters
urlthe URL of the request
httpMethodHTTP method
timera timer created when the network request was started
failureCodeFailure code defined from NewRelicAgent.NetworkFailureCode list
messageoptional descriptive message, unused in iOS
static void NewRelicAgent.NoticeNetworkRequest ( string  URL,
string  httpMethod,
Timer  timer,
Dictionary< string, object >  headers,
int  httpStatusCode,
int  bytesSent,
int  bytesReceived,
byte[]  responseData,
Dictionary< string, object >  parameters 
)
inlinestatic

New Relic will track the URL, response time, status code, and data send/received. If the response headers dictionary contains a X-NewRelic-AppData header, New Relic will track the association between the mobile app and the web server and display the correlation and the server vs. network vs. queue time in the New Relic UI.

If the HTTP status code indicates an error (400 and above) New Relic will also track this request as a server error, optionally capturing the response type and encoding from the headers dictionary and the response body data as a

Parameters
URLthe URL of the request
httpMethodHTTP method
timerA timer created when the network request started
headersHeaders dictionary (optional)
httpStatusCodehttp response code
bytesSentBytes sent.
bytesReceivedBytes received.
responseDataResponse data.
parametersunused
static bool NewRelicAgent.RecordEvent ( string  name,
Dictionary< string, object >  attributes 
)
inlinestatic

Records an Insights Event

Returns
true, if event was recorded, false otherwise.
Parameters
nameName of the event. Will be stored in the 'category' attribute of Mobile events in New Relic Insights
attributesdictionary of attributes associated with the event. Attributes must be a string or numeric value.
static void NewRelicAgent.RecordMetricWithName ( string  name,
string  category 
)
inlinestatic

This method will record a metric without units and a value of 1

Parameters
namethe metric name.
categorya descriptive category
static void NewRelicAgent.RecordMetricWithName ( string  name,
string  category,
double  value 
)
inlinestatic

This method will record a metric without units

Parameters
namethe metric name
categorya descriptive category
valuethe value to record.
static void NewRelicAgent.RecordMetricWithName ( string  name,
string  category,
double  value,
MetricUnit  valueUnits 
)
inlinestatic

This method adds on the last with the addition of setting the value Unit The unit names may be mixed case and must consist strictly of alphabetical characters as well as the _, % and / symbols. Case is preserved. Recommendation: Use uncapitalized words, spelled out in full. For example, use second not Sec. While there are a few predefined units please feel free to add your own by typecasting an NSString.

Parameters
namethe metric name
categorya descriptive category
valuethe value to record.
valueUnitsthe units of value
static void NewRelicAgent.RecordMetricWithName ( string  name,
string  category,
double  value,
MetricUnit  valueUnits,
MetricUnit  countUnits 
)
inlinestatic

This method adds on the last with the addition of setting the optional parameter countUnits. The unit names may be mixed case and must consist strictly of alphabetical characters as well as the _, % and / symbols. Case is preserved. Recommendation: Use uncapitalized words, spelled out in full. For example, use second not Sec. While there are a few predefined units please feel free to add your own by typecasting an NSString.

Parameters
namethe metric name
categorya descriptive category
valuethe value to record.
valueUnitsthe units of value
countUnitsrepresents the unit of the metric
static bool NewRelicAgent.RemoveAllAttributes ( )
inlinestatic

Removes all attributes.

Returns
true, if all attributes was removed, false otherwise.
static bool NewRelicAgent.RemoveAttribute ( string  name)
inlinestatic

Removes the attribute with name

Returns
true, if attribute was removed, false otherwise.
Parameters
nameName.
static void NewRelicAgent.SetApplicationBuild ( string  buildNumber)
inlinestatic

used internally

Parameters
buildNumberwill replace the default build number New Relic will report for this app
static void NewRelicAgent.SetApplicationVersion ( string  version)
inlinestatic

used internally

Parameters
versionwill replace the default version New Relic will report for this app
static bool NewRelicAgent.SetAttribute ( string  name,
string  value 
)
inlinestatic

records an attribute that will be added to all events in this app install

Returns
true, if attribute was set, false otherwise.
Parameters
namethe attribute name
valuethe attribute value
static bool NewRelicAgent.SetAttribute ( string  name,
double  value 
)
inlinestatic

records an attribute that will be added to all events in this app install

Returns
true, if attribute was set, false otherwise.
Parameters
namethe attribute name
valuethe attribute value
static void NewRelicAgent.SetMaxEventBufferTime ( uint  seconds)
inlinestatic

Change the maximum length of time before the SDK sends queued events to New Relic. the default timeout is 600 seconds. If the user keeps your app open for longer than that, any stored events will be transmitted and the timer resets.

Parameters
secondsmax event buffer time
static void NewRelicAgent.SetMaxEventPoolSize ( uint  size)
inlinestatic

Sets the size of the max event pool. default 1000 events at a time. if more events are recorded before maxEventBufferTime seconds elapsed, events will be sampled using a Reservoir Sampling algorithm. If maxEventBufferTime seconds elapse, the existing event buffer will be transmitted and then emptied.

Parameters
sizemax even pool size.
static string NewRelicAgent.StartInteractionWithName ( string  name)
inlinestatic

This method will start an interaction trace using name as the name shown in New Relic. The interaction will record all instrumented methods until a timout occurs or

stopCurrentInteraction is called.

Returns
Returns an interaction identifier that can be passed to
stopCurrentInteraction()
which will stop the current interaction if it hasn't timed out.
Parameters
nameName.
static void NewRelicAgent.StartTracingMethod ( String  methodName,
string  className,
Timer  timer,
NRTraceType  category 
)
inlinestatic

This method adds a new method trace to the currently running Interaction Trace. If no interaction trace is running, nothing will happen. This method should be called at the beginning of the method you wish to instrument. The timer parameter is a New Relic defined object that only needs to be created just prior to calling this method and must stay in memory until it is passed to the endTracingMethodWithTimer() method call at the end of the custom instrumented method.

Parameters
methodNamethe method name we are tracing
classNamethe class owning the method
timertimer object used to time the method
categorya category defined by NRTraceType
static void NewRelicAgent.StopCurrentInteraction ( string  interactionIdentifier)
inlinestatic

This method will stop the Interaction trace associated with interactionIdentifier which is returned by StartInteractionWithName() It's not necessary to call this method to complete an interaction trace. (An interaction trace will intelligently complete on its own.) However, use this method if you want a more discrete interaction period.

Parameters
interactionIdentifieran identifier generated by StartInteractionWithName()

Member Data Documentation

Boolean NewRelicAgent.analyticsEvents = true

enable or disable Insights events, allows for custom events to be recorded as well defaults to true (only settable in Android)

string NewRelicAgent.applicationBuild = ""

The application build. default to value set by Unity To override the default value set this field through the Unity object interface.

string NewRelicAgent.applicationVersion = ""

The application version. Default to value set by Unity To override the default value set this field through the Unity object interface.

Boolean NewRelicAgent.crashReporting = true

Enable or disable New Relic crash reporting defaults to true

Boolean NewRelicAgent.httpResponseBodyCapture = true

enable or disable http response body capture. New Relic will capture a portion of http response bodies to allow for http error debugging. defaults to true

string NewRelicAgent.iOSApplicationToken = "<NewRelicAppToken>"

The application token provided by NewRelic Set through the Unity object interface

AgentLogLevel NewRelicAgent.logLevel = AgentLogLevel.ERROR

The detail of logging provided by New Relic for internal operations. defaults to ERROR

Boolean NewRelicAgent.usingSSL = true

Enable or disable SSL for New Relic data posts defaults to true


The documentation for this class was generated from the following file: