Clarify Activity parent in links example (readme) (#946)
* Clarify parent id in links scenario Server activity had parent equal to one of the links - this is confusing, changed to default context (new trace) as likely this activity has no parent. * Update README.md * review comments * fix lint Co-authored-by: Cijo Thomas <cithomas@microsoft.com>
This commit is contained in:
parent
21d18e1662
commit
70c410771a
|
|
@ -270,9 +270,22 @@ OpenTelemetry samplers chose not to sample this activity.
|
|||
activityLinks.Add(new ActivityLink(linkedContext2));
|
||||
|
||||
var activity = activitySource.StartActivity(
|
||||
"ActivityName",
|
||||
"ActivityWithLinks",
|
||||
ActivityKind.Server,
|
||||
"00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01",
|
||||
default(ActivityContext), // this creates Activity without parent
|
||||
initialTags,
|
||||
activityLinks);
|
||||
```
|
||||
|
||||
In case activity has parent, pass parent's context:
|
||||
|
||||
```csharp
|
||||
var parentContext = Activity.Current != null ? Activity.Current.Context : default(ActivityContext);
|
||||
|
||||
var activity = activitySource.StartActivity(
|
||||
"ActivityWithLinks",
|
||||
ActivityKind.Server,
|
||||
parentContext,
|
||||
initialTags,
|
||||
activityLinks);
|
||||
```
|
||||
|
|
|
|||
Loading…
Reference in New Issue