[DOC] Update Jaeger tutorial to use OTLP Exporter (#3940)

* [DOC] Update Jaeger tutorial to use OTLP Exporter

* fix HttpClient could not be found in .NET framework error during CI

* fix markdown lint issue

* Update jaeger example .csproj file

* Update docs/trace/getting-started-jaeger/getting-started-jaeger.csproj

* Remove redundant options setting and update README

Co-authored-by: Reiley Yang <reyang@microsoft.com>
This commit is contained in:
Han Gao 2022-12-01 03:10:23 +08:00 committed by GitHub
parent e376aef472
commit 260460787f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 21 deletions

View File

@ -240,6 +240,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Exporter.Open
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTelemetry.Exporter.Console.Tests", "test\OpenTelemetry.Exporter.Console.Tests\OpenTelemetry.Exporter.Console.Tests.csproj", "{011E70E1-152A-47BB-AF83-12DD12B125ED}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "getting-started-jaeger", "docs\trace\getting-started-jaeger\getting-started-jaeger.csproj", "{329AD438-6D15-4432-99BE-B0E85F00B3CB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -498,6 +500,10 @@ Global
{011E70E1-152A-47BB-AF83-12DD12B125ED}.Debug|Any CPU.Build.0 = Debug|Any CPU
{011E70E1-152A-47BB-AF83-12DD12B125ED}.Release|Any CPU.ActiveCfg = Release|Any CPU
{011E70E1-152A-47BB-AF83-12DD12B125ED}.Release|Any CPU.Build.0 = Release|Any CPU
{329AD438-6D15-4432-99BE-B0E85F00B3CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{329AD438-6D15-4432-99BE-B0E85F00B3CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{329AD438-6D15-4432-99BE-B0E85F00B3CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{329AD438-6D15-4432-99BE-B0E85F00B3CB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -535,6 +541,7 @@ Global
{9A07D215-90AC-4BAF-BCDB-73D74FD3A5C5} = {3862190B-E2C5-418E-AFDC-DB281FB5C705}
{5FDAF679-DE5A-4C73-A49B-8ABCF2399229} = {77C7929A-2EED-4AA6-8705-B5C443C8AA0F}
{A2DF46DE-50D7-4887-8C9D-4BD79CA19FAA} = {3862190B-E2C5-418E-AFDC-DB281FB5C705}
{329AD438-6D15-4432-99BE-B0E85F00B3CB} = {5B7FB835-3FFF-4BC2-99C5-A5B5FAE3C818}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {55639B5C-0770-4A22-AB56-859604650521}

View File

@ -19,6 +19,7 @@ using System.Diagnostics;
using System.Net.Http;
using System.Threading.Tasks;
using OpenTelemetry;
using OpenTelemetry.Exporter;
using OpenTelemetry.Resources;
using OpenTelemetry.Trace;
@ -37,7 +38,7 @@ public class Program
.AddSource("OpenTelemetry.Demo.Jaeger")
.AddHttpClientInstrumentation()
.AddConsoleExporter()
.AddJaegerExporter()
.AddOtlpExporter()
.Build();
using var parent = MyActivitySource.StartActivity("JaegerDemo");

View File

@ -20,14 +20,14 @@ dotnet run
```
Add reference to [Console
Exporter](../../../src/OpenTelemetry.Exporter.Console/README.md), [Jaeger
Exporter](../../../src/OpenTelemetry.Exporter.Jaeger/README.md) and [HttpClient
Instrumentation](../../../src/OpenTelemetry.Instrumentation.Http/README.md):
Exporter](../../../src/OpenTelemetry.Exporter.Console/README.md), [OTLP
Exporter](../../../src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md) and
[HttpClient Instrumentation](../../../src/OpenTelemetry.Instrumentation.Http/README.md):
```sh
dotnet add package OpenTelemetry.Exporter.Console
dotnet add package OpenTelemetry.Exporter.Jaeger
dotnet add package OpenTelemetry.Instrumentation.Http
dotnet add package OpenTelemetry.Exporter.OpenTelemetryProtocol
dotnet add package OpenTelemetry.Instrumentation.Http --prerelease
```
Now copy the code from [Program.cs](./Program.cs).
@ -67,15 +67,15 @@ Note that we have configured two exporters in the code:
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
...
.AddConsoleExporter()
.AddJaegerExporter()
.AddOtlpExporter()
.Build();
```
When we run the application, the `ConsoleExporter` was printing the traces on
console, and the `JaegerExporter` was attempting to send the traces to Jaeger
Agent via the default endpoint `udp://localhost:6831`.
console, and the `OtlpExporter` was attempting to send the traces to Jaeger
Agent via the default endpoint `http://localhost:4317`.
Since we didn't have Jaeger running, the traces received by `JaegerExporter`
Since we didn't have Jaeger running, the traces received by `OtlpExporter`
were simply dropped on the floor. In the next step, we are going to learn about
how to use Jaeger to collect and visualize the traces.
@ -87,7 +87,7 @@ subgraph SDK
SimpleExportProcessor["SimpleExportProcessor < Activity >"]
BatchExportProcessor["BatchExportProcessor < Activity >"]
ConsoleExporter
JaegerExporter
OtlpExporter
end
subgraph API
@ -98,7 +98,7 @@ ActivitySource --> | System.Diagnostics.Activity | TracerProvider
TracerProvider --> | System.Diagnostics.Activity | SimpleExportProcessor --> | Batch | ConsoleExporter
TracerProvider --> | System.Diagnostics.Activity | BatchExportProcessor --> | Batch | JaegerExporter
TracerProvider --> | System.Diagnostics.Activity | BatchExportProcessor --> | Batch | OtlpExporter
```
## Collect and visualize traces using Jaeger
@ -112,7 +112,7 @@ After finished downloading, extract it to a local location that's easy to
access. Run the `jaeger-all-in-one(.exe)` executable:
```sh
./jaeger-all-in-one
./jaeger-all-in-one --collector.otlp.enabled
```
Now we should be able to see the Jaeger UI at
@ -133,7 +133,7 @@ Chart](https://en.wikipedia.org/wiki/Gantt_chart):
```mermaid
graph TD
JaegerExporter["JaegerExporter"] --> |udp://localhost:6831| Jaeger
OtlpExporter["OtlpExporter"] --> |http://localhost:4317| Jaeger
Jaeger -->|http://localhost:16686/| JaegerUI["Browser<br/>(Jaeger UI)"]
```
@ -147,7 +147,7 @@ using var tracerProvider = Sdk.CreateTracerProviderBuilder()
...
// Remove Console Exporter from the final application
// .AddConsoleExporter()
.AddJaegerExporter()
.AddOtlpExporter()
.Build();
```
@ -161,7 +161,7 @@ graph LR
subgraph SDK
TracerProvider
BatchExportProcessor["BatchExportProcessor < Activity >"]
JaegerExporter
OtlpExporter
end
subgraph API
@ -170,11 +170,11 @@ end
ActivitySource --> | System.Diagnostics.Activity | TracerProvider --> | System.Diagnostics.Activity | BatchExportProcessor
BatchExportProcessor --> | Batch | JaegerExporter
BatchExportProcessor --> | Batch | OtlpExporter
```
## Learn more
- [Jaeger Tracing](https://www.jaegertracing.io/)
- [Jaeger Exporter for OpenTelemetry
.NET](../../../src/OpenTelemetry.Exporter.Jaeger/README.md)
- [OTLP Exporter for OpenTelemetry
.NET](../../../src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md)

View File

@ -1,7 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Exporter.Console\OpenTelemetry.Exporter.Console.csproj" />
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Exporter.Jaeger\OpenTelemetry.Exporter.Jaeger.csproj" />
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Exporter.OpenTelemetryProtocol\OpenTelemetry.Exporter.OpenTelemetryProtocol.csproj" />
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Instrumentation.Http\OpenTelemetry.Instrumentation.Http.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Net.Http" Version="4.3.4" Condition="$(TargetFramework) == 'net472' or $(TargetFramework) == 'net48'" />
</ItemGroup>
</Project>