Skip to content

Commit

Permalink
Added default feature check to pre-commit to catch errors between all…
Browse files Browse the repository at this point in the history
… and default features (not just all) and fixed that type of error (#18)
  • Loading branch information
zakstucke authored Feb 13, 2024
1 parent 1ffd551 commit b9c3eec
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
20 changes: 18 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,21 @@ repos:
types: [rust]
args: [--manifest-path=./rust/Cargo.toml, --]
- id: cargo-check
name: cargo-check
name: cargo-check-all-features
description: Check the package for errors.
entry: cargo +nightly check
language: rust
types: [rust]
args: [--manifest-path=./rust/Cargo.toml, --all-features]
pass_filenames: false
- id: cargo-check
name: cargo-check-default-features
description: Check the package for errors.
entry: cargo +nightly check
language: rust
types: [rust]
args: [--manifest-path=./rust/Cargo.toml]
pass_filenames: false
- id: cargo-clippy
name: cargo-clippy
description: Lint rust sources
Expand All @@ -104,13 +112,21 @@ repos:
types: [rust]
args: [--manifest-path=./py_rust/Cargo.toml, --]
- id: cargo-check
name: cargo-check
name: cargo-check-all-features
description: Check the package for errors.
entry: cargo +nightly check
language: rust
types: [rust]
args: [--manifest-path=./py_rust/Cargo.toml, --all-features]
pass_filenames: false
- id: cargo-check
name: cargo-check-default-features
description: Check the package for errors.
entry: cargo +nightly check
language: rust
types: [rust]
args: [--manifest-path=./py_rust/Cargo.toml]
pass_filenames: false
- id: cargo-clippy
name: cargo-clippy
description: Lint rust sources
Expand Down
21 changes: 12 additions & 9 deletions rust/bitbazaar/logging/global_log/out.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,19 @@ impl GlobalLog {
///
/// Note there doesn't seem to be an underlying interface to force through metrics.
pub fn flush(&self) -> Result<(), AnyErr> {
if let Some(prov) = &self.otlp_providers.logger_provider {
prov.force_flush();
#[cfg(feature = "opentelemetry")]
{
if let Some(prov) = &self.otlp_providers.logger_provider {
prov.force_flush();
}
if let Some(prov) = &self.otlp_providers.tracer_provider {
prov.force_flush();
}
self.otlp_providers
.meter_provider
.force_flush()
.change_context(AnyErr)?;
}
if let Some(prov) = &self.otlp_providers.tracer_provider {
prov.force_flush();
}
self.otlp_providers
.meter_provider
.force_flush()
.change_context(AnyErr)?;
Ok(())
}
}
4 changes: 2 additions & 2 deletions rust/bitbazaar/logging/global_log/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use tracing_subscriber::{
};

use super::{builder::GlobalLogBuilder, GlobalLog};
use crate::{misc::is_tcp_port_listening, prelude::*};
use crate::prelude::*;

/// Need the write trait for our write function.
impl std::io::Write for super::builder::CustomConf {
Expand Down Expand Up @@ -112,7 +112,7 @@ pub fn builder_into_global_log(builder: GlobalLogBuilder) -> Result<GlobalLog, A
use opentelemetry_otlp::{new_exporter, new_pipeline, WithExportConfig};
use opentelemetry_sdk::{logs as sdklogs, resource, trace as sdktrace};

if !is_tcp_port_listening("localhost", otlp.port)? {
if !crate::misc::is_tcp_port_listening("localhost", otlp.port)? {
return Err(anyerr!("Can't connect to open telemetry collector on local port {}. Are you sure it's running?", otlp.port));
}

Expand Down

0 comments on commit b9c3eec

Please sign in to comment.