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

Create diagnosticsource-getting-started.md #29255

Merged
merged 29 commits into from
Jun 2, 2022
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1901847
Create diagnosticsource-getting-started.md
mikelle-rogers May 2, 2022
ebf9141
DiagnosticSource Overview page
mikelle-rogers May 3, 2022
d29f7b0
Alter formatting and clarify contents of the file
mikelle-rogers May 3, 2022
3cdb16c
Update diagnosticsource.md
mikelle-rogers May 3, 2022
48c76a0
Fixing lint failures
mikelle-rogers May 3, 2022
012a00d
Fix up the code and finish up the documentation
mikelle-rogers May 5, 2022
14cd364
Not needed
mikelle-rogers May 5, 2022
0e80142
Update the date
mikelle-rogers May 5, 2022
f530c99
Combine into one file
mikelle-rogers May 5, 2022
f1998d9
Not needed
mikelle-rogers May 5, 2022
7bd1010
Remove whitespace
mikelle-rogers May 5, 2022
9e27b55
Fixed suggestions from code review
mikelle-rogers May 9, 2022
672fb48
Two additional edits
mikelle-rogers May 9, 2022
19ebd1e
Response to suggestions
mikelle-rogers May 10, 2022
9a72826
Update to working example
mikelle-rogers May 13, 2022
15c251e
Add a line, remove a space
mikelle-rogers May 13, 2022
3b085cf
Updating from feedback on code review
mikelle-rogers May 23, 2022
5c42c6f
Add DiagnosticSource and DiagnosticListener to toc
mikelle-rogers May 25, 2022
3edf4ce
Add .csproj and .cs files
mikelle-rogers May 25, 2022
5eb2e4f
Add links to the .cs and .csproj folders
mikelle-rogers May 25, 2022
3504d75
Merge branch 'main' into dev/mirogers/diagnosticsource-getting-started
mikelle-rogers May 25, 2022
6f2f3bc
Move the file to the correct place
mikelle-rogers May 25, 2022
d8c5a42
move location, add blocking
mikelle-rogers May 25, 2022
a9b6a75
Moving to correct address for real
mikelle-rogers May 25, 2022
f1550c3
Linking the code to the snippits
mikelle-rogers May 25, 2022
7971595
Correct filepath
mikelle-rogers May 25, 2022
04eb980
Responding to feedback
mikelle-rogers May 25, 2022
2802ddc
Added missing character
mikelle-rogers May 25, 2022
5f0fc2c
removing links
mikelle-rogers Jun 2, 2022
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
27 changes: 27 additions & 0 deletions docs/core/diagnostics/diagnosticsource-getting-started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
title: Getting Started with DiagnosticSource
description: A tutorial to create a basic DiagnosticSource and understand key concepts
ms.date: 05/02/2022
---
# Getting Started with DiagnosticSource

**This article applies to: ✔️** .NET Core 3.1 and later versions **✔️** .NET Framework 4.5 and later versions

This walkthrough shows <xref:System.Diagnostics.DiagnosticSource?displayProperty=nameWithType>
mikelle-rogers marked this conversation as resolved.
Show resolved Hide resolved

## Log an event

The `DiagnosticSource` type is an abstract base class that defines the methods needed to log events. The class that holds the implementation is `DiagnosticListener`.
The first step in instrumenting code with `DiagnosticSource` is to create a
`DiagnosticListener`. For example:

```C#
private static DiagnosticSource httpLogger = new DiagnosticListener("System.Net.Http");
```
Notice that httpLogger is typed as a `DiagnosticSource`.
This is because this code
only cares about writing events and thus only cares about the `DiagnosticSource` methods that
the `DiagnosticListener` implements. `DiagnosticListeners` are given names when they are created
and this name should be the name of logical grouping of related events (typically the component).
Later this name is used to find the Listener and subscribe to any of its events. `DiagnosticListeners` have a name, which is used to represent the component associated with the event.
Thus the event names only need to be unique within a component.
mikelle-rogers marked this conversation as resolved.
Show resolved Hide resolved