Returns properties in the current execution environment used to support tracing.
Agent version 8.19 or higher.
Compatible with all app types.
Distributed tracing must be enabled to get meaningful values.
Provides access to the following properties:
Returns a string representing the currently executing trace. If the trace ID is not available, or distributed tracing is disabled, the value will be string.Empty.
Returns a string representing the currently executing span. If the span ID is not available, or distributed tracing is disabled, the value will be string.Empty.
NewRelic.Api.Agent.IAgent Agent = NewRelic.Api.Agent.NewRelic.GetAgent();var traceMetadata = Agent.TraceMetadata;var traceId = traceMetadata.TraceId;var spanId = traceMetadata.SpanId;var isSampled = traceMetadata.IsSampled;
If you need more help, check out these support and learning resources:
- 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.