-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/NATS.Net.OpenTelemetry/OpenTelemetryTracingExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using NATS.Client.Core; | ||
|
||
// ReSharper disable once CheckNamespace - Place in OTEL namespace for discoverability | ||
namespace OpenTelemetry.Trace; | ||
|
||
public static class OpenTelemetryTracingExtensions | ||
{ | ||
/// <summary> | ||
/// Enables trace collection on activity sources from the NATS.Client nuget package. | ||
/// </summary> | ||
/// <param name="builder"><see cref="TracerProviderBuilder"/> being configured.</param> | ||
/// <param name="includeInternal">Include traces from internal messaging used for control flow and lower level usage during high level abstractions (e.g. JetStream, KvStore, etc)</param> | ||
/// <returns>The same instance of <see cref="TracerProviderBuilder"/> to chain the calls.</returns> | ||
public static TracerProviderBuilder AddNatsInstrumentation(this TracerProviderBuilder builder, bool includeInternal = false) | ||
{ | ||
builder.AddSource("NATS.Client"); | ||
|
||
if (includeInternal) | ||
builder.AddSource("NATS.Client.Internal"); | ||
|
||
return builder; | ||
} | ||
} |