• EnglishEspañol日本語한국어Português
  • ログイン今すぐ開始

この機械翻訳は参考用に提供されます。

英語版と翻訳版に矛盾がある場合は、英語版が優先されます。詳細については、このページ を参照してください。

問題を作成する

HTTPリクエストを追跡する

構文

Java

NewRelic.noticeHttpTransaction(string $url, string $httpMethod, int $statusCode, long $startTime, long $endTime, long $bytesSent, long $bytesReceived [, string $responseBody])

コトリン [#kotlin]

NewRelic.noticeHttpTransaction(
url: String?,
httpMethod: String?,
statusCode: Int,
startTimeMs: Long,
endTimeMs: Long,
bytesSent: Long,
bytesReceived: Long,
responseBody: String?
)

説明 [#description]

応答本文も送信するオプションを使用して HTTP トランザクションを記録します。

ネットワーク リクエストが失敗した場合は、 noticeNetworkFailure()を使用して失敗に関する詳細を記録できます。

パラメーター [#parameters]

パラメータ

タイプ

説明

$url

string

必須です。リクエストのURLです。

$httpMethod

string

必要です。GETやPOSTなど、使用するHTTPメソッドです。

$statusCode

int

必須。 HTTP 応答の statusCode ( OKの場合は 200 など)。

$startTime

int

必須。リクエストの開始時刻をエポックからのミリ秒で表したもの。

$endTime

int

必須。リクエストの終了時刻をエポックからのミリ秒で表したもの。

$bytesSent

int

必須です。リクエストで送信されたバイト数です。

$bytesReceived

int

必須です。レスポンスで受信したバイト数。

$responseBody

string

オプションです。HTTP レスポンスのレスポンス ボディです。レスポンス ボディは、HTTP トランザクションがエラーの場合、切り捨てられて HTTP エラー メトリックに含まれます。

[#examples]

HTTP トランザクションを追跡する例を次に示します。

Java [#java]

public class CustomHttpMetricsLogger implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
//collect request start time
long t1 = System.nanoTime();
//get the size of the request body
long requestSize = null == request.body() ? 0 : request.body().contentLength();
//proceed with the request
Response response = chain.proceed(request);
//capture the time when response returns
long t2 = System.nanoTime();
long responseSize = null == response.body() ? 0 : response.body().contentLength();
//tell New Relic to notice this request
NewRelic.noticeHttpTransaction(request.urlString(), request.method(), response.code(), t1, t2, requestSize, responseSize);
//return response for processing
return response;
}
}

コトリン [#kotlin]

class CustomInterceptor : Interceptor {
override fun intercept(chain: Interceptor.Chain): Response {
val t1 = System.nanoTime()
val aRequest: Request = chain.request()
val requestSize: Long = if (null == aRequest.body) 0 else aRequest.body!!.contentLength()
val aResponse = chain.proceed(aRequest)
val t2 = System.nanoTime()
val responseSize: Long = if (null == aResponse.body) 0 else aResponse.body!!.contentLength()
NewRelic.noticeHttpTransaction(aRequest.url.toString(), aRequest.method, aResponse.code, t1, t2, requestSize, responseSize)
return aResponse
}
}

構文

目的-c

+ (void)noticeNetworkRequestForURL:(NSURL*)url
httpMethod:(NSString*)httpMethod
withTimer:(NRTimer*)timer
responseHeaders:(NSDictionary*)headers
statusCode:(NSInteger)httpStatusCode
bytesSent:(NSUInteger)bytesSent
bytesReceived:(NSUInteger)bytesReceived
responseData:(NSData *)responseData
traceHeaders:(NSDictionary<NSString*,NSString*>* _Nullable)traceHeaders
andParams:(NSDictionary * _Nullable)params;

迅速 [#swift]

func noticeNetworkRequest(for: URL, httpMethod: String, with: NRTimer, responseHeaders: [AnyHashable : Any], statusCode: Int, bytesSent: UInt, bytesReceived: UInt, responseData: Data, traceHeaders: [String : String], andParams: [AnyHashable : Any])

説明 [#description]

New Relic は、URL、応答時間、ステータス コード、および送受信されたデータを追跡します。

応答ヘッダーのディクショナリにX-NewRelic-AppDataヘッダーが含まれている場合、New Relic はモバイル アプリとウェブ サーバー間の関連付けを追跡し、New Relic UI はサーバーとネットワークとキュー時間の相関と比較を表示します。

HTTP ステータス コードがエラー (400 以上) を示している場合、New Relic はこのリクエストもエラーとして追跡します。リクエスト ヘッダーの辞書とレスポンス ボディのデータは、New Relic UI でサーバー エラーとしてエンコードされます。

パラメーター [#parameters]

パラメータ

タイプ

説明

$url

NSURL

必須です。リクエストのURLです。

$httpMethod

string

必須。リクエストの HTTP メソッド。

$timer

NRTimer

必須。リクエストの開始と終了をキャプチャするタイマー。

$startTime

double

オプション。リクエストの終了時刻を取得する double。startTimeendTime timerの代わりに使用できます。

$endTime

double

オプション。リクエストの終了時刻をキャプチャする double。( startTimeendTime timerの代わりに使用できます)

$responseHeaders

NSDictionary

必須。サーバー応答で返されるヘッダーのディクショナリ。

$httpStatusCode

NSUInteger

必須。HTTP 応答のステータス コード。

$bytesSent

NSUInteger

必須。リクエスト本文で送信されたバイト数。

$bytesReceived

NSUInteger

必須。応答本文で受信したバイト数。

$responseData

NSData

必須。サーバーから返された応答本文データ。トレースされたサーバー エラーを記録するときに使用されます。

$traceHeaders

NSDictionary

null 可能。分散トレースに使用されます。

$params

NSDictionary

null 可能。未使用。

[#examples]

Objective-C [#obj-c]

HTTP トランザクションを追跡する例を次に示します。

[NewRelic noticeNetworkRequestForURL:[NSURL URLWithString:@"https://www.newrelic.com"] httpMethod:@"GET" withTimer:[[NRTimer alloc] init]
responseHeaders:@{} statusCode:200 bytesSent:1024 bytesReceived:52
responseData:[NSData data] traceHeaders:nil andParams:nil];

開始時刻と終了時刻の例を次に示します。

[NewRelic noticeNetworkRequestForURL:[NSURL URLWithString:@"https://www.newrelic.com"] httpMethod:@"GET" startTime:0.0 endTime:0.1
responseHeaders:@{} statusCode:200 bytesSent:1024 bytesReceived:52
responseData:[NSData data] traceHeaders:nil andParams:nil];

迅速 [#swift]

HTTP トランザクションを追跡する例を次に示します。

NewRelic.noticeNetworkRequest(for: URL(string: "https://www.newrelic.com"), httpMethod: "GET", with: NRTimer(), responseHeaders: [:],
statusCode: 200, bytesSent: 1000, bytesReceived: 1000, responseData: Data(), traceHeaders: nil, andParams: nil)

開始時刻と終了時刻の例を次に示します。

NewRelic.noticeNetworkRequest(for: URL(string: "https://www.newrelic.com"), httpMethod: "GET", startTime: 0.0, endTime: 0.1, responseHeaders: [:],
statusCode: 200, bytesSent: 1000, bytesReceived: 1000, responseData: Data(), traceHeaders: nil, andParams: nil)

構文

noticeHttpTransaction(options: { url: string; method: string; status: number; startTime: number; endTime: number; bytesSent: number; bytesReceived: number; body: string; }) => void

説明 [#description]

HTTP トランザクションを手動で記録します。オプションで応答本文も送信します。

パラメーター [#parameters]

パラメータ

タイプ

説明

url

string

必須です。リクエストのURLです。

method

string

必須。リクエストの HTTP メソッド。

status

number

必要。応答の HTTP ステータス コード。

startTime

number

オプション。エポックからのリクエストの開始時刻 (ミリ秒単位)。startTimeendTime timerの代わりに使用できます。

endTime

number

オプション。エポックからのリクエストの終了時刻 (ミリ秒単位)。startTimeendTime timerの代わりに使用できます。

bytesSent

number

必須です。リクエストで送信されたバイト数です。

bytesReceived

number

必須です。レスポンスで受信したバイト数。

body

string

オプション。HTTP 応答の応答本文。

[#example]

NewRelicCapacitorPlugin.noticeHttpTransaction({
url: "https://fakewebsite.com",
method: "GET",
status: 200,
startTime: Date.now(),
endTime: Date.now(),
bytesSent: 10,
bytesReceived: 2500,
body: "fake http response body 200",
});

構文

noticeHttpTransaction(url: string, method: string, status: number, startTime: number, endTime: number, bytesSent: number, bytesReceived: number, body?: string)

説明 [#description]

New Relic Cordova プラグインは HTTP トランザクションを自動的に収集しますが、HTTP トランザクションを手動で記録する場合は、この方法を使用してください。

パラメーター [#parameters]

パラメータ

タイプ

説明

url

string

必須です。リクエストのURLです。

method

string

必須。リクエストの HTTP メソッド。

status

number

必要。応答の HTTP ステータス コード。

startTime

number

オプション。エポックからのリクエストの開始時刻 (ミリ秒単位)。startTimeendTime timerの代わりに使用できます。

endTime

number

オプション。エポックからのリクエストの終了時刻 (ミリ秒単位)。startTimeendTime timerの代わりに使用できます。

bytesSent

number

必須です。リクエストで送信されたバイト数です。

bytesReceived

number

必須です。レスポンスで受信したバイト数。

body?

string

オプション。HTTP 応答の応答本文。

[#example]

NewRelic.noticeHttpTransaction('https://fakewebsiteurl.com', 'GET', 200, Date.now(), Date.now(), 0, 100000, 'fake request body');

構文

NoticeHttpTransaction(string url, string httpMethod, int statusCode, long startTime,long endTime, long bytesSent, long bytesReceived, string responseBody): void;

説明 [#description]

ネットワークリクエストを手動で追跡します。このメソッドを使用して HTTP トランザクションを記録でき、オプションで応答本文も送信できます。

パラメーター [#parameters]

パラメータ

タイプ

説明

url

string

必須です。リクエストのURLです。

httpmethod

string

必須。リクエストの HTTP メソッド。

statusCode

int

必要。応答の HTTP ステータス コード。

startTime

long

オプション。エポックからのリクエストの開始時刻 (ミリ秒単位)。startTimeendTime timerの代わりに使用できます。

endTime

long

オプション。エポックからのリクエストの終了時刻 (ミリ秒単位)。startTimeendTime timerの代わりに使用できます。

bytesSent

long

必須です。リクエストで送信されたバイト数です。

bytesReceived

long

必須です。レスポンスで受信したバイト数。

responseBody

string

オプション。HTTP 応答の応答本文。

[#example]

CrossNewRelic.Current.NoticeHttpTransaction(
"https://newrelic.com",
"GET",
200,
DateTimeOffset.Now.ToUnixTimeMilliseconds(),
DateTimeOffset.Now.ToUnixTimeMilliseconds() + 100,
0,
1000,
""
);

構文

noticeHttpTransaction(String url,String httpMethod,int statusCode,int startTime,int endTime,int bytesSent,int bytesReceived,Map<String, dynamic>? traceData,{String responseBody = ""}): void;

説明 [#description]

ネットワークリクエストを手動で追跡します。このメソッドを使用して HTTP トランザクションを記録でき、オプションで応答本文も送信できます。

パラメーター [#parameters]

パラメータ

タイプ

説明

url

string

必須です。リクエストのURLです。

httpmethod

string

必須。リクエストの HTTP メソッド。

statusCode

int

必要。応答の HTTP ステータス コード。

startTime

int

オプション。エポックからのリクエストの開始時刻 (ミリ秒単位)。startTimeendTime timerの代わりに使用できます。

endTime

int

オプション。エポックからのリクエストの終了時刻 (ミリ秒単位)。startTimeendTime timerの代わりに使用できます。

bytesSent

int

必須です。リクエストで送信されたバイト数です。

bytesReceived

int

必須です。レスポンスで受信したバイト数。

traceData

dictionary

オプション。トランザクションに関する追加情報を提供するために使用できるキーと値のペアの辞書。

responseBody

string

オプション。HTTP 応答の応答本文。

[#example]

NewrelicMobile.instance.noticeHttpTransaction("https://cb6b02be-a319-4de5-a3b1-361de2564493.mock.pstmn.io/searchpage", "GET",200, 1000, 2000,100,300,null,responseBody: "This is Test Payload");

構文

noticeHttpTransaction(url: string, httpMethod: string, statusCode: number, startTime: number, endTime: number, bytesSent: number, bytesReceived: number, responseBody: string): void;

説明 [#description]

ネットワークリクエストを手動で追跡します。このメソッドを使用して HTTP トランザクションを記録でき、オプションで応答本文も送信できます。

パラメーター [#parameters]

パラメータ

タイプ

説明

url

string

必須です。リクエストのURLです。

httpmethod

string

必須。リクエストの HTTP メソッド。

statusCode

number

必要。応答の HTTP ステータス コード。

startTime

number

オプション。エポックからのリクエストの開始時刻 (ミリ秒単位)。startTimeendTime timerの代わりに使用できます。

endTime

number

オプション。エポックからのリクエストの終了時刻 (ミリ秒単位)。startTimeendTime timerの代わりに使用できます。

bytesSent

number

必須です。リクエストで送信されたバイト数です。

bytesReceived

number

必須です。レスポンスで受信したバイト数。

responseBody

string

オプション。HTTP 応答の応答本文。

[#example]

NewRelic.noticeHttpTransaction('https://github.com', 'GET', 200, Date.now(), Date.now()+1000, 100, 101, "response body");

構文

noticeHttpTransaction(string url, string httpMethod, int statusCode, long startTime,long endTime, long bytesSent, long bytesReceived, string responseBody): void;

説明 [#description]

ネットワークリクエストを手動で追跡します。このメソッドを使用して HTTP トランザクションを記録でき、オプションで応答本文も送信できます。

パラメーター [#parameters]

パラメータ

タイプ

説明

url

string

必須です。リクエストのURLです。

httpmethod

string

必須。リクエストの HTTP メソッド。

statusCode

int

必要。応答の HTTP ステータス コード。

startTime

long

オプション。エポックからのリクエストの開始時刻 (ミリ秒単位)。startTimeendTime timerの代わりに使用できます。

endTime

long

オプション。エポックからのリクエストの終了時刻 (ミリ秒単位)。startTimeendTime timerの代わりに使用できます。

bytesSent

long

必須です。リクエストで送信されたバイト数です。

bytesReceived

long

必須です。レスポンスで受信したバイト数。

responseBody

string

オプション。HTTP 応答の応答本文。

[#example]

NewRelicAgent.NoticeHttpTransaction('https://github.com',
'GET', 200,
DateTimeOffset.Now.ToUnixTimeMilliseconds(),
DateTimeOffset.Now.ToUnixTimeMilliseconds()+1000,
100, 101, "response body",
null);

構文

NoticeHttpTransaction(string url, string httpMethod, int statusCode, long startTime,long endTime, long bytesSent, long bytesReceived, string responseBody): void;

説明 [#description]

ネットワークリクエストを手動で追跡します。このメソッドを使用して HTTP トランザクションを記録でき、オプションで応答本文も送信できます。

パラメーター [#parameters]

パラメータ

タイプ

説明

url

string

必須です。リクエストのURLです。

httpmethod

string

必須。リクエストの HTTP メソッド。

statusCode

int

必要。応答の HTTP ステータス コード。

startTime

long

オプション。エポックからのリクエストの開始時刻 (ミリ秒単位)。startTimeendTime timerの代わりに使用できます。

endTime

long

オプション。エポックからのリクエストの終了時刻 (ミリ秒単位)。startTimeendTime timerの代わりに使用できます。

bytesSent

long

必須です。リクエストで送信されたバイト数です。

bytesReceived

long

必須です。レスポンスで受信したバイト数。

responseBody

string

オプション。HTTP 応答の応答本文。

[#example]

CrossNewRelicClient.Current.NoticeHttpTransaction(
"https://newrelic.com",
"GET",
200,
DateTimeOffset.Now.ToUnixTimeMilliseconds(),
DateTimeOffset.Now.ToUnixTimeMilliseconds() + 100,
0,
1000,
""
);
Copyright © 2024 New Relic株式会社。

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