Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify Activity parent in links example (readme) #946

Merged
merged 6 commits into from
Jul 30, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/OpenTelemetry.Api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
```
Expand Down