Skip to content

Commit

Permalink
rename otlp-tonic to otlp-grpc
Browse files Browse the repository at this point in the history
The cargo feature name should match the actual feature, not the
implementation detail
  • Loading branch information
Geal committed Nov 19, 2021
1 parent b1feaa4 commit 3a84c54
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions crates/apollo-router/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ name = "router"
path = "src/main.rs"

[features]
default = ["otlp-tonic"]
default = ["otlp-grpc"]
# activates OTLP/gRPC
otlp-tonic = [
otlp-grpc = [
"opentelemetry-otlp/tonic",
"opentelemetry-otlp/tonic-build",
"opentelemetry-otlp/prost",
"tonic",
]
# activates OTLP/HTTP
otlp-http = ["opentelemetry-otlp/http-proto"]
tls = ["opentelemetry-otlp/tls", "tonic/transport", "tonic/tls", "otlp-tonic"]
tls = ["opentelemetry-otlp/tls", "tonic/transport", "tonic/tls", "otlp-grpc"]

[dependencies]
anyhow = "1.0.47"
Expand Down
12 changes: 6 additions & 6 deletions crates/apollo-router/src/configuration/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Logic for loading configuration in to an object model

#[cfg(any(feature = "otlp-tonic", feature = "otlp-http"))]
#[cfg(any(feature = "otlp-grpc", feature = "otlp-http"))]
pub mod otlp;

use apollo_router_core::prelude::*;
Expand Down Expand Up @@ -199,7 +199,7 @@ impl Cors {
#[allow(clippy::large_enum_variant)]
pub enum OpenTelemetry {
Jaeger(Option<Jaeger>),
#[cfg(any(feature = "otlp-tonic", feature = "otlp-http"))]
#[cfg(any(feature = "otlp-grpc", feature = "otlp-http"))]
Otlp(otlp::Otlp),
}

Expand Down Expand Up @@ -312,7 +312,7 @@ mod tests {
assert_config_snapshot!("testdata/config_opentelemetry_jaeger_full.yml");
}

#[cfg(any(feature = "otlp-tonic", feature = "otlp-http"))]
#[cfg(any(feature = "otlp-grpc", feature = "otlp-http"))]
#[test]
fn ensure_configuration_api_does_not_change_common() {
// NOTE: don't take a snapshot here because the optional fields appear with ~ and they vary
Expand All @@ -324,14 +324,14 @@ mod tests {
))
.unwrap();

#[cfg(feature = "otlp-tonic")]
#[cfg(feature = "otlp-grpc")]
serde_yaml::from_str::<Configuration>(include_str!(
"testdata/config_opentelemetry_otlp_tracing_tonic_common.yml"
))
.unwrap();
}

#[cfg(feature = "otlp-tonic")]
#[cfg(feature = "otlp-grpc")]
#[test]
fn ensure_configuration_api_does_not_change_tonic() {
assert_config_snapshot!("testdata/config_opentelemetry_otlp_tracing_tonic_basic.yml");
Expand All @@ -345,7 +345,7 @@ mod tests {
assert_config_snapshot!("testdata/config_opentelemetry_otlp_tracing_http_full.yml");
}

#[cfg(all(feature = "tls", feature = "otlp-tonic"))]
#[cfg(all(feature = "tls", feature = "otlp-grpc"))]
#[test]
fn ensure_configuration_api_does_not_change_tls_config() {
assert_config_snapshot!("testdata/config_opentelemetry_otlp_tracing_tonic_tls.yml");
Expand Down
10 changes: 5 additions & 5 deletions crates/apollo-router/src/configuration/otlp/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#[cfg(feature = "otlp-http")]
mod http;
#[cfg(feature = "otlp-tonic")]
#[cfg(feature = "otlp-grpc")]
mod tonic;

#[cfg(feature = "otlp-http")]
pub use self::http::*;
#[cfg(feature = "otlp-tonic")]
#[cfg(feature = "otlp-grpc")]
pub use self::tonic::*;
use crate::configuration::ConfigurationError;
use opentelemetry::sdk::resource::Resource;
Expand All @@ -32,7 +32,7 @@ pub struct Tracing {
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(deny_unknown_fields, rename_all = "snake_case")]
pub enum Exporter {
#[cfg(feature = "otlp-tonic")]
#[cfg(feature = "otlp-grpc")]
Grpc(TonicExporter),
#[cfg(feature = "otlp-http")]
Http(HttpExporter),
Expand All @@ -41,7 +41,7 @@ pub enum Exporter {
impl Exporter {
pub fn exporter(&self) -> Result<opentelemetry_otlp::SpanExporterBuilder, ConfigurationError> {
match &self {
#[cfg(feature = "otlp-tonic")]
#[cfg(feature = "otlp-grpc")]
Exporter::Grpc(exporter) => Ok(exporter.exporter()?.into()),
#[cfg(feature = "otlp-http")]
Exporter::Http(exporter) => Ok(exporter.exporter()?.into()),
Expand All @@ -53,7 +53,7 @@ impl Exporter {
match std::env::var("ROUTER_TRACING").as_deref() {
#[cfg(feature = "otlp-http")]
Ok("http") => Ok(HttpExporter::exporter_from_env().into()),
#[cfg(feature = "otlp-tonic")]
#[cfg(feature = "otlp-grpc")]
Ok("tonic") => Ok(TonicExporter::exporter_from_env().into()),
Ok(val) => Err(ConfigurationError::InvalidEnvironmentVariable(format!(
"unrecognized value for ROUTER_TRACING: {}",
Expand Down
2 changes: 1 addition & 1 deletion crates/apollo-router/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ fn try_initialize_subscriber(
opentelemetry::global::set_error_handler(handle_error)?;
return Ok(Some(Arc::new(subscriber.with(telemetry))));
}
#[cfg(any(feature = "otlp-tonic", feature = "otlp-http"))]
#[cfg(any(feature = "otlp-grpc", feature = "otlp-http"))]
Some(OpenTelemetry::Otlp(configuration::otlp::Otlp::Tracing(tracing))) => {
let tracer = if let Some(tracing) = tracing.as_ref() {
tracing.tracer()?
Expand Down
2 changes: 1 addition & 1 deletion xtask/src/commands/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use anyhow::{ensure, Result};
use structopt::StructOpt;
use xtask::*;

const FEATURE_SETS: &[&[&str]] = &[&[], &["otlp-http"], &["otlp-tonic"], &["otlp-tonic", "tls"]];
const FEATURE_SETS: &[&[&str]] = &[&[], &["otlp-http"], &["otlp-grpc"], &["otlp-grpc", "tls"]];

#[derive(Debug, StructOpt)]
pub struct Test {
Expand Down

0 comments on commit 3a84c54

Please sign in to comment.