Skip to content

Commit 7b38fd6

Browse files
NathanFlurryMasterPtato
authored andcommitted
chore: expose namespace in otel attributes
1 parent 2c043a5 commit 7b38fd6

File tree

9 files changed

+18
-1
lines changed

9 files changed

+18
-1
lines changed

packages/common/runtime/src/otel.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ fn resource() -> Resource {
2020
SCHEMA_URL,
2121
);
2222

23+
if let Ok(v) = std::env::var("RIVET_NAMESPACE") {
24+
resource = resource.with_attribute(KeyValue::new("namespace", v));
25+
}
2326
if let Ok(v) = std::env::var("RIVET_CLUSTER_ID") {
2427
resource = resource.with_attribute(KeyValue::new("cluster_id", v));
2528
}

packages/core/services/cluster/src/workflows/server/install/install_scripts/components/rivet/guard.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ pub fn configure(config: &rivet_config::Config) -> GlobalResult<String> {
156156
.unwrap_or(0.001);
157157

158158
Ok(include_str!("../../files/rivet_guard_configure.sh")
159+
.replace("__NAMESPACE__", &server_config.rivet.namespace)
159160
.replace(
160161
"__RIVET_GUARD_CONFIG__",
161162
&serde_json::to_string_pretty(&guard_config_json)?,

packages/core/services/cluster/src/workflows/server/install/install_scripts/components/rivet/worker.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ pub fn configure(config: &rivet_config::Config) -> GlobalResult<String> {
162162
.unwrap_or(0.001);
163163

164164
Ok(include_str!("../../files/rivet_worker_configure.sh")
165+
.replace("__NAMESPACE__", &server_config.rivet.namespace)
165166
.replace(
166167
"__RIVET_EDGE_CONFIG__",
167168
&serde_json::to_string_pretty(&edge_config_json)?,

packages/core/services/cluster/src/workflows/server/install/install_scripts/components/vector.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub struct PrometheusTarget {
2121
pub scrape_interval: usize,
2222
}
2323

24-
pub fn configure(config: &Config, pool_type: PoolType) -> GlobalResult<String> {
24+
pub fn configure(namespace: &str, config: &Config, pool_type: PoolType) -> GlobalResult<String> {
2525
let sources = config
2626
.prometheus_targets
2727
.keys()
@@ -43,6 +43,7 @@ pub fn configure(config: &Config, pool_type: PoolType) -> GlobalResult<String> {
4343
"inputs": ["filter_metrics"],
4444
"source": formatdoc!(
4545
r#"
46+
.tags.namespace = "{namespace}"
4647
.tags.server_id = "___SERVER_ID___"
4748
.tags.datacenter_id = "___DATACENTER_ID___"
4849
.tags.cluster_id = "___CLUSTER_ID___"
@@ -87,6 +88,7 @@ pub fn configure(config: &Config, pool_type: PoolType) -> GlobalResult<String> {
8788
r#"
8889
.source = "pegboard_manager"
8990
91+
.namespace = "{namespace}"
9092
.client_id = "___SERVER_ID___"
9193
.server_id = "___SERVER_ID___"
9294
.datacenter_id = "___DATACENTER_ID___"
@@ -109,6 +111,7 @@ pub fn configure(config: &Config, pool_type: PoolType) -> GlobalResult<String> {
109111
r#"
110112
.source = "pegboard_isolate_v8_runner"
111113
114+
.namespace = "{namespace}"
112115
.client_id = "___SERVER_ID___"
113116
.server_id = "___SERVER_ID___"
114117
.datacenter_id = "___DATACENTER_ID___"
@@ -132,6 +135,7 @@ pub fn configure(config: &Config, pool_type: PoolType) -> GlobalResult<String> {
132135
.source = "pegboard_container_runner"
133136
.actor_id = parse_regex!(.file, r'/var/lib/rivet-client/actors/(?P<actor_id>[0-9a-fA-F-]+)/logs/').actor_id
134137
138+
.namespace = "{namespace}"
135139
.client_id = "___SERVER_ID___"
136140
.server_id = "___SERVER_ID___"
137141
.datacenter_id = "___DATACENTER_ID___"
@@ -161,6 +165,7 @@ pub fn configure(config: &Config, pool_type: PoolType) -> GlobalResult<String> {
161165
r#"
162166
.source = "worker"
163167
168+
.namespace = "{namespace}"
164169
.server_id = "___SERVER_ID___"
165170
.datacenter_id = "___DATACENTER_ID___"
166171
.cluster_id = "___CLUSTER_ID___"
@@ -187,6 +192,7 @@ pub fn configure(config: &Config, pool_type: PoolType) -> GlobalResult<String> {
187192
r#"
188193
.source = "guard"
189194
195+
.namespace = "{namespace}"
190196
.server_id = "___SERVER_ID___"
191197
.datacenter_id = "___DATACENTER_ID___"
192198
.cluster_id = "___CLUSTER_ID___"

packages/core/services/cluster/src/workflows/server/install/install_scripts/files/rivet_guard_configure.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ ConditionPathExists=/etc/rivet-server/
1818
Environment="RIVET_OTEL_ENABLED=1"
1919
Environment="RIVET_OTEL_SAMPLER_RATIO=1"
2020
Environment="RIVET_SERVICE_NAME=guard"
21+
Environment="RIVET_NAMESPACE=__NAMESPACE__"
2122
Environment="RIVET_CLUSTER_ID=___CLUSTER_ID___"
2223
Environment="RIVET_DATACENTER_ID=___DATACENTER_ID___"
2324
Environment="RIVET_SERVER_ID=___SERVER_ID___"

packages/core/services/cluster/src/workflows/server/install/install_scripts/files/rivet_worker_configure.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ ConditionPathExists=/etc/rivet-server/
1919
Environment="RIVET_OTEL_ENABLED=1"
2020
Environment="RIVET_OTEL_SAMPLER_RATIO=1"
2121
Environment="RIVET_SERVICE_NAME=edge"
22+
Environment="RIVET_NAMESPACE=__NAMESPACE__"
2223
Environment="RIVET_CLUSTER_ID=___CLUSTER_ID___"
2324
Environment="RIVET_DATACENTER_ID=___DATACENTER_ID___"
2425
Environment="RIVET_SERVER_ID=___SERVER_ID___"

packages/core/services/cluster/src/workflows/server/install/install_scripts/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ pub async fn gen_initialize(
111111
pool_type: PoolType,
112112
server_token: &str,
113113
) -> GlobalResult<String> {
114+
let server_config = config.server()?;
115+
114116
let mut script = Vec::new();
115117

116118
let mut prometheus_targets = HashMap::new();
@@ -233,6 +235,7 @@ pub async fn gen_initialize(
233235
// MARK: Common (post)
234236
if !prometheus_targets.is_empty() {
235237
script.push(components::vector::configure(
238+
&server_config.rivet.namespace,
236239
&components::vector::Config { prometheus_targets },
237240
pool_type,
238241
)?);

packages/core/services/service-log/db/service-log/migrations/20250530221342_add_namespace_column.down.sql

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE service_logs ADD COLUMN namespace String DEFAULT '';

0 commit comments

Comments
 (0)