Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
j-zhong-ms committed Dec 11, 2024
1 parent 14b50f7 commit adaf17b
Showing 1 changed file with 54 additions and 28 deletions.
82 changes: 54 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,43 @@
# Project
# Azure Monitor OpenTelemetry Profiler for .NET (PREVIEW)

## Description

Welcome to the home page of `Azure Monitor OpenTelemetry Profiler for .NET`.
Welcome to the home page of `Azure Monitor OpenTelemetry Profiler for .NET (PREVIEW)`.

## Get Started

### Step 0: Prerequisites
- **.NET 8 SDK**: Install the latest .NET Core SDK from [here](https://dotnet.microsoft.com/en-us/download/dotnet).
- **Local authentication**: Ensure local authentication is enabled for the Application Insights resource.

- **.NET 8 SDK**: Install the latest .NET Core SDK from [here](https://dotnet.microsoft.com/download/dotnet).

### Step 1: Create an ASP.NET Core Application

If you don't have an app already, you can create a new web API project using the following command:

```sh
dotnet new web
```

### Step 2: Add NuGet Package Reference

Add a reference to the latest NuGet packages:

```sh
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
Follow the [instructions](https://learn.microsoft.com/en-us/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/en-us/azure/azure-monitor/app/opentelemetry-enable?tabs=aspnetcore#confirm-data-is-flowing).
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

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

```csharp
using Azure.Monitor.OpenTelemetry.Profiler.AspNetCore;

Expand All @@ -42,49 +51,66 @@ builder.Services.AddOpenTelemetry()
```

### Step 5: Run Your Application

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

```sh
PS > dotnet run

Building...
info: Microsoft.ApplicationInsights.Profiler.Shared.Services.Orchestrations.LocalProfileSettingsService[0]
Getting remote settings in standalone mode. Returns null.

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
Now listening on: http://localhost:5143
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Development
Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
Content root path: C:\
Content root path: C:\
info: Azure.Monitor.OpenTelemetry.Profiler.AspNetCore.ServiceProfilerAgentBootstrap[0]
Starting application insights profiler with connection string: InstrumentationKey=5d…
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\...
Start writing trace file C:\Users\aaa\AppData\Local\Temp\SPTraces\...
info: Azure.Monitor.OpenTelemetry.Profiler.Core.EventListeners.TraceSessionListener[0]
Activity detected.
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.
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:\Users\aaa\AppData\Local\Temp\ServiceProfiler\99.2024.1119.31081\Uploader\Microsoft.ApplicationInsights.Profiler.Uploader.dll
warn: Azure.Monitor.OpenTelemetry.Profiler.Core.AuthTokenProvider[0]
AuthTokenProvider is not implemented.
info: Azure.Monitor.OpenTelemetry.Profiler.Core.Orchestrations.StubResourceUsageSource[0]
GetAverageCPUUsage triggered in StubResourceUsageSource
info: Azure.Monitor.OpenTelemetry.Profiler.Core.Orchestrations.StubResourceUsageSource[0]
GetAverageMemoryUsage triggered in StubResourceUsageSource
info: Azure.Monitor.OpenTelemetry.Profiler.Core.TraceUploaderProxy[0]
Call upload trace finished. Exit code: 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
You can view the profiler data by following [these instructions](https://learn.microsoft.com/en-us/azure/azure-monitor/profiler/profiler-data).

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

## 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
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
the rights to use your contribution. For details, visit <https://cla.opensource.microsoft.com>.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
provided by the bot. You will only need to do this once across all repos using our CLA.
Expand All @@ -97,6 +123,6 @@ The software may collect information about you and your use of the software and

## Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow [Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow [Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/legal/intellectualproperty/trademarks/usage/general).
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
Any use of third-party trademarks or logos are subject to those third-party's policies.

0 comments on commit adaf17b

Please sign in to comment.