Skip to content

Commit

Permalink
feat(rust): add tracing cutoff to background nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianbenavides committed Nov 13, 2024
1 parent 0859eaf commit c33886c
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 39 deletions.
16 changes: 10 additions & 6 deletions implementations/rust/ockam/ockam_api/src/logs/default_values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,14 @@ pub(crate) const DEFAULT_SPAN_EXPORT_QUEUE_SIZE: u16 = 32768;
// Size of the queue used to batch logs.
pub(crate) const DEFAULT_LOG_EXPORT_QUEUE_SIZE: u16 = 32768;

// Maximum time for sending log record batches when using a portal
pub(crate) const DEFAULT_FOREGROUND_LOG_EXPORT_PORTAL_CUTOFF: Duration =
Duration::from_millis(3000);
// Maximum time for sending log record batches when using a foreground node
pub(crate) const DEFAULT_FOREGROUND_LOG_EXPORT_CUTOFF: Duration = Duration::from_millis(3000);

// Maximum time for sending span batches when using a portal
pub(crate) const DEFAULT_FOREGROUND_SPAN_EXPORT_PORTAL_CUTOFF: Duration =
Duration::from_millis(3000);
// Maximum time for sending span batches when using a foreground node
pub(crate) const DEFAULT_FOREGROUND_SPAN_EXPORT_CUTOFF: Duration = Duration::from_millis(3000);

// Maximum time for sending log record batches when using a background node
pub(crate) const DEFAULT_BACKGROUND_LOG_EXPORT_CUTOFF: Duration = Duration::from_millis(3000);

// Maximum time for sending span batches when using a background node
pub(crate) const DEFAULT_BACKGROUND_SPAN_EXPORT_CUTOFF: Duration = Duration::from_millis(3000);
18 changes: 12 additions & 6 deletions implementations/rust/ockam/ockam_api/src/logs/env_variables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,20 @@ pub(crate) const OCKAM_SPAN_EXPORT_QUEUE_SIZE: &str = "OCKAM_SPAN_EXPORT_QUEUE_S
pub(crate) const OCKAM_LOG_EXPORT_QUEUE_SIZE: &str = "OCKAM_LOG_EXPORT_QUEUE_SIZE";

/// Maximum time for sending a log batch and not waiting for a response when running
/// a foreground command and using a portal to export log records. For example: 200ms
pub(crate) const OCKAM_FOREGROUND_LOG_EXPORT_PORTAL_CUTOFF: &str =
"OCKAM_FOREGROUND_LOG_EXPORT_PORTAL_CUTOFF";
/// a foreground command export log records. For example: 200ms
pub(crate) const OCKAM_FOREGROUND_LOG_EXPORT_CUTOFF: &str = "OCKAM_FOREGROUND_LOG_EXPORT_CUTOFF";

/// Maximum time for sending a span batch and not waiting for a response when running
/// a foreground command and using a portal to export span batches. For example: 200ms
pub(crate) const OCKAM_FOREGROUND_SPAN_EXPORT_PORTAL_CUTOFF: &str =
"OCKAM_FOREGROUND_SPAN_EXPORT_PORTAL_CUTOFF";
/// a foreground command to export span batches. For example: 200ms
pub(crate) const OCKAM_FOREGROUND_SPAN_EXPORT_CUTOFF: &str = "OCKAM_FOREGROUND_SPAN_EXPORT_CUTOFF";

/// Maximum time for sending a log batch and not waiting for a response when running
/// a background command to export log records. For example: 200ms
pub(crate) const OCKAM_BACKGROUND_LOG_EXPORT_CUTOFF: &str = "OCKAM_BACKGROUND_LOG_EXPORT_CUTOFF";

/// Maximum time for sending a span batch and not waiting for a response when running
/// a background command to export span batches. For example: 200ms
pub(crate) const OCKAM_BACKGROUND_SPAN_EXPORT_CUTOFF: &str = "OCKAM_BACKGROUND_SPAN_EXPORT_CUTOFF";

