Skip to content

Commit

Permalink
fix: otel-otlp http client, deployment request (#1765)
Browse files Browse the repository at this point in the history
* fix: otel-otlp features for http client

* fix: otel collector http port

* fix: deployment request fields ser/de
  • Loading branch information
jonaro00 authored May 8, 2024
1 parent 8671518 commit f947dee
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 14 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ once_cell = "1.16.0"
opentelemetry = "0.21.0"
opentelemetry_sdk = { version = "0.21.0", features = ["rt-tokio", "logs"] }
opentelemetry-http = "0.10.0"
opentelemetry-otlp = { version = "0.14.0", features = ["logs", "grpc-tonic", "http-proto"] }
opentelemetry-otlp = { version = "0.14.0", features = ["logs", "http-proto", "reqwest-client", "reqwest-rustls"] }
opentelemetry-proto = "0.4.0"
opentelemetry-contrib = { version = "0.4.0", features = ["datadog"] }
opentelemetry-appender-tracing = "0.2.0"
Expand Down
2 changes: 1 addition & 1 deletion backends/src/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use shuttle_common::log::Backend;

use super::otlp_tracing_bridge::{self, ErrorTracingLayer};

const OTLP_ADDRESS: &str = "http://otel-collector:4317";
const OTLP_ADDRESS: &str = "http://otel-collector:4318";

pub fn setup_tracing<S>(subscriber: S, backend: Backend)
where
Expand Down
4 changes: 2 additions & 2 deletions cargo-shuttle/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use reqwest::{RequestBuilder, Response};
use serde::{Deserialize, Serialize};
use shuttle_common::constants::headers::X_CARGO_SHUTTLE_VERSION;
use shuttle_common::log::LogsRange;
use shuttle_common::models::deployment::DeploymentRequest;
use shuttle_common::models::deployment::{DeploymentRequest, DeploymentRequestBeta};
use shuttle_common::models::team;
use shuttle_common::models::{deployment, project, service, ToJson};
use shuttle_common::{resource, ApiKey, LogItem, VersionInfo};
Expand Down Expand Up @@ -108,7 +108,7 @@ impl ShuttleApiClient {
pub async fn deploy_beta(
&self,
project: &str,
deployment_req: DeploymentRequest,
deployment_req: DeploymentRequestBeta,
) -> Result<deployment::EcsResponse> {
let path = format!("/projects/{project}");
let deployment_req = rmp_serde::to_vec(&deployment_req)
Expand Down
16 changes: 12 additions & 4 deletions cargo-shuttle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use ignore::overrides::OverrideBuilder;
use ignore::WalkBuilder;
use indicatif::ProgressBar;
use indoc::{formatdoc, printdoc};
use shuttle_common::models::deployment::deployments_table_beta;
use shuttle_common::models::deployment::{deployments_table_beta, DeploymentRequestBeta};
use shuttle_common::{
constants::{
API_URL_DEFAULT, DEFAULT_IDLE_MINUTES, EXAMPLES_REPO, EXECUTABLE_DIRNAME,
Expand Down Expand Up @@ -1756,6 +1756,9 @@ impl Shuttle {
no_test: args.no_test,
..Default::default()
};
let mut deployment_req_beta = DeploymentRequestBeta {
..Default::default()
};

if self.beta {
let manifest_path = working_directory.join("Cargo.toml");
Expand All @@ -1779,7 +1782,7 @@ impl Shuttle {

trace!(keys = ?secrets.keys(), "available secrets");

deployment_req.secrets = Some(secrets);
deployment_req_beta.secrets = Some(secrets);
} else {
trace!("No secrets were loaded");
}
Expand All @@ -1794,7 +1797,7 @@ impl Shuttle {
.expect("at least one shuttle crate in the workspace")
.name
.to_owned();
deployment_req.package_name = Some(package_name);
deployment_req_beta.package_name = package_name;
}

if let Ok(repo) = Repository::discover(working_directory) {
Expand Down Expand Up @@ -1839,8 +1842,13 @@ impl Shuttle {

// End this early for beta platform.
if self.beta {
deployment_req_beta.data = deployment_req.data;
deployment_req_beta.git_commit_id = deployment_req.git_commit_id;
deployment_req_beta.git_commit_msg = deployment_req.git_commit_msg;
deployment_req_beta.git_branch = deployment_req.git_branch;
deployment_req_beta.git_dirty = deployment_req.git_dirty;
let deployment = client
.deploy_beta(self.ctx.project_name(), deployment_req)
.deploy_beta(self.ctx.project_name(), deployment_req_beta)
.await
.map_err(suggestions::deploy::deploy_request_failure)?;

Expand Down
22 changes: 16 additions & 6 deletions common/src/models/deployment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,16 +409,26 @@ pub fn get_deployments_table(

#[derive(Default, Deserialize, Serialize)]
pub struct DeploymentRequest {
/// Alpha: tar archive. Beta: zip archive.
/// Alpha: tar archive.
pub data: Vec<u8>,
/// The cargo package name to compile and run. Required on beta.
pub package_name: Option<String>,
/// Secrets to add before this deployment. Ignored on alpha.
pub secrets: Option<HashMap<String, String>>,
/// Ignored on beta.
pub no_test: bool,
pub git_commit_id: Option<String>,
pub git_commit_msg: Option<String>,
pub git_branch: Option<String>,
pub git_dirty: Option<bool>,
}

#[derive(Default, Deserialize, Serialize)]
pub struct DeploymentRequestBeta {
/// Beta: zip archive.
pub data: Vec<u8>,
/// The cargo package name to compile and run.
pub package_name: String,
/// Secrets to add before this deployment.
/// Might remove this in favour of a separate secrets uploading action.
pub secrets: Option<HashMap<String, String>>,
pub git_commit_id: Option<String>,
pub git_commit_msg: Option<String>,
pub git_branch: Option<String>,
pub git_dirty: Option<bool>,
}
1 change: 1 addition & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ services:
otel-collector:
ports:
- 4317:4317
- 4318:4318
logger:
ports:
- 8010:8000
Expand Down

0 comments on commit f947dee

Please sign in to comment.