Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Add an event for Repro VM creation #3091

Merged
merged 1 commit into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/ApiService/ApiService/Functions/ReproVmss.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Net;
using System.Security.Cryptography;
using System.Text;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;

Expand Down Expand Up @@ -81,6 +83,14 @@ private async Async.Task<HttpResponseData> Post(HttpRequestData req) {
"repro_vm create");
}

// we’d like to track the usage of this feature;
// anonymize the user ID so we can distinguish multiple requests
{
var data = userInfo.OkV.UserInfo.ToString(); // rely on record ToString
var hash = Convert.ToBase64String(SHA256.HashData(Encoding.UTF8.GetBytes(data)));
_log.Event($"created repro VM, user distinguisher: {hash:Tag:UserHash}");
}

var response = req.CreateResponse(HttpStatusCode.OK);
await response.WriteAsJsonAsync(vm.OkV);
return response;
Expand Down
2 changes: 1 addition & 1 deletion src/ApiService/ApiService/Log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Microsoft.OneFuzz.Service;
[InterpolatedStringHandler]
public struct LogStringHandler {

private StringBuilder _builder;
private readonly StringBuilder _builder;
private Dictionary<string, string>? _tags;

public LogStringHandler(int literalLength, int formattedCount) {
Expand Down