Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Profiler] Add HttpClient copy as curl feature #37691

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

Conversation

noniagriconomie
Copy link
Contributor

Q A
Branch? master
Bug fix? no
New feature? yes
Deprecations? no
Tickets Part of #33311
License MIT
Doc PR none

PR draft

Folowing #37690
i wanted to see some issues on the httpclient and found this one #33311

i can work on both ping @nicolas-grekas

- when a transport error occurs, (ie the "error" info is populated) we should maybe have a better display too?

what do you have in mind for we should maybe have a better display too?

- add a copy-as-curl button next to each request

curl request can be complex, what is the MVP wanted here?

Thanks :)

@noniagriconomie noniagriconomie force-pushed the feature-http-client-profiler-curl branch from e987f84 to a00ba1b Compare July 28, 2020 21:30
{% endblock %}

{% macro render_curl(trace) %}
curl "{{ trace.url }}" --compressed -H "Connection: keep-alive" -v
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we can provide a reusable service (request to curl) that be neat :) i believe there are some CurlBuilders in the wild to take inspiration from.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, I would say that it must at least include the method and the headers. For the body, that's harder.

Also, be careful about the fact that you need to escape " in the command arguments (or even better apply proper shell escaping, which might imply moving this logic to a helper method in the collector class rather than doing it in a twig macro)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moving this logic to a helper method in the collector class

would there be any reason to not make it a first class feature, if we want this feature for the profiler?

a usecase i have in mind is adding the curl command in some log entries its context. Or perhaps display in CLI verbose mode.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, if you want to make it a first-class feature, the argument of this API cannot be the internal data structure of this collector

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it will be easier in the datacollector, agreed i'll move this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'll check this thx

@nicolas-grekas nicolas-grekas added this to the next milestone Jul 29, 2020

document.querySelectorAll('[data-clipboard-text]').forEach(function(button) {
button.addEventListener('click', function() {
navigator.clipboard.writeText(button.getAttribute('data-clipboard-text'));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of writing support for Copy to clipboard as an inline script in this panel, I suggest adding such a feature in the shared JS of the profiler pages, so that it can be reused by any other panel too (as we do for tabs and toggles).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll refactor indeed

@nicolas-grekas
Copy link
Member

Closing because this staled and there is a lot of work remaining. Please resubmit when you think this is ready for review (not as a draft then :) )

@noniagriconomie
Copy link
Contributor Author

Agreed, will try to find time to continue this if i can
Thx

@derrabus
Copy link
Member

@noniagriconomie How far is your progress? I need this feature for my current project and was thinking about building it for myself. In case you're not actively working on the feature: Any objects if I take over? I don't want to steal your contribution.

@noniagriconomie
Copy link
Contributor Author

hi @derrabus no i am no more working on it, this one was really a POC/RFC mainly to gather feedbacks/ideas

for now i just got time to finish my other PR #37880

feel free to ping for review 👍

@derrabus
Copy link
Member

Will do, thanks!

@maranqz
Copy link
Contributor

maranqz commented Feb 24, 2021

I want to continue this PR; however, there is not all data in trace to generate correct CURL command.

Trace contains only method, url and raw options without preparing such as json.
image

I think HttpClientInterface needs to be rewritten to support this feature.
Is there is more elegant solution to get necessary data?

@noniagriconomie
Copy link
Contributor Author

Maybe open a new issue linking this one as reference to discuss the continuity/specifications @maranqz

@noniagriconomie noniagriconomie deleted the feature-http-client-profiler-curl branch February 24, 2021 21:33
@derrabus
Copy link
Member

@maranqz No, you need to save more information in the trace than we currently do. That's more or less why I haven't made much progress on the PR either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants