Skip to content

Commit

Permalink
Updated docs from commit 235e8ec on refs/heads/release/latest
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Feb 20, 2024
1 parent c20d3ed commit 218950d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
47 changes: 47 additions & 0 deletions articles/distributed-tracing.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ <h2 id="using-open-telemetry">Using Open Telemetry</h2>
<li>Active health checks for clusters</li>
</ul>
<p>These will only be created if there is a listener for the <a href="https://learn.microsoft.com/dotnet/core/diagnostics/distributed-tracing-instrumentation-walkthroughs#activitysource"><code>ActivitySource</code></a> named <code>Yarp.ReverseProxy</code>.</p>
<h3 id="example-application-insights">Example: Application Insights</h3>
<p>For example, to monitor the traces with Application Insights, the proxy application needs to use the <a href="https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/src/OpenTelemetry/README.md">Open Telemetry</a> and <a href="https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/monitor/Azure.Monitor.OpenTelemetry.AspNetCore/README.md">Azure Monitor</a> SDKs.</p>
<p><code>application.csproj</code>:</p>
<pre><code class="lang-xml">&lt;ItemGroup&gt;
Expand Down Expand Up @@ -112,6 +113,52 @@ <h2 id="using-open-telemetry">Using Open Telemetry</h2>
app.Run();

</code></pre>
<h3 id="example-opentelemetry-hosting">Example: OpenTelemetry hosting</h3>
<pre><code class="lang-xml"> &lt;ItemGroup&gt;
&lt;PackageReference Include=&quot;OpenTelemetry.Exporter.Console&quot; Version=&quot;1.7.0&quot; /&gt;
&lt;PackageReference Include=&quot;OpenTelemetry.Exporter.OpenTelemetryProtocol&quot; Version=&quot;1.7.0&quot; /&gt;
&lt;PackageReference Include=&quot;OpenTelemetry.Extensions.Hosting&quot; Version=&quot;1.7.0&quot; /&gt;
&lt;PackageReference Include=&quot;OpenTelemetry.Instrumentation.AspNetCore&quot; Version=&quot;1.7.0&quot; /&gt;
&lt;PackageReference Include=&quot;OpenTelemetry.Instrumentation.Http&quot; Version=&quot;1.7.0&quot; /&gt;
&lt;PackageReference Include=&quot;OpenTelemetry.Instrumentation.Runtime&quot; Version=&quot;1.7.0&quot; /&gt;
&lt;/ItemGroup&gt;
</code></pre>
<pre><code class="lang-csharp">using OpenTelemetry.Logs;
using OpenTelemetry.Metrics;
using OpenTelemetry.Resources;
using OpenTelemetry.Trace;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddReverseProxy().LoadFromConfig(builder.Configuration.GetSection(&quot;ReverseProxy&quot;));

// configure OTel and OTLP
const string serviceName = &quot;yarpProxy&quot;;

builder.Logging.AddOpenTelemetry(options =&gt;
{
options
.SetResourceBuilder(
ResourceBuilder.CreateDefault()
.AddService(serviceName))
.AddOtlpExporter();
});

builder.Services.AddOpenTelemetry()
.ConfigureResource(resource =&gt; resource.AddService(serviceName))
.WithTracing(tracing =&gt; tracing
.AddAspNetCoreInstrumentation()
.AddHttpClientInstrumentation()
.AddSource(&quot;Yarp.ReverseProxy&quot;)
.AddOtlpExporter()
);

// build and start app
var app = builder.Build();
app.MapReverseProxy();
app.Run();
</code></pre>
<p>Note that the <code>AddHttpClientInstrumentation()</code> call is required along with the <code>AddSource(&quot;Yarp.ReverseProxy&quot;)</code> call to make the request spans emit.</p>
<p>See <a href="https://learn.microsoft.com/dotnet/core/diagnostics/observability-with-otel">ASP.NET Documentation on Observability with OpenTelemetry</a>.</p>
<p>Provided that the traces are being logged to the same store for the proxy and destination servers, then the tracing analysis tools can correlate the requests and provide gant charts etc covering the end-to-end processing of the requests as they transition across the servers.</p>
<p>The same pattern can be used with the built-in OTEL exporters for Jaeger and Zipkin, or with many of the <a href="https://opentelemetry.io/ecosystem/vendors/">APM vendors</a> who are adopting OTEL.</p>
<h2 id="using-custom-tracing-headers">Using custom tracing headers</h2>
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2448,7 +2448,7 @@
"output": {
".html": {
"relative_path": "articles/distributed-tracing.html",
"hash": "DNfRNG6c3yhabvJ1gFmcZo+sRSv6VPrj6RSQ8I4RoGM="
"hash": "25hSV6Lh4Cc6uUm4LincW4P03ave5+WG/cZUfZL78Bk="
}
},
"is_incremental": false,
Expand Down

0 comments on commit 218950d

Please sign in to comment.