Skip to content
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

Implement Detailed Request Timing in Dio #2336

Closed
TheWalkingDead1024 opened this issue Nov 28, 2024 · 2 comments
Closed

Implement Detailed Request Timing in Dio #2336

TheWalkingDead1024 opened this issue Nov 28, 2024 · 2 comments
Labels
s: feature This issue indicates a feature request

Comments

@TheWalkingDead1024
Copy link

Request Statement

Hello Dio team,

I'm a frequent user of Dio in my Flutter projects and find it highly efficient. However, I've encountered a need for more granular timing data for HTTP requests, similar to what's available in native iOS and Android development.

Feature Request: Detailed Request Timing Analysis

It would be extremely beneficial to have the ability to log detailed timing for each stage of an HTTP request within Dio. This includes:

DNS Lookup
TCP Handshake
SSL Handshake
Time to First Byte (TTFB)
Download Time
Such a feature would aid in performance debugging, optimization, and monitoring, providing insights comparable to native platforms.

Proposed Implementation:

Extend Interceptor with timing hooks for each stage.
Add a Dio configuration for detailed timing, outputting metrics.
Example:

Dio dio = Dio();
dio.interceptors.add(TimingInterceptor());

class TimingInterceptor extends Interceptor {
  @override
  Future onRequest(RequestOptions options, RequestInterceptorHandler handler) async {
    final startTime = DateTime.now();
    var response = await handler.next(options);
    final duration = DateTime.now().difference(startTime);
    print('Request Timing: $duration');
    return response;
  }
}

This feature would enhance Dio's capabilities and align it with native network analysis tools. I'm keen to contribute if possible.

Thank you for considering this request.

Best regards,

Solution Brainstorm

No response

@TheWalkingDead1024 TheWalkingDead1024 added the s: feature This issue indicates a feature request label Nov 28, 2024
@TheWalkingDead1024
Copy link
Author

Hello. I wanted to follow up on this issue as it has been two weeks without any response. Could anyone provide any updates or insights on this matter? It is quite important for the projects I am currently working on, and I would greatly appreciate any feedback or suggestions on possible workarounds.

@AlexV525
Copy link
Member

The library builds on top of high-level HTTP implementation (dart:io::HttpClient). To be aware of these sequences, AFAIK, you need to build the client from the start to override those functions or switch to other adapters like native_dio_adapter that might be helpful with platform-specific APIs. There is not much the library can do on its interface.

@AlexV525 AlexV525 closed this as not planned Won't fix, can't repro, duplicate, stale Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s: feature This issue indicates a feature request
Projects
None yet
Development

No branches or pull requests

2 participants