• /
  • Log in
  • Free account

ISpan

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 on IAgent (Recommended).
  • The CurrentSpan property on ITransaction.

This section contains descriptions and parameters of ISpan methods:

Name

Description

AddCustomAttribute

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

key

string

Identifies the information being reported. Also known as the name.

  • Empty keys are not supported.
  • Keys are limited to 255-bytes. Attributes with keys larger than 255-bytes will be ignored.

value

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));
Create issueEdit page
Copyright © 2022 New Relic Inc.