Add checker for passing correct sampling decision for xray (#1355)

* Add checker for passing correct sampling decision when apply xray id generator.

* Added comment

* Update comments.

* Update links.

* Updated CHANGELOG.md

* Fixed the typo and lining

* Moved check inline.

Co-authored-by: Cijo Thomas <cithomas@microsoft.com>
This commit is contained in:
Lu Peng 2021-01-14 10:09:56 -08:00 committed by GitHub
parent 9b60e1fe8f
commit b17278f691
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -19,6 +19,9 @@
for Activity.Recorded in SimpleActivityExportProcessor and
BatchActivityExportProcessor
([#1622](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1622))
* Added check in `ActivitySourceAdapter` class for root activity if traceid is
overridden by calling `SetParentId`
([#1355](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1355))
## 1.0.0-rc1.1

View File

@ -136,7 +136,10 @@ namespace OpenTelemetry.Trace
private void RunGetRequestedDataOtherSampler(Activity activity)
{
ActivityContext parentContext;
if (string.IsNullOrEmpty(activity.ParentId))
// Check activity.ParentId alone is sufficient to normally determine if a activity is root or not. But if one uses activity.SetParentId to override the TraceId (without intending to set an actual parent), then additional check of parentspanid being empty is required to confirm if an activity is root or not.
// This checker can be removed, once Activity exposes an API to customize ID Generation (https://github.com/dotnet/runtime/issues/46704) or issue https://github.com/dotnet/runtime/issues/46706 is addressed.
if (string.IsNullOrEmpty(activity.ParentId) || activity.ParentSpanId.ToHexString() == "0000000000000000")
{
parentContext = default;
}