Skip to content

Commit

Permalink
Merge branch 'main' into feat/dotnet-buffer-length
Browse files Browse the repository at this point in the history
  • Loading branch information
AndriiAndreiev committed Dec 10, 2024
2 parents ff74cd1 + 9514eef commit 8c73929
Show file tree
Hide file tree
Showing 9 changed files with 127 additions and 190 deletions.
129 changes: 25 additions & 104 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/dotnet/ReadMe/ConfigValues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,7 @@ public class Options
public int bufferLength { get; set; } = 1;

public string baseLogUrl { get; set; } = "https://example.readme.com";

public bool fireAndForget { get; set; } = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public ReadMeApiCaller(string harJsonObjects, string apiKey)
this.apiKey = apiKey;
}

public void SendHarObjToReadMeApi()
public void SendHarObjToReadMeApi(bool fireAndForget)
{
try
{
Expand All @@ -26,7 +26,14 @@ public void SendHarObjToReadMeApi()
string apiKey = "Basic " + Convert.ToBase64String(Encoding.UTF8.GetBytes(this.apiKey + ":"));
request.AddHeader("Authorization", apiKey);
request.AddParameter("application/json", this.harJsonObjects, ParameterType.RequestBody);
client.ExecuteAsync(request);
if (fireAndForget)
{
client.ExecuteAsync(request);
}
else
{
client.Execute(request);
}
}
catch (Exception)
{
Expand Down
7 changes: 6 additions & 1 deletion packages/dotnet/ReadMe/Metrics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public async Task InvokeAsync(HttpContext context)
{
string serializaedHars = JsonConvert.SerializeObject(this.harQueue);
ReadMeApiCaller readmeApiCaller = new ReadMeApiCaller(serializaedHars, configValues.apiKey);
readmeApiCaller.SendHarObjToReadMeApi();
readmeApiCaller.SendHarObjToReadMeApi(configValues.options.fireAndForget);
this.harQueue.Clear();
}
}
Expand Down Expand Up @@ -126,6 +126,11 @@ private ConfigValues GetConfigValues()
optionsObj.baseLogUrl = options.GetSection("baseLogUrl").Value;
}

if (options.GetSection("fireAndForget").Value != null)
{
optionsObj.fireAndForget = bool.Parse(options.GetSection("fireAndForget").Value);
}

configValues.options = optionsObj;
return configValues;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@
"prettier": "@readme/eslint-config/prettier",
"optionalDependencies": {
"pino": "^9.3.2",
"pino-pretty": "^11.2.2"
"pino-pretty": "^13.0.0"
}
}
Loading

0 comments on commit 8c73929

Please sign in to comment.