Skip to content

Commit 0a30e8f

Browse files
committed
Revert all related new AfterRecordingStartAsync handler
1 parent 266ebc2 commit 0a30e8f

File tree

7 files changed

+9
-45
lines changed

7 files changed

+9
-45
lines changed

DevProxy.Abstractions/Plugins/BasePlugin.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@ public virtual Task AfterRequestLogAsync(RequestLogArgs e, CancellationToken can
5555
return Task.CompletedTask;
5656
}
5757

58-
public virtual Task AfterRecordingStartAsync(EventArgs e, CancellationToken cancellationToken)
59-
{
60-
return Task.CompletedTask;
61-
}
62-
6358
public virtual Task AfterRecordingStopAsync(RecordingArgs e, CancellationToken cancellationToken)
6459
{
6560
return Task.CompletedTask;

DevProxy.Abstractions/Plugins/IPlugin.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ public interface IPlugin
2222
Task BeforeResponseAsync(ProxyResponseArgs e, CancellationToken cancellationToken);
2323
Task AfterResponseAsync(ProxyResponseArgs e, CancellationToken cancellationToken);
2424
Task AfterRequestLogAsync(RequestLogArgs e, CancellationToken cancellationToken);
25-
Task AfterRecordingStartAsync(EventArgs e, CancellationToken cancellationToken);
2625
Task AfterRecordingStopAsync(RecordingArgs e, CancellationToken cancellationToken);
2726
Task MockRequestAsync(EventArgs e, CancellationToken cancellationToken);
2827
}

DevProxy.Plugins/Inspection/OpenAITelemetryPlugin.cs

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ public sealed class OpenAITelemetryPlugin(
6767
private LanguageModelPricesLoader? _loader;
6868
private MeterProvider? _meterProvider;
6969
private TracerProvider? _tracerProvider;
70-
7170
private readonly ConcurrentDictionary<string, List<OpenAITelemetryPluginReportModelUsageInformation>> _modelUsage = [];
72-
private bool _isRecording;
7371

7472
public override string Name => nameof(OpenAITelemetryPlugin);
7573

@@ -194,16 +192,6 @@ public override Task AfterResponseAsync(ProxyResponseArgs e, CancellationToken c
194192
return Task.CompletedTask;
195193
}
196194

197-
public override Task AfterRecordingStartAsync(EventArgs e, CancellationToken cancellationToken)
198-
{
199-
Logger.LogTrace("{Method} called", nameof(AfterRecordingStartAsync));
200-
201-
_isRecording = true;
202-
203-
Logger.LogTrace("Left {Name}", nameof(AfterRecordingStartAsync));
204-
return Task.CompletedTask;
205-
}
206-
207195
public override Task AfterRecordingStopAsync(RecordingArgs e, CancellationToken cancellationToken)
208196
{
209197
Logger.LogTrace("{Method} called", nameof(AfterRecordingStopAsync));
@@ -218,7 +206,6 @@ public override Task AfterRecordingStopAsync(RecordingArgs e, CancellationToken
218206
};
219207

220208
StoreReport(report, e);
221-
_isRecording = false;
222209
_modelUsage.Clear();
223210

224211
Logger.LogTrace("Left {Name}", nameof(AfterRecordingStopAsync));
@@ -869,12 +856,8 @@ private void RecordUsageMetrics(Activity activity, OpenAIRequest request, OpenAI
869856
CompletionTokens = usage.CompletionTokens,
870857
CachedTokens = usage.PromptTokensDetails?.CachedTokens ?? 0L
871858
};
872-
873-
if (_isRecording)
874-
{
875-
var usagePerModel = _modelUsage.GetOrAdd(response.Model, model => []);
876-
usagePerModel.Add(reportModelUsageInformation);
877-
}
859+
var usagePerModel = _modelUsage.GetOrAdd(response.Model, model => []);
860+
usagePerModel.Add(reportModelUsageInformation);
878861

879862
if (!Configuration.IncludeCosts || Configuration.Prices is null)
880863
{

DevProxy/ApiControllers/ProxyController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public async Task<IActionResult> SetAsync([FromBody] ProxyInfo proxyInfo, Cancel
4242
{
4343
if (proxyInfo.Recording.Value)
4444
{
45-
await _proxyStateController.StartRecordingAsync(cancellationToken);
45+
_proxyStateController.StartRecording();
4646
}
4747
else
4848
{

DevProxy/Proxy/IProxyStateController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public interface IProxyStateController
99
#pragma warning restore CA1515
1010
{
1111
IProxyState ProxyState { get; }
12-
Task StartRecordingAsync(CancellationToken cancellationToken);
12+
void StartRecording();
1313
Task StopRecordingAsync(CancellationToken cancellationToken);
1414
Task MockRequestAsync(CancellationToken cancellationToken);
1515
void StopProxy();

DevProxy/Proxy/ProxyEngine.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
147147

148148
if (_config.Record)
149149
{
150-
await StartRecordingAsync(stoppingToken);
150+
StartRecording();
151151
}
152152

153153
if (_config.TimeoutSeconds.HasValue)
@@ -210,7 +210,7 @@ private async Task ReadKeysAsync(CancellationToken cancellationToken)
210210
#pragma warning restore IDE0010
211211
{
212212
case ConsoleKey.R:
213-
await StartRecordingAsync(cancellationToken);
213+
StartRecording();
214214
break;
215215
case ConsoleKey.S:
216216
await StopRecordingAsync(cancellationToken);
@@ -225,14 +225,14 @@ private async Task ReadKeysAsync(CancellationToken cancellationToken)
225225
}
226226
}
227227

228-
private async Task StartRecordingAsync(CancellationToken cancellationToken)
228+
private void StartRecording()
229229
{
230230
if (_proxyController.ProxyState.IsRecording)
231231
{
232232
return;
233233
}
234234

235-
await _proxyController.StartRecordingAsync(cancellationToken);
235+
_proxyController.StartRecording();
236236
}
237237

238238
private async Task StopRecordingAsync(CancellationToken cancellationToken)

DevProxy/Proxy/ProxyStateController.cs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ sealed class ProxyStateController(
2323
private readonly ILogger _logger = logger;
2424
private ExceptionHandler ExceptionHandler => ex => _logger.LogError(ex, "An error occurred in a plugin");
2525

26-
public async Task StartRecordingAsync(CancellationToken cancellationToken)
26+
public void StartRecording()
2727
{
2828
if (ProxyState.IsRecording)
2929
{
@@ -32,19 +32,6 @@ public async Task StartRecordingAsync(CancellationToken cancellationToken)
3232

3333
ProxyState.IsRecording = true;
3434
PrintRecordingIndicator(ProxyState.IsRecording);
35-
36-
var eventArgs = EventArgs.Empty;
37-
foreach (var plugin in _plugins.Where(p => p.Enabled))
38-
{
39-
try
40-
{
41-
await plugin.AfterRecordingStartAsync(eventArgs, cancellationToken);
42-
}
43-
catch (Exception ex)
44-
{
45-
ExceptionHandler(ex);
46-
}
47-
}
4835
}
4936

5037
public async Task StopRecordingAsync(CancellationToken cancellationToken)

0 commit comments

Comments
 (0)