• EnglishEspañol日本語한국어Português
  • 로그인지금 시작하기

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

In the event of any inconsistency between the English version and the translated version, the English versionwill take priority. Please visit this page for more information.

문제 신고

newrelic_get_trace_metadata

통사론

newrelic_get_trace_metadata()

현재 추적 및 상위 범위의 식별자를 포함하는 연관 배열을 반환합니다.

요구 사항

PHP 에이전트 버전 9.3 이상이 필요합니다.

트랜잭션 내에서 호출되어야 합니다.

설명

현재 추적 및 상위 범위의 식별자를 포함하는 연관 배열을 반환합니다. 이 정보는 Zipkin과 같은 타사 분산 추적 도구와 통합하는 데 유용합니다.

반환 값

키를 포함하는 연관 배열:

  • trace_id: 현재 실행 중인 추적 식별자입니다. 트랜잭션이 이 기능을 지원하지 않거나 분산 추적이 비활성화된 경우 빈 값이 반환됩니다.반환:
  • span_id: 현재 실행 중인 스팬 식별자입니다. 트랜잭션이 이 기능을 지원하지 않거나 분산 추적이 비활성화된 경우 빈 값이 반환됩니다.

Zipkin과 함께 사용할 B3 헤더 채우기

Zipkin 소비자에게 전송되는 HTTP 헤더에 필요한 분산 추적 메타데이터를 추가합니다.

function make_http_request($url) {
$metadata = newrelic_get_trace_metadata();
$sampled = newrelic_is_sampled();
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'X-B3-TraceId: ' . $metadata['trace_id'],
'X-B3-SpanId: ' . substr(uniqid() . uniqid(), 0, 16),
'X-B3-ParentSpanId: ' . $metadata['span_id'],
'X-B3-Sampled: ' . $sampled));
return curl_exec($ch);
}
$status = make_http_request("zipkin-consumer.example");
Copyright © 2024 New Relic Inc.

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