///
/// OPENTELEMETRY COLLECTOR ERRORS CONFIGURATION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ pub struct ExportingConfiguration {
/// This boolean is set on spans to distinguish internal usage for external usage
is_ockam_developer: bool,
/// Maximum time for exporting a batch of spans (with no response)
span_export_portal_cutoff: Option<Duration>,
span_export_cutoff: Option<Duration>,
/// Maximum time for exporting a batch of log records (with no response)
log_export_portal_cutoff: Option<Duration>,
log_export_cutoff: Option<Duration>,
}

impl ExportingConfiguration {
Expand Down Expand Up @@ -101,12 +101,12 @@ impl ExportingConfiguration {

/// Return the maximum time to wait until sending the current batch of spans (without waiting for a response)
pub fn span_export_cutoff(&self) -> Option<Duration> {
self.span_export_portal_cutoff
self.span_export_cutoff
}

/// Return the maximum time to wait until sending the current batch of log records (without waiting for a response)
pub fn log_export_cutoff(&self) -> Option<Duration> {
self.log_export_portal_cutoff
self.log_export_cutoff
}

/// Return the URL where to export spans and log records
Expand All @@ -132,8 +132,8 @@ impl ExportingConfiguration {
log_export_queue_size: log_export_queue_size()?,
opentelemetry_endpoint: endpoint.url(),
is_ockam_developer: is_ockam_developer()?,
span_export_portal_cutoff: Some(foreground_span_export_portal_cutoff().unwrap()),
log_export_portal_cutoff: Some(foreground_log_export_portal_cutoff().unwrap()),
span_export_cutoff: Some(foreground_span_export_portal_cutoff()?),
log_export_cutoff: Some(foreground_log_export_cutoff()?),
}),
}
}
Expand All @@ -155,8 +155,8 @@ impl ExportingConfiguration {
log_export_queue_size: log_export_queue_size()?,
opentelemetry_endpoint: endpoint.url(),
is_ockam_developer: is_ockam_developer()?,
span_export_portal_cutoff: None,
log_export_portal_cutoff: None,
span_export_cutoff: Some(background_span_export_portal_cutoff()?),
log_export_cutoff: Some(background_log_export_cutoff()?),
}),
}
}
Expand All @@ -173,8 +173,8 @@ impl ExportingConfiguration {
log_export_queue_size: DEFAULT_LOG_EXPORT_QUEUE_SIZE,
opentelemetry_endpoint: Self::default_opentelemetry_endpoint()?,
is_ockam_developer: is_ockam_developer()?,
span_export_portal_cutoff: None,
log_export_portal_cutoff: None,
span_export_cutoff: None,
log_export_cutoff: None,
})
}

Expand Down Expand Up @@ -489,19 +489,35 @@ pub fn background_log_export_scheduled_delay() -> ockam_core::Result<Duration> {
)
}

