-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a72da1
commit dc5aeaa
Showing
4 changed files
with
60 additions
and
9 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,48 @@ | ||
// Copyright 2021-Present Datadog, Inc. https://www.datadoghq.com/ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// todo: delete file; Exporter has been removed | ||
use crate::exporter::Uri; | ||
use ddcommon_net::compat::Endpoint; | ||
use ddcommon_net::dep::http; | ||
use std::borrow::Cow; | ||
use std::str::FromStr; | ||
|
||
pub trait ProfilingEndpoint { | ||
fn profiling_agentless( | ||
site: impl AsRef<str>, | ||
api_key: Cow<'static, str>, | ||
) -> http::Result<Endpoint>; | ||
fn profiling_agent<U: TryInto<Uri>>(uri: U) -> Result<Endpoint, http::Error> | ||
where | ||
http::Error: From<U::Error>; | ||
} | ||
|
||
impl ProfilingEndpoint for Endpoint { | ||
fn profiling_agentless( | ||
site: impl AsRef<str>, | ||
api_key: Cow<'static, str>, | ||
) -> http::Result<Endpoint> { | ||
let intake_url = format!("https://intake.profile.{}/api/v2/profile", site.as_ref()); | ||
Ok(Self { | ||
url: Uri::try_from(intake_url)?, | ||
api_key: Some(api_key), | ||
timeout_ms: 0, | ||
test_token: None, | ||
}) | ||
} | ||
|
||
fn profiling_agent<U: TryInto<Uri>>(uri: U) -> Result<Endpoint, http::Error> | ||
where | ||
http::Error: From<U::Error>, | ||
{ | ||
let mut parts = uri.try_into()?.into_parts(); | ||
parts.path_and_query = Some(http::uri::PathAndQuery::from_str("/profiling/v1/input")?); | ||
let url = Uri::from_parts(parts)?; | ||
Ok(Self { | ||
url, | ||
api_key: None, | ||
timeout_ms: 0, | ||
test_token: None, | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters