Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/common/runtime/src/otel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ fn resource() -> Resource {
SCHEMA_URL,
);

if let Ok(v) = std::env::var("RIVET_NAMESPACE") {
resource = resource.with_attribute(KeyValue::new("namespace", v));
}
if let Ok(v) = std::env::var("RIVET_CLUSTER_ID") {
resource = resource.with_attribute(KeyValue::new("cluster_id", v));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ pub fn configure(config: &rivet_config::Config) -> GlobalResult<String> {
.unwrap_or(0.001);

Ok(include_str!("../../files/rivet_guard_configure.sh")
.replace("__NAMESPACE__", &server_config.rivet.namespace)
.replace(
"__RIVET_GUARD_CONFIG__",
&serde_json::to_string_pretty(&guard_config_json)?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ pub fn configure(config: &rivet_config::Config) -> GlobalResult<String> {
.unwrap_or(0.001);

Ok(include_str!("../../files/rivet_worker_configure.sh")
.replace("__NAMESPACE__", &server_config.rivet.namespace)
.replace(
"__RIVET_EDGE_CONFIG__",
&serde_json::to_string_pretty(&edge_config_json)?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub struct PrometheusTarget {
pub scrape_interval: usize,
}

pub fn configure(config: &Config, pool_type: PoolType) -> GlobalResult<String> {
pub fn configure(namespace: &str, config: &Config, pool_type: PoolType) -> GlobalResult<String> {
let sources = config
.prometheus_targets
.keys()
Expand All @@ -43,6 +43,7 @@ pub fn configure(config: &Config, pool_type: PoolType) -> GlobalResult<String> {
"inputs": ["filter_metrics"],
"source": formatdoc!(
r#"
.tags.namespace = "{namespace}"
.tags.server_id = "___SERVER_ID___"
.tags.datacenter_id = "___DATACENTER_ID___"
.tags.cluster_id = "___CLUSTER_ID___"
Expand Down Expand Up @@ -87,6 +88,7 @@ pub fn configure(config: &Config, pool_type: PoolType) -> GlobalResult<String> {
r#"
.source = "pegboard_manager"

.namespace = "{namespace}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Namespace field added at root level for pegboard logs, while metrics use .tags.namespace. Consider using consistent structure

.client_id = "___SERVER_ID___"
.server_id = "___SERVER_ID___"
.datacenter_id = "___DATACENTER_ID___"
Expand All @@ -109,6 +111,7 @@ pub fn configure(config: &Config, pool_type: PoolType) -> GlobalResult<String> {
r#"
.source = "pegboard_isolate_v8_runner"

.namespace = "{namespace}"
.client_id = "___SERVER_ID___"
.server_id = "___SERVER_ID___"
.datacenter_id = "___DATACENTER_ID___"
Expand All @@ -132,6 +135,7 @@ pub fn configure(config: &Config, pool_type: PoolType) -> GlobalResult<String> {
.source = "pegboard_container_runner"
.actor_id = parse_regex!(.file, r'/var/lib/rivet-client/actors/(?P<actor_id>[0-9a-fA-F-]+)/logs/').actor_id

.namespace = "{namespace}"
.client_id = "___SERVER_ID___"
.server_id = "___SERVER_ID___"
.datacenter_id = "___DATACENTER_ID___"
Expand Down Expand Up @@ -161,6 +165,7 @@ pub fn configure(config: &Config, pool_type: PoolType) -> GlobalResult<String> {
r#"
.source = "worker"

.namespace = "{namespace}"
.server_id = "___SERVER_ID___"
.datacenter_id = "___DATACENTER_ID___"
.cluster_id = "___CLUSTER_ID___"
Expand All @@ -187,6 +192,7 @@ pub fn configure(config: &Config, pool_type: PoolType) -> GlobalResult<String> {
r#"
.source = "guard"

.namespace = "{namespace}"
.server_id = "___SERVER_ID___"
.datacenter_id = "___DATACENTER_ID___"
.cluster_id = "___CLUSTER_ID___"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ ConditionPathExists=/etc/rivet-server/
Environment="RIVET_OTEL_ENABLED=1"
Environment="RIVET_OTEL_SAMPLER_RATIO=1"
Environment="RIVET_SERVICE_NAME=guard"
Environment="RIVET_NAMESPACE=__NAMESPACE__"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Template variable uses different underscore pattern than other environment variables (NAMESPACE vs CLUSTER_ID). Should be consistent with 3 underscores.

Suggested change
Environment="RIVET_NAMESPACE=__NAMESPACE__"
Environment="RIVET_NAMESPACE=___NAMESPACE___"

Environment="RIVET_CLUSTER_ID=___CLUSTER_ID___"
Environment="RIVET_DATACENTER_ID=___DATACENTER_ID___"
Environment="RIVET_SERVER_ID=___SERVER_ID___"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ ConditionPathExists=/etc/rivet-server/
Environment="RIVET_OTEL_ENABLED=1"
Environment="RIVET_OTEL_SAMPLER_RATIO=1"
Environment="RIVET_SERVICE_NAME=edge"
Environment="RIVET_NAMESPACE=__NAMESPACE__"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Ensure NAMESPACE is properly replaced during configuration. The template variable format differs from other environment variables which use ___ prefix/suffix.

Environment="RIVET_CLUSTER_ID=___CLUSTER_ID___"
Environment="RIVET_DATACENTER_ID=___DATACENTER_ID___"
Environment="RIVET_SERVER_ID=___SERVER_ID___"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ pub async fn gen_initialize(
pool_type: PoolType,
server_token: &str,
) -> GlobalResult<String> {
let server_config = config.server()?;

let mut script = Vec::new();

let mut prometheus_targets = HashMap::new();
Expand Down Expand Up @@ -233,6 +235,7 @@ pub async fn gen_initialize(
// MARK: Common (post)
if !prometheus_targets.is_empty() {
script.push(components::vector::configure(
&server_config.rivet.namespace,
&components::vector::Config { prometheus_targets },
pool_type,
)?);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE service_logs ADD COLUMN namespace String DEFAULT '';
Loading