/// Return the maximum time for sending log record batches when using a portal
pub fn foreground_log_export_portal_cutoff() -> ockam_core::Result<Duration> {
/// Return the maximum time for sending log record batches when using a foreground node
pub fn foreground_log_export_cutoff() -> ockam_core::Result<Duration> {
get_env_with_default(
OCKAM_FOREGROUND_LOG_EXPORT_PORTAL_CUTOFF,
DEFAULT_FOREGROUND_LOG_EXPORT_PORTAL_CUTOFF,
OCKAM_FOREGROUND_LOG_EXPORT_CUTOFF,
DEFAULT_FOREGROUND_LOG_EXPORT_CUTOFF,
)
}

/// Return the maximum time for sending span batches when using a portal
/// Return the maximum time for sending span batches when using a foreground node
pub fn foreground_span_export_portal_cutoff() -> ockam_core::Result<Duration> {
get_env_with_default(
OCKAM_FOREGROUND_SPAN_EXPORT_PORTAL_CUTOFF,
DEFAULT_FOREGROUND_SPAN_EXPORT_PORTAL_CUTOFF,
OCKAM_FOREGROUND_SPAN_EXPORT_CUTOFF,
DEFAULT_FOREGROUND_SPAN_EXPORT_CUTOFF,
)
}

/// Return the maximum time for sending log record batches when using a background node
pub fn background_log_export_cutoff() -> ockam_core::Result<Duration> {
get_env_with_default(
OCKAM_BACKGROUND_LOG_EXPORT_CUTOFF,
DEFAULT_BACKGROUND_LOG_EXPORT_CUTOFF,
)
}

/// Return the maximum time for sending span batches when using a background node
pub fn background_span_export_portal_cutoff() -> ockam_core::Result<Duration> {
get_env_with_default(
OCKAM_BACKGROUND_SPAN_EXPORT_CUTOFF,
DEFAULT_BACKGROUND_SPAN_EXPORT_CUTOFF,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,6 @@ Database
- OCKAM_POSTGRES_USER: Postgres database user. If it is not set, no authorization will be used to access the database.
- OCKAM_POSTGRES_PASSWORD: Postgres database password. If it is not set, no authorization will be used to access the database.

- OCKAM_LOGGING: set this variable to any value in order to enable logging.
- OCKAM_LOG_LEVEL: a `string` that defines the verbosity of the logs when the `--verbose` argument is not passed: `info`, `warn`, `error`, `debug` or `trace`. Default value: `debug`.
- OCKAM_LOG_FORMAT: a `string` that overrides the default format of the logs: `default`, `json`, or `pretty`. Default value: `default`.
- OCKAM_LOG_MAX_SIZE_MB: an `integer` that defines the maximum size of a log file in MB. Default value `100`.
- OCKAM_LOG_MAX_FILES: an `integer` that defines the maximum number of log files to keep per node. Default value `60`.
- OCKAM_LOG_CRATES_FILTER: a filter for log messages based on crate names: `all`, `default`, comma-separated list of crate names. Default value: `default`, i.e. the list of `ockam` crates.

Tracing
- OCKAM_OPENTELEMETRY_EXPORT: set this variable to a false value to disable tracing: `0`, `false`, `no`. Default value: `true`
- OCKAM_OPENTELEMETRY_ENDPOINT: the URL of an OpenTelemetry collector accepting gRPC.
Expand All @@ -48,9 +41,10 @@ Tracing
- OCKAM_SPAN_EXPORT_QUEUE_SIZE: Size of the queue used to store batched spans before export. When the queue is full, spans are dropped. Default value: `32768`
- OCKAM_LOG_EXPORT_QUEUE_SIZE: Size of the queue used to store batched log records before export. When the queue is full, log records are dropped. Default value: `32768`
- OCKAM_TRACING_GLOBAL_ERROR_HANDLER: Configuration for printing tracing/logging errors: `console`, `logfile`, `off`. Default value: `logfile`.
- OCKAM_FOREGROUND_LOG_EXPORT_PORTAL_CUTOFF: Cutoff time for sending log records batches to an OpenTelemetry portal inlet, without waiting for a response. Default value: `3s`.
- OCKAM_FOREGROUND_SPAN_EXPORT_PORTAL_CUTOFF: Cutoff time for sending span batches to an OpenTelemetry portal inlet, without waiting for a response. Default value: `3s`.
- OCKAM_TRACING_GLOBAL_ERROR_HANDLER: Configuration for printing tracing/logging errors: `console`, `logfile`, `off`. Default value: `console`.
- OCKAM_FOREGROUND_LOG_EXPORT_CUTOFF: Cutoff time for sending log records batches to an OpenTelemetry foreground node, without waiting for a response. Default value: `3s`.
- OCKAM_FOREGROUND_SPAN_EXPORT_CUTOFF: Cutoff time for sending span batches to an OpenTelemetry foreground inlet, without waiting for a response. Default value: `3s`.
- OCKAM_BACKGROUND_LOG_EXPORT_CUTOFF: Cutoff time for sending log records batches to an OpenTelemetry baclground node, without waiting for a response. Default value: `3s`.
- OCKAM_BACKGROUND_SPAN_EXPORT_CUTOFF: Cutoff time for sending span batches to an OpenTelemetry background inlet, without waiting for a response. Default value: `3s`.

UDP Puncture
- OCKAM_RENDEZVOUS_SERVER: set this variable to the hostname and port of the Rendezvous service
Expand Down

0 comments on commit c33886c

Please sign in to comment.