Skip to content

Commit

Permalink
Update readme and fix missing assembly bug (#7)
Browse files Browse the repository at this point in the history
* update package versions

* add frontend assembly

* update readme

* update readme
  • Loading branch information
j-zhong-ms authored Dec 13, 2024
1 parent c6b748b commit af8a87e
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 35 deletions.
74 changes: 39 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,38 @@ If you don't have an app already, you can create a new web API project using the
dotnet new web
```

### Step 2: Add NuGet Package Reference
### Step 2: Generate a PAT

Generate a Personal Access Token (PAT) that will be used to download the NuGet package by following [these instructions](https://docs.github.com/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic).

Ensure that the Personal Access Token (PAT) has the `read:packages` permission.

![PAT read](./images/PAT-read.png)

### Step 3: Add NuGet Source

Create a `nuget.config` in your project root with the following content, replacing `your-user-name` with your GitHub username and `GITHUB-PAT` with the PAT from the previous step:

```xml
<configuration>
<packageSources>
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
<clear />
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
<add key="github-azure" value="https://nuget.pkg.github.com/Azure/index.json" />
</packageSources>
<packageSourceCredentials>
<github-azure>
<add key="Username" value="your-user-name" />
<add key="ClearTextPassword" value="GITHUB-PAT" />
</github-azure>
</packageSourceCredentials>
</configuration>
```

For additional details on using the GitHub Packages registry, please refer to the [documentation](https://docs.github.com/packages/working-with-a-github-packages-registry/working-with-the-nuget-registry#installing-a-package).

### Step 4: Add NuGet Package Reference

Add a reference to the latest NuGet packages:

Expand All @@ -28,13 +59,13 @@ dotnet add package Azure.Monitor.OpenTelemetry.Profiler.AspNetCore --prerelease

This will automatically add a dependency to `Azure.Monitor.OpenTelemetry.AspNetCore`.

### Step 3: Enable Application Insights with OpenTelemetry
### Step 5: Enable Application Insights with OpenTelemetry

Follow the [instructions](https://learn.microsoft.com/azure/azure-monitor/app/opentelemetry-enable?tabs=aspnetcore#enable-opentelemetry-with-application-insights) to enable Azure Monitor OpenTelemetry for .NET.

Verify that the connection to Application Insights works -- [Confirm Data is Flowing](https://learn.microsoft.com/azure/azure-monitor/app/opentelemetry-enable?tabs=aspnetcore#confirm-data-is-flowing).

### Step 4: Enable Profiler
### Step 6: Enable Profiler

Append the call to `UseProfiler()` in your code:

Expand All @@ -50,7 +81,7 @@ builder.Services.AddOpenTelemetry()
...
```

### Step 5: Run Your Application
### Step 7: Run Your Application

Run your application and check the log output. A successful execution will look like this:

Expand All @@ -59,10 +90,6 @@ PS > dotnet run

Building...

info: Microsoft.ApplicationInsights.Profiler.Shared.Services.TraceScavenger.TraceScavengerService[0]
TraceScavengerService started. Initial delay: 00:00:00, Grace period from last access: 00:10:00
info: Microsoft.ApplicationInsights.Profiler.Shared.Services.TraceScavenger.TraceScavengerListener[0]
File scavenger started.
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://localhost:5143
info: Microsoft.Hosting.Lifetime[0]
Expand All @@ -75,38 +102,15 @@ info: Azure.Monitor.OpenTelemetry.Profiler.AspNetCore.ServiceProfilerAgentBootst
Starting application insights profiler with connection string: InstrumentationKey=5d…
info: Azure.Monitor.OpenTelemetry.Profiler.Core.DumbTraceControl[0]
Start writing trace file C:\Users\aaa\AppData\Local\Temp\SPTraces\...
info: Azure.Monitor.OpenTelemetry.Profiler.Core.EventListeners.TraceSessionListener[0]
Activity detected.
info: Azure.Monitor.OpenTelemetry.Profiler.Core.DumbTraceControl[0]
Finished writing trace file C:\Users\aaa\AppData\Local\Temp\SPTraces\b73520a6-931f-4207-b602-0d72d376609a.nettrace.
info: Azure.Monitor.OpenTelemetry.Profiler.Core.TraceUploaderProxy[0]
Uploader to be used: C:\...\Microsoft.ApplicationInsights.Profiler.Uploader.dll

Uploader Hosting Environment is set to: Development.
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
Content root path: C:\...
info: Microsoft.ApplicationInsights.Profiler.Uploader.TraceUploaderByNamedPipe[0]
Service Profiler trace uploaded.
info: Microsoft.ApplicationInsights.Profiler.Uploader.TraceUploaderByNamedPipe[0]
Trace file will be preserved at: C:\...\*.etl.zip
info: Microsoft.ApplicationInsights.Profiler.Uploader.TraceUploaderByNamedPipe[0]
Sending customer events
info: Microsoft.ApplicationInsights.Profiler.Uploader.TraceUploaderByNamedPipe[0]
AAD auth is enabled.
info: Microsoft.Hosting.Lifetime[0]
Application is shutting down...
info: Azure.Monitor.OpenTelemetry.Profiler.Core.TraceUploaderProxy[0]
Call upload trace finished. Exit code: 0
...
```

### Step 6: View Profiler Data
### Step 8: View Profiler Data

You can view the profiler data by following [these instructions](https://learn.microsoft.com/azure/azure-monitor/profiler/profiler-data).

![sample trace](./images/sample-trace.png)

## Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
Expand Down
Binary file added images/PAT-read.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/sample-trace.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
<file src="bin\$configuration$\$targetFramework$\Microsoft.ApplicationInsights.Profiler.Shared.pdb" target="lib/$targetFramework$"></file>
<file src="bin\$configuration$\$targetFramework$\Microsoft.ServiceProfiler.Agent.Exceptions.dll" target="lib/$targetFramework$"></file>
<file src="bin\$configuration$\$targetFramework$\Microsoft.ServiceProfiler.Agent.Exceptions.pdb" target="lib/$targetFramework$"></file>
<file src="bin\$configuration$\$targetFramework$\Microsoft.ServiceProfiler.Agent.FrontendClient.dll" target="lib/$targetFramework$"></file>
<file src="bin\$configuration$\$targetFramework$\Microsoft.ServiceProfiler.Agent.FrontendClient.pdb" target="lib/$targetFramework$"></file>
<file src="bin\$configuration$\$targetFramework$\Microsoft.ServiceProfiler.Agent.FrontendClient.Profiler.dll" target="lib/$targetFramework$"></file>
<file src="bin\$configuration$\$targetFramework$\Microsoft.ServiceProfiler.Agent.FrontendClient.Profiler.pdb" target="lib/$targetFramework$"></file>
<file src="bin\$configuration$\$targetFramework$\Microsoft.ServiceProfiler.Common.Utilities.dll" target="lib/$targetFramework$"></file>
Expand Down

0 comments on commit af8a87e

Please sign in to comment.