-
Notifications
You must be signed in to change notification settings - Fork 90
feat(stdlib): add http_request
function
#1360
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
base: main
Are you sure you want to change the base?
Conversation
bench_function! { | ||
http_request => vrl::stdlib::HttpRequest; | ||
|
||
http_request { | ||
args: func_args![ | ||
url: value!("https://httpbin.org/bearer"), | ||
headers: value!({"accept": "application/json", "Authorization": "Bearer my_token"}) | ||
], | ||
want: Ok(r#"{"authenticated": true, "token": "my_token"}"#), | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this benchmark since making network calls like this isn't very reliable, running this specific benchmark gives back:
Benchmarking vrl_stdlib/functions/http_request/http_request: Warming up for 3.0000 s
Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 154.0s, or reduce sample count to 10.
Benchmarking vrl_stdlib/functions/http_request/http_request: Collecting 100 samples in estimated 154.03 s (100 iterations)
vrl_stdlib/functions/http_request/http_request
time: [1.4146 s 1.5196 s 1.6320 s]
thrpt: [0.6128 elem/s 0.6581 elem/s 0.7069 elem/s]
Found 9 outliers among 100 measurements (9.00%)
8 (8.00%) high mild
1 (1.00%) high severe
Maybe something with warp would be more useful
// Create a new Tokio runtime as a fallback | ||
let runtime = Runtime::new().expect("Failed to create Tokio runtime"); | ||
runtime.block_on(async { http_request(&url, &method, headers).await }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was added to allow the bench function to run -- AFAICT it isn't needed apart from that since the Vector runtime can be accessed with Handle::current()
Summary
This PR adds a HTTP request function, allowing users to fetch data from external sources.
Change Type
Is this a breaking change?
How did you test this PR?
Added tests, otherwise currently running this in a Kubernetes environment via Helm.
Does this PR include user facing changes?
our guidelines.
dns_lookup
)Checklist
run
dd-rust-license-tool write
and commit the changes. More details here.References
Closes #1359