-
Notifications
You must be signed in to change notification settings - Fork 867
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add telemetry for chunk-dedup build artifacts uploads (#3375)
* Add telemetry for chunk-dedup build artifacts uploads * fix tests * better design * cleanup * Don't need this anymore * cleanup * cleanup * fix test * tryparse
- Loading branch information
Showing
17 changed files
with
218 additions
and
45 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
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
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
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
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
37 changes: 37 additions & 0 deletions
37
src/Microsoft.VisualStudio.Services.Agent/Blob/BlobStoreClientTelemetryTfs.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,37 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using System.Threading.Tasks; | ||
using Microsoft.VisualStudio.Services.WebApi; | ||
using Microsoft.VisualStudio.Services.Content.Common.Tracing; | ||
using Microsoft.VisualStudio.Services.Content.Common.Telemetry; | ||
using Microsoft.VisualStudio.Services.BlobStore.Common.Telemetry; | ||
|
||
namespace Microsoft.VisualStudio.Services.Agent.Blob | ||
{ | ||
public class BlobStoreClientTelemetryTfs : BlobStoreClientTelemetry | ||
{ | ||
private CustomerIntelligenceTelemetrySender _ciSender; | ||
|
||
public BlobStoreClientTelemetryTfs(IAppTraceSource tracer, Uri baseAddress, VssConnection connection) | ||
: base(tracer, baseAddress) | ||
{ | ||
_ciSender = new CustomerIntelligenceTelemetrySender(connection); | ||
this.senders.Add(_ciSender); | ||
} | ||
|
||
// for testing | ||
public BlobStoreClientTelemetryTfs(IAppTraceSource tracer, Uri baseAddress, VssConnection connection, ITelemetrySender sender) | ||
: base(tracer, baseAddress, sender) | ||
{ | ||
_ciSender = new CustomerIntelligenceTelemetrySender(connection); | ||
this.senders.Add(_ciSender); | ||
} | ||
|
||
public async Task CommitTelemetry(Guid planId, Guid jobId) | ||
{ | ||
await _ciSender.CommitTelemetry(planId, jobId); | ||
} | ||
} | ||
} |
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
85 changes: 85 additions & 0 deletions
85
src/Microsoft.VisualStudio.Services.Agent/Blob/CustomerIntelligenceTelemetrySender.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,85 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Microsoft.VisualStudio.Services.WebApi; | ||
using Microsoft.VisualStudio.Services.Agent.Util; | ||
using Microsoft.VisualStudio.Services.Content.Common.Telemetry; | ||
using Microsoft.VisualStudio.Services.CustomerIntelligence.WebApi; | ||
using Microsoft.VisualStudio.Services.WebPlatform; | ||
|
||
namespace Microsoft.VisualStudio.Services.Agent.Blob | ||
{ | ||
public class CustomerIntelligenceTelemetrySender : ITelemetrySender | ||
{ | ||
private CustomerIntelligenceHttpClient _ciClient; | ||
|
||
private long _chunksUploaded = 0; | ||
private long _compressionBytesSaved = 0; | ||
private long _dedupUploadBytesSaved = 0; | ||
private long _logicalContentBytesUploaded = 0; | ||
private long _physicalContentBytesUploaded = 0; | ||
private long _totalNumberOfChunks = 0; | ||
|
||
public CustomerIntelligenceTelemetrySender(VssConnection connection) | ||
{ | ||
ArgUtil.NotNull(connection, nameof(connection)); | ||
_ciClient = connection.GetClient<CustomerIntelligenceHttpClient>(); | ||
} | ||
|
||
// Not used by the interface. We just want to capture successful telemetry for dedup analytics | ||
public void StartSender() | ||
{ | ||
} | ||
public void StopSender() | ||
{ | ||
} | ||
public void SendErrorTelemetry(ErrorTelemetryRecord errorTelemetry) | ||
{ | ||
} | ||
public void SendRecord(TelemetryRecord record) | ||
{ | ||
} | ||
|
||
public void SendActionTelemetry(ActionTelemetryRecord actionTelemetry) | ||
{ | ||
if (actionTelemetry is IDedupRecord dedupRecord) | ||
{ | ||
var uploadStats = dedupRecord.UploadStatistics; | ||
if (uploadStats != null) | ||
{ | ||
this._chunksUploaded += uploadStats.ChunksUploaded; | ||
this._compressionBytesSaved += uploadStats.CompressionBytesSaved; | ||
this._dedupUploadBytesSaved += uploadStats.DedupUploadBytesSaved; | ||
this._logicalContentBytesUploaded += uploadStats.LogicalContentBytesUploaded; | ||
this._physicalContentBytesUploaded += uploadStats.PhysicalContentBytesUploaded; | ||
this._totalNumberOfChunks += uploadStats.TotalNumberOfChunks; | ||
} | ||
} | ||
} | ||
|
||
public async Task CommitTelemetry(Guid planId, Guid jobId) | ||
{ | ||
var ciData = new Dictionary<string, object>(); | ||
ciData.Add("PlanId", planId); | ||
ciData.Add("JobId", jobId); | ||
|
||
ciData.Add("ChunksUploaded", this._chunksUploaded); | ||
ciData.Add("CompressionBytesSaved", this._compressionBytesSaved); | ||
ciData.Add("DedupUploadBytesSaved", this._dedupUploadBytesSaved); | ||
ciData.Add("LogicalContentBytesUploaded", this._logicalContentBytesUploaded); | ||
ciData.Add("PhysicalContentBytesUploaded", this._physicalContentBytesUploaded); | ||
ciData.Add("TotalNumberOfChunks", this._totalNumberOfChunks); | ||
|
||
var ciEvent = new CustomerIntelligenceEvent | ||
{ | ||
Area = "AzurePipelinesAgent", | ||
Feature = "BuildArtifacts", | ||
Properties = ciData | ||
}; | ||
await _ciClient.PublishEventsAsync(new [] { ciEvent }); | ||
} | ||
} | ||
} |
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
12 changes: 12 additions & 0 deletions
12
src/Microsoft.VisualStudio.Services.Agent/Blob/IDedupRecord.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,12 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using Microsoft.VisualStudio.Services.BlobStore.Common.Telemetry; | ||
|
||
namespace Microsoft.VisualStudio.Services.Agent.Blob | ||
{ | ||
public interface IDedupRecord | ||
{ | ||
DedupUploadStatistics UploadStatistics { get; } | ||
} | ||
} |
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
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
Oops, something went wrong.