• 로그인지금 시작하기

사용자의 편의를 위해 제공되는 기계 번역입니다.

영문본과 번역본이 일치하지 않는 경우 영문본이 우선합니다. 보다 자세한 내용은 를 방문하시기 바랍니다.

문제 신고

noticeHttpTransaction(안드로이드 SDK API)

통사론

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

네트워크 요청을 추적합니다.

요구 사항

모든 에이전트 버전과 호환됩니다.

설명

New Relic Android SDK API는 네트워크 요청 및 네트워크 오류를 추적하는 여러 방법을 제공합니다. 응답 본문을 보내는 옵션과 함께 noticeHttpTransaction 을 사용하여 HTTP 트랜잭션을 기록할 수 있습니다.

네트워크 요청이 실패하면 noticeNetworkFailure() 을(를) 사용하여 실패에 대한 세부정보를 기록할 수 있습니다.

New Relic Android SDK API 사용에 대한 일반적인 정보는 사용 가이드 를 참조하세요.

매개변수

매개변수

설명

$url

필수의. 요청의 URL입니다.

$httpMethod

필수의. GET 또는 POST와 같이 사용된 HTTP 메서드입니다.

$statusCode

정수

필수의. HTTP 응답의 statusCode(예: OK 의 경우 200).

$startTime

정수

필수의. Epoch 이후의 요청 시작 시간(밀리초)입니다.

$endTime

정수

필수의. Epoch 이후 요청의 종료 시간(밀리초)입니다.

$bytesSent

정수

필수의. 요청에서 보낸 바이트 수입니다.

$bytesReceived

정수

필수의. 응답에서 수신된 바이트 수입니다.

$responseBody

선택 과목. HTTP 응답의 응답 본문입니다. HTTP 트랜잭션이 오류인 경우 응답 본문이 잘리고 HTTP 오류 메트릭에 포함됩니다.

HTTP 트랜잭션 기록

HTTP 트랜잭션 추적의 예:

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;
}
}
Copyright © 2023 New Relic Inc.

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