Syntax
newrelic_is_sampled()
Returns a value indicating whether or not the current transaction is marked as sampled.
Requirements
Requires PHP agent version 9.3 or higher.
Must be called inside a transaction.
Description
Returns a value indicating whether or not the current transaction is marked as sampled.
Return values
Returns true
if distributed tracing is enabled, and the current transaction is marked as sampled, otherwise false
.
Examples
Populate B3 Headers for use with Zipkin
Adds necessary distributed tracing metadata to the HTTP headers being sent to a Zipkin consumer:
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");
For more help
If you need more help, check out these support and learning resources:
- Suggest a change and learn how to contribute to our PHP agent open source repository.
- Browse the Explorers Hub to get help from the community and join in discussions.
- Find answers on our sites and learn how to use our support portal.
- Run New Relic Diagnostics, our troubleshooting tool for Linux, Windows, and macOS.
- Review New Relic's data security and licenses documentation.
その他のヘルプ
さらに支援が必要な場合は、これらのサポートと学習リソースを確認してください:
- Explorers Hubでは、コミュニティからのサポートを受けたり、ディスカッションに参加したりすることができます。
- 当社サイトで答えを見つけて、サポートポータルの使用方法を確認してください。
- Linux、Windows、およびmacOS向けトラブルシューティングツールであるNew Relic Diagnosticsを実行してください。
- New Relicのデータセキュリティとライセンスドキュメント をご確認ください。