-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feature(enterprise): configurable app name #18554
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
Changes from 8 commits
99c53bb
a105d7d
9625858
39b9c7b
94decfe
2f2f4e7
aad4c20
20c1b08
0a69f0e
2cc23ac
fad4306
798fcca
b9b5543
698f525
790a97a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -95,6 +95,7 @@ pub struct LogApiService { | |
| client: HttpClient, | ||
| uri: Uri, | ||
| user_provided_headers: IndexMap<HeaderName, HeaderValue>, | ||
| default_headers: IndexMap<HeaderName, HeaderValue>, | ||
| } | ||
|
|
||
| impl LogApiService { | ||
|
|
@@ -103,12 +104,26 @@ impl LogApiService { | |
| uri: Uri, | ||
| headers: IndexMap<String, String>, | ||
| ) -> crate::Result<Self> { | ||
| let headers = validate_headers(&headers)?; | ||
| let user_provided_headers = validate_headers(&headers)?; | ||
|
|
||
| // Note that these headers cannot be overriden by the user. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this documented?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No. I'm not sure if we'd want to document this. The user should never want to modify these values unless for some nefarious reasons. |
||
| let default_headers = &[ | ||
| (CONTENT_TYPE.to_string(), "application/json".to_string()), | ||
| ( | ||
| "DD-EVP-ORIGIN".to_string(), | ||
| crate::get_app_name().to_lowercase().replace(' ', "_"), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know it's only used in one place at the moment, but I could definitely see this being used in other places in the future if we wanted to pull it up. |
||
| ), | ||
| ("DD-EVP-ORIGIN-VERSION".to_string(), crate::get_version()), | ||
| ] | ||
| .into_iter() | ||
| .collect(); | ||
| let default_headers = validate_headers(default_headers)?; | ||
|
|
||
| Ok(Self { | ||
| client, | ||
| uri, | ||
| user_provided_headers: headers, | ||
| user_provided_headers, | ||
| default_headers, | ||
| }) | ||
| } | ||
| } | ||
|
|
@@ -126,11 +141,8 @@ impl Service<LogApiRequest> for LogApiService { | |
| // Emission of Error internal event is handled upstream by the caller | ||
| fn call(&mut self, mut request: LogApiRequest) -> Self::Future { | ||
| let mut client = self.client.clone(); | ||
| let http_request = Request::post(&self.uri) | ||
| .header(CONTENT_TYPE, "application/json") | ||
| .header("DD-EVP-ORIGIN", "vector") | ||
| .header("DD-EVP-ORIGIN-VERSION", crate::get_version()) | ||
| .header("DD-API-KEY", request.api_key.to_string()); | ||
| let http_request = | ||
| Request::post(&self.uri).header("DD-API-KEY", request.api_key.to_string()); | ||
|
|
||
| let http_request = if let Some(ce) = request.compression.content_encoding() { | ||
| http_request.header(CONTENT_ENCODING, ce) | ||
|
|
@@ -149,6 +161,9 @@ impl Service<LogApiRequest> for LogApiService { | |
| // Replace rather than append to any existing header values | ||
| headers.insert(name, value.clone()); | ||
| } | ||
| for (name, value) in &self.default_headers { | ||
| headers.insert(name, value.clone()); | ||
| } | ||
| } | ||
|
|
||
| let http_request = http_request | ||
|
|
||
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 can see this coming in handy in other places too in the future.