• /
  • EnglishEspañol日本語한국어Português
  • Log inStart now

Track HTTP requests headers

Syntax

Java

NewRelic.addHTTPHeadersTrackingFor(List<String> headers)

Kotlin

NewRelic.addHTTPHeadersTrackingFor(List<String> headers)

Description

This API allows you to add any header field strings to a list that gets recorded as attributes with networking request events. After header fields have been added using this function, if the headers are in a network call they will be included in networking events in the New Relic platform. The Android agent currently automatically captures the following header fields: X-APOLLO-OPERATION-NAME, X-APOLLO-OPERATION-TYPE, and X-APOLLO-OPERATION-ID.

Parameters

Parameter

Type

Description

$headers

List<String>

Required. The HTTP header fields to be added.

Return values

Returns true if added successfully, or false if not.

Examples

Here's an example of adding some HTTP header fields:

Java

List headers = new ArrayList();
headers.add("httpClient");
headers.add("CustomAttribute");
NewRelic.addHTTPHeadersTrackingFor(headers);
// Okhttp3
Request request = new Request.Builder()
.url("https://speed.hetzner.de/1GB.bin")
.addHeader("httpClient","Okhttp3")
.addHeader("CustomAttribute","OutOfMemoryAPI")
.build();

Kotlin

val headers = mutableListOf()
headers.add("httpClient")
headers.add("CustomAttribute")
NewRelic.addHTTPHeadersTrackingFor(headers)
val client = OkHttpClient().newBuilder()
.addInterceptor(new MyInterceptor())
.cache(cache)
.build()
val request: Request = Builder()
.url("https://speed.hetzner.de/1GB.bin")
.addHeader("httpClient", "Okhttp3")
.addHeader("CustomAttribute", "OutOfMemoryAPI")
.build()

Syntax

Objective-c

(void)addHTTPHeaderTrackingFor:(NSArray<NSString*>*_Nonnull)headers;

Swift

func addHTTPHeaderTracking(for: [String])

Description

This API allows you to add any header field strings to a list that gets recorded as attributes with networking request events. After header fields have been added using this function, if the headers are in a network call they will be included in networking events in the New Relic platform. The iOS agent currently automatically captures the following header fields: X-APOLLO-OPERATION-NAME, X-APOLLO-OPERATION-TYPE, and X-APOLLO-OPERATION-ID.

Parameters

Parameter

Type

Description

headers

NSArray<NSString*>*_Nonnull

Required. The HTTP header fields to be added.

Examples

Here's an example of adding some HTTP header fields:

[NewRelic addHTTPHeadersTrackingFor:@[@"Example", @"Example2"]];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"https://www.newrelic.com"]];
NSMutableURLRequest *mutableRequest = [request mutableCopy];
[mutableRequest addValue:@"Test" forHTTPHeaderField:@"Example"];
[mutableRequest addValue:@"Test2" forHTTPHeaderField:@"Example2"];
request = [mutableRequest copy];
[[NSURLSession sharedSession] dataTaskWithRequest:request];
NewRelic.addHTTPHeadersTracking(for:["Example", "Example2"])
var request = URLRequest(url: URL(string:"https://www.newrelic.com")!)
request.addValue("Test", forHTTPHeaderField: "Example")
request.addValue("Test2", forHTTPHeaderField: "Example2")
URLSession.shared.dataTask(with: request)

Syntax

Typescript

NewRelic.addHTTPHeadersTrackingFor((options:{headers: string[]}))

Description

This API allows you to add any header field strings to a list that gets recorded as attributes with networking request events. After header fields have been added using this function, if the headers are in a network call they will be included in networking events in the New Relic platform. The Android agent currently automatically captures the following header fields: X-APOLLO-OPERATION-NAME, X-APOLLO-OPERATION-TYPE, and X-APOLLO-OPERATION-ID.

Parameters

Parameter

Type

Description

$headers

string[]

Required. The HTTP header fields to be added.

Return values

Returns true if added successfully, or false if not.

Examples

Here's an example of adding some HTTP header fields:

Typescript

NewRelicCapacitorPlugin.addHTTPHeadersTrackingFor({headers:["Car","Music"]});

Syntax

Javascript

NewRelic.addHTTPHeadersTrackingFor(headers)

Description

This API allows you to add any header field strings to a list that gets recorded as attributes with networking request events. After header fields have been added using this function, if the headers are in a network call they will be included in networking events in the New Relic platform.

Parameters

Parameter

Type

Description

$headers

string[]

Required. The HTTP header fields to be added.

Return values

Returns true if added successfully, or false if not.

Examples

Here's an example of adding some HTTP header fields:

Javascript

NewRelic.addHTTPHeadersTrackingFor(["Car"]);

Syntax

NewRelic.addHTTPHeadersTrackingFor(List<String> headers)

Description

This API allows you to add any header field strings to a list that gets recorded as attributes with networking request events. After header fields have been added using this function, if the headers are in a network call they will be included in networking events in the New Relic platform.

Parameters

Parameter

Type

Description

$headers

List<String>

Required. The HTTP header fields to be added.

Return values

Returns true if added successfully, or false if not.

Examples

Here's an example of adding some HTTP header fields:

List<string> headers = new List<string>();
headers.Add("Car");
headers.Add("Music");
CrossNewRelic.Current.AddHTTPHeadersTrackingFor(headers);

Syntax

NewRelic.addHTTPHeadersTrackingFor(List<String> headers)

Description

This API allows you to add any header field strings to a list that gets recorded as attributes with networking request events. After header fields have been added using this function, if the headers are in a network call they will be included in networking events in the New Relic platform.

Parameters

Parameter

Type

Description

$headers

List<String>

Required. The HTTP header fields to be added.

Return values

Returns true if added successfully, or false if not.

Examples

Here's an example of adding some HTTP header fields:

NewRelic.addHTTPHeadersTrackingFor(["Car"]);

Syntax

NewRelic.addHTTPHeadersTrackingFor(headers:string[])

Description

This API allows you to add any header field strings to a list that gets recorded as attributes with networking request events. After header fields have been added using this function, if the headers are in a network call they will be included in networking events in the New Relic platform. The Android and agent currently automatically captures the following header fields: X-APOLLO-OPERATION-NAME, X-APOLLO-OPERATION-TYPE, and X-APOLLO-OPERATION-ID.

Parameters

Parameter

Type

Description

$headers

string[]

Required. The HTTP header fields to be added.

Return values

Returns true if added successfully, or false if not.

Examples

Here's an example of adding some HTTP header fields:

NewRelic.addHTTPHeadersTrackingFor(["Car"]);

Syntax

NewRelic.addHTTPHeadersTrackingFor(List<String> headers)

Description

This API allows you to add any header field strings to a list that gets recorded as attributes with networking request events. After header fields have been added using this function, if the headers are in a network call they will be included in networking events in the New Relic platform.

Parameters

Parameter

Type

Description

$headers

List<String>

Required. The HTTP header fields to be added.

Return values

Returns true if added successfully, or false if not.

Examples

Here's an example of adding some HTTP header fields:

Example

List<string> headers = new List<string>();
headers.Add("Car");
headers.Add("Music");
CrossNewRelic.Current.AddHTTPHeadersTrackingFor(headers);
Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.