• 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()

現在のトレースと親のスパンの識別子を含む連想配列を返します。

要件

Requires PHP agent version 9.3 or higher.

トランザクションの中で呼び出す必要があります

説明

現在のトレースと親のスパンの識別子を含む連想配列を返します。この情報は、Zipkin のようなサードパーティの分散型トレースツールと統合する際に役立ちます。

戻り値

キーを含む連想配列です。

  • trace_id: 現在実行中のトレース識別子。トランザクションがこの機能をサポートしていない場合、または分散トレースが無効になっている場合は、空の値が返されます。戻り値:
  • span_id: 現在実行中のスパン識別子。トランザクションがこの機能をサポートしていない場合、または分散トレースが無効になっている場合は、空の値が返されます。

Zipkin で使用するための B3 Headers の作成

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株式会社。

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