Syntax
Public interface ISpan
Provides access to span-specific methods in the New Relic API.
Description
Provides access to span-specific methods in the New Relic .NET agent API. To obtain a reference to ISpan
, use:
- The
CurrentSpan
property onIAgent
(Recommended). - The
CurrentSpan
property onITransaction
.
This section contains descriptions and parameters of ISpan
methods:
Name | Description |
---|---|
Add contextual information from your application to the current span in form of attributes. |
AddCustomAttribute
Adds contextual information about your application to the current span in the form of attributes.
This method requires .NET agent version and .NET agent API version 8.25 or higher.
Syntax
ISpan AddCustomAttribute(string key, object value)
Parameters
Parameter | Description |
---|---|
string | Identifies the information being reported. Also known as the name.
|
object | The value being reported. |
Returns
A reference to the current span.
Usage considerations
For details about supported data types, see the Custom Attributes guide.
Examples
IAgent agent = NewRelic.Api.Agent.NewRelic.GetAgent(); ISpan currentSpan = agent.CurrentSpan;
currentSpan .AddCustomAttribute("customerName","Bob Smith") .AddCustomAttribute("currentAge",31) .AddCustomAttribute("birthday", new DateTime(2000, 02, 14)) .AddCustomAttribute("waitTime", TimeSpan.FromMilliseconds(93842));