-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Migrate to custom OTel Exporter in dotnetup to prevent perf delay and data loss
#55421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nagilson
wants to merge
26
commits into
dotnet:release/dnup
Choose a base branch
from
nagilson:nagilson-new-otel-exporter
base: release/dnup
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
4f9c493
Telemetry Client uses shutdown in `dotnetup` over flush and uses new …
nagilson 856cb53
allow toggling the drain in persistent storage exporter
nagilson 850fa88
reference custom otel exporter
nagilson 474ef49
Document flush control env var
nagilson 1c66b96
add dotnet cli telemetry timeout constant to dotnetup constants
nagilson 138262a
test that it uses custom flush / shutdown budgets - even if shutdown …
nagilson 91a8c34
add backoff to POST requests in custom exporter lib
nagilson b21114a
Add backoff retry to the http upload transport
nagilson abcc37c
Add reference to dotnet's sdk telemetry path
nagilson 7746447
include the cli path folder calculator for consumption to get sdk sto…
nagilson e6e6c40
Add a sub process to drain telemetry at the end for non one and done …
nagilson 0754dbd
Add detached process upload for telemetry
nagilson e39eb17
Add basic test for http retry on post
nagilson ef087b7
Add tests to ensure it backs off if the transport throws to prevent t…
nagilson 6974b81
Merge branch 'release/dnup' into nagilson-new-otel-exporter
nagilson c227540
try to avoid exceptions from async tasks throwing due to a new thread…
nagilson a60c5f7
Merge branch 'nagilson-new-otel-exporter' of https://github.com/nagil…
nagilson d9cb98b
Fix usings
nagilson e05aa7d
add tests for telemetry drainer for blob retry delays
nagilson 2ef14bc
consider framework conditional for using better .net core methods
nagilson b5a0a50
Add full depth e2e tests for detached draining, post, telemetry rete…
nagilson bed87b2
Merge branch 'release/dnup' into nagilson-new-otel-exporter
nagilson 85fcd0b
deduplicate exporters and telemetry path calculation
nagilson b1be289
dont continue to try to upload data that will never succeed to POST
nagilson 4bace8b
dont allow telemetry blobs that will never succeed to persist indefin…
nagilson 479d417
test rejected blobs that are retrieable can be retried
nagilson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
88 changes: 88 additions & 0 deletions
88
...crosoft.DotNet.Cli.Telemetry/Implementation/PersistentStorageTelemetryBackgroundWorker.cs
This file contains hidden or 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,88 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Diagnostics; | ||
| using System.Threading; | ||
|
|
||
| namespace Microsoft.DotNet.Cli.Telemetry.Implementation; | ||
|
|
||
| internal sealed class PersistentStorageTelemetryBackgroundWorker | ||
| { | ||
| private readonly Func<CancellationToken, Task> _drainAsync; | ||
| private int _started; | ||
| private CancellationTokenSource? _cancellation; | ||
| private Task? _task; | ||
|
|
||
| public PersistentStorageTelemetryBackgroundWorker( | ||
| ITelemetryBlobStorage storage, | ||
| Uri ingestionTrackUri, | ||
| int leasePeriodMilliseconds, | ||
| int maxBlobsPerDrain) | ||
| : this(CreateDrainAsync(storage, ingestionTrackUri, leasePeriodMilliseconds, maxBlobsPerDrain)) | ||
| { | ||
| } | ||
|
|
||
| internal PersistentStorageTelemetryBackgroundWorker(Func<CancellationToken, Task> drainAsync) | ||
| { | ||
| _drainAsync = drainAsync; | ||
| } | ||
|
|
||
| public void StartOnce() | ||
| { | ||
| if (Interlocked.Exchange(ref _started, 1) != 0) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| _cancellation = new CancellationTokenSource(); | ||
| _task = Task.Run(() => DrainAsync(_cancellation.Token)); | ||
| } | ||
|
|
||
| public bool Shutdown(int timeoutMilliseconds) | ||
| { | ||
| _cancellation?.Cancel(); | ||
| if (_task is null) | ||
| { | ||
| return true; | ||
| } | ||
|
|
||
| try | ||
| { | ||
| return _task.Wait(timeoutMilliseconds); | ||
| } | ||
| catch (AggregateException) | ||
| { | ||
| return true; | ||
| } | ||
| } | ||
|
|
||
| private async Task DrainAsync(CancellationToken cancellationToken) | ||
| { | ||
| try | ||
| { | ||
| await _drainAsync(cancellationToken).ConfigureAwait(false); | ||
| } | ||
| catch (OperationCanceledException) | ||
| { | ||
| } | ||
| catch (Exception e) | ||
| { | ||
| Debug.Fail(e.ToString()); | ||
| } | ||
| } | ||
|
|
||
| private static Func<CancellationToken, Task> CreateDrainAsync( | ||
| ITelemetryBlobStorage storage, | ||
| Uri ingestionTrackUri, | ||
| int leasePeriodMilliseconds, | ||
| int maxBlobsPerDrain) | ||
| { | ||
| var transport = new HttpTelemetryUploadTransport(ingestionTrackUri); | ||
| var uploader = new PersistentStorageTelemetryUploader( | ||
| storage, | ||
| transport, | ||
| leasePeriodMilliseconds, | ||
| maxBlobsPerDrain); | ||
| return cancellationToken => uploader.DrainAsync(cancellationToken); | ||
| } | ||
| } |
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.