Skip to content

Commit

Permalink
Merge pull request #5375 from brnhensley/patch-5
Browse files Browse the repository at this point in the history
  • Loading branch information
paperclypse committed Dec 17, 2021
2 parents 5cc7c2c + 2fa1bcc commit 6bb6464
Showing 1 changed file with 45 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ This section contains descriptions and parameters of three ITransaction methods:

### Syntax

```
```cs
void AcceptDistributedHeaders(carrier, getter, transportType)
```

Expand Down Expand Up @@ -173,8 +173,16 @@ void AcceptDistributedHeaders(carrier, getter, transportType)

### Example

```
HttpContext httpContext = HttpContext.Current;IAgent agent = NewRelic.Api.Agent.NewRelic.GetAgent();ITransaction currentTransaction = agent.CurrentTransaction;currentTransaction.AcceptDistributedTraceHeaders(httpContext, Getter, TransportType.HTTP);IEnumerable<string> Getter(HttpContext carrier, string key) { string value = carrier.Request.Headers[key]; return value == null ? null : new string[] { value }; }
```cs
HttpContext httpContext = HttpContext.Current;
IAgent agent = NewRelic.Api.Agent.NewRelic.GetAgent();
ITransaction currentTransaction = agent.CurrentTransaction;
currentTransaction.AcceptDistributedTraceHeaders(httpContext, Getter, TransportType.HTTP);
IEnumerable<string> Getter(HttpContext carrier, string key)
{
string value = carrier.Request.Headers[key];
return value == null ? null : new string[] { value };
}
```

## InsertDistributedTraceHeaders
Expand All @@ -183,7 +191,7 @@ HttpContext httpContext = HttpContext.Current;IAgent agent = NewRelic.Api.Agent.

### Syntax

```
```cs
void InsertDistributedTraceHeaders(carrier, setter)
```

Expand Down Expand Up @@ -235,8 +243,12 @@ void InsertDistributedTraceHeaders(carrier, setter)

### Example

```
HttpWebRequest requestMessage = (HttpWebRequest)WebRequest.Create("https://remote-address");IAgent agent = NewRelic.Api.Agent.NewRelic.GetAgent();ITransaction currentTransaction = agent.CurrentTransaction;var setter = new Action<HttpWebRequest, string, string>((carrier, key, value) => { carrier.Headers?.Set(key, value); });currentTransaction.InsertDistributedTraceHeaders(requestMessage, setter);
```cs
HttpWebRequest requestMessage = (HttpWebRequest)WebRequest.Create("https://remote-address");
IAgent agent = NewRelic.Api.Agent.NewRelic.GetAgent();
ITransaction currentTransaction = agent.CurrentTransaction;
var setter = new Action<HttpWebRequest, string, string>((carrier, key, value) => { carrier.Headers?.Set(key, value); });
currentTransaction.InsertDistributedTraceHeaders(requestMessage, setter);
```

## AcceptDistributedTracePayload [#acceptdistributedtracepayload]
Expand All @@ -248,7 +260,7 @@ Accepts an incoming distributed trace payload from an upstream service. Calling

### Syntax

```
```cs
void AcceptDistributedPayload(payload, transportType)
```

Expand Down Expand Up @@ -305,8 +317,15 @@ void AcceptDistributedPayload(payload, transportType)

### Example

```
//Obtain the information from the request object from the upstream caller.//The method by which this information is obtain is specific to the transport //type being used. For example, in an HttpRequest, this information is//contained in the header.KeyValuePair<string, string> metadata = GetMetaDataFromRequest("requestPayload");IAgent agent = NewRelic.Api.Agent.NewRelic.GetAgent(); ITransaction transaction = agent.CurrentTransaction; transaction.AcceptDistributedTracePayload(metadata.Value, TransportType.Queue);
```cs
//Obtain the information from the request object from the upstream caller.
//The method by which this information is obtain is specific to the transport
//type being used. For example, in an HttpRequest, this information is
//contained in the
header.KeyValuePair<string, string> metadata = GetMetaDataFromRequest("requestPayload");
IAgent agent = NewRelic.Api.Agent.NewRelic.GetAgent();
ITransaction transaction = agent.CurrentTransaction;
transaction.AcceptDistributedTracePayload(metadata.Value, TransportType.Queue);
```

## CreateDistributedTracePayload (obsolete) [#createdistributedtracepayload]
Expand All @@ -317,7 +336,7 @@ Creates a distributed trace payload for inclusion in an outgoing request to a do

### Syntax

```
```cs
IDistributedTracePayload CreateDistributedTracePayload()
```

Expand All @@ -332,8 +351,10 @@ An object that implements `IDistributedTracePayload` which provides access to th

### Example

```
IAgent agent = NewRelic.Api.Agent.NewRelic.GetAgent(); ITransaction transaction = agent.CurrentTransaction; IDistributedTracePayload payload = transaction.CreateDistributedTracePayload();
```cs
IAgent agent = NewRelic.Api.Agent.NewRelic.GetAgent();
ITransaction transaction = agent.CurrentTransaction;
IDistributedTracePayload payload = transaction.CreateDistributedTracePayload();
```

## AddCustomAttribute
Expand All @@ -344,7 +365,7 @@ This method requires .NET agent version and .NET agent API [version 8.24.244.0](

### Syntax

```
```cs
ITransaction AddCustomAttribute(string key, object value)
```

Expand Down Expand Up @@ -403,8 +424,13 @@ For details about supported data types, see the [Custom Attributes Guide](/docs/

### Example

```
IAgent agent = NewRelic.Api.Agent.NewRelic.GetAgent(); ITransaction transaction = agent.CurrentTransaction; transaction .AddCustomAttribute("customerName","Bob Smith") .AddCustomAttribute("currentAge",31) .AddCustomAttribute("birthday", new DateTime(2000, 02, 14)) .AddCustomAttribute("waitTime", TimeSpan.FromMilliseconds(93842));
```cs
IAgent agent = NewRelic.Api.Agent.NewRelic.GetAgent();
ITransaction transaction = agent.CurrentTransaction;
transaction.AddCustomAttribute("customerName","Bob Smith")
.AddCustomAttribute("currentAge",31)
.AddCustomAttribute("birthday", new DateTime(2000, 02, 14))
.AddCustomAttribute("waitTime", TimeSpan.FromMilliseconds(93842));
```

## CurrentSpan
Expand All @@ -413,8 +439,10 @@ Provides access to the currently executing [span](http://docs.newrelic.com/docs/

### Example

```
IAgent agent = NewRelic.Api.Agent.NewRelic.GetAgent(); ITransaction transaction = agent.CurrentTransaction; ISpan = currentSpan = transaction.CurrentSpan;
```cs
IAgent agent = NewRelic.Api.Agent.NewRelic.GetAgent();
ITransaction transaction = agent.CurrentTransaction;
ISpan currentSpan = transaction.CurrentSpan;
```

## Examples
Expand Down

0 comments on commit 6bb6464

Please sign in to comment.