Skip to content

Commit 21b861e

Browse files
committed
feat: pass orgslug to logs endpoint
1 parent d77e92b commit 21b861e

3 files changed

Lines changed: 21 additions & 5 deletions

File tree

src/tracer/src/cli/handlers/logs.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ pub async fn otel_start_with_auto_install(
170170
let run_name = run_snapshot.name.clone();
171171
let pipeline_name = pipeline_data.name.clone();
172172
let user_id = pipeline_data.tags.user_id.unwrap();
173+
let organization_slug = pipeline_data.tags.organization_slug.clone();
173174

174175
let trace_id = run_id.clone();
175176
let span_id = run_id.clone();
@@ -187,6 +188,7 @@ pub async fn otel_start_with_auto_install(
187188
trace_id,
188189
span_id,
189190
user_email,
191+
organization_slug,
190192
std::collections::HashMap::new(),
191193
);
192194

@@ -208,6 +210,7 @@ pub async fn otel_start_with_auto_install(
208210
warning_message!("No active run found, using standalone configuration");
209211

210212
let user_email = pipeline_data.tags.email.unwrap();
213+
let organization_slug = pipeline_data.tags.organization_slug.clone();
211214

212215
let run_id = uuid::Uuid::new_v4().to_string();
213216
let standalone_config = OtelConfig::with_environment_variables(
@@ -219,6 +222,7 @@ pub async fn otel_start_with_auto_install(
219222
run_id.clone(),
220223
run_id,
221224
user_email,
225+
organization_slug.clone(),
222226
std::collections::HashMap::new(),
223227
);
224228

@@ -235,6 +239,7 @@ pub async fn otel_start_with_auto_install(
235239
warning_message!("Daemon not accessible: {}", e);
236240

237241
let user_email = "unknown".to_string();
242+
let organization_slug = "unknown".to_string();
238243

239244
let run_id = uuid::Uuid::new_v4().to_string();
240245
let standalone_config = OtelConfig::with_environment_variables(
@@ -246,6 +251,7 @@ pub async fn otel_start_with_auto_install(
246251
run_id.clone(),
247252
run_id,
248253
user_email,
254+
organization_slug.clone(),
249255
std::collections::HashMap::new(),
250256
);
251257

src/tracer/src/opentelemetry/config.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub struct OtelConfig {
1717
pub span_id: String,
1818
pub user_email: String,
1919
pub environment_variables: HashMap<String, String>,
20+
pub organization_slug: String,
2021
}
2122

2223
impl OtelConfig {
@@ -30,6 +31,7 @@ impl OtelConfig {
3031
trace_id: String,
3132
span_id: String,
3233
user_email: String,
34+
organization_slug: String,
3335
) -> Self {
3436
Self {
3537
user_id,
@@ -40,6 +42,7 @@ impl OtelConfig {
4042
trace_id,
4143
span_id,
4244
user_email,
45+
organization_slug,
4346
environment_variables: HashMap::new(),
4447
}
4548
}
@@ -54,6 +57,7 @@ impl OtelConfig {
5457
trace_id: String,
5558
span_id: String,
5659
user_email: String,
60+
organization_slug: String,
5761
environment_variables: HashMap<String, String>,
5862
) -> Self {
5963
Self {
@@ -66,6 +70,7 @@ impl OtelConfig {
6670
span_id,
6771
user_email,
6872
environment_variables,
73+
organization_slug,
6974
}
7075
}
7176

@@ -95,8 +100,9 @@ impl OtelConfig {
95100

96101
pub fn generate_config(&self) -> Result<String> {
97102
crate::info_message!(
98-
"Generating OpenTelemetry config for run_id: {}",
99-
self.run_id
103+
"Generating OpenTelemetry config for run_id: {}, organization: {}",
104+
self.run_id,
105+
self.organization_slug
100106
);
101107

102108
let template_content = include_str!("otel-config-template.yaml");
@@ -111,6 +117,7 @@ impl OtelConfig {
111117
.replace("{{run_id}}", &self.run_id)
112118
.replace("{{otel_endpoint}}", OTEL_FORWARD_ENDPOINT)
113119
.replace("{{organization_id}}", &self.organization_id)
120+
.replace("{{organization_slug}}", &self.organization_slug)
114121
.replace("{{trace_id}}", &self.trace_id)
115122
.replace("{{span_id}}", &self.span_id)
116123
.replace("{{user_email}}", &self.user_email);

src/tracer/src/opentelemetry/otel-config-template.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ processors:
6262
resource:
6363
attributes:
6464
- key: service.name
65-
value: "nextflow-pipeline"
65+
value: "tracer-logger"
6666
action: insert
6767
- key: service.version
68-
value: "1.0.0"
68+
value: "1.1.0"
6969
action: insert
7070
- key: deployment.environment
7171
value: "production"
@@ -89,8 +89,9 @@ processors:
8989
- set(attributes["run_name"], "{{run_name}}")
9090
- set(attributes["trace_id"], "{{trace_id}}")
9191
- set(attributes["span_id"], "{{span_id}}")
92-
- set(attributes["organization_id"], "{{organization_id}}")
9392
- set(attributes["run_id"], "{{run_id}}")
93+
- set(attributes["organization_id"], "{{organization_id}}")
94+
- set(attributes["organization_slug"], "{{organization_slug}}")
9495
- set(attributes["user_email"], "{{user_email}}")
9596
- set(attributes["log_file_path"], attributes["log.file.path"]) where attributes["log.file.path"] != nil
9697
- set(attributes["file_name"], attributes["log.file.name"]) where attributes["log.file.name"] != nil
@@ -106,6 +107,8 @@ exporters:
106107
endpoint: "{{otel_endpoint}}"
107108
headers:
108109
Content-Type: "application/json"
110+
x-organization-slug: "{{organization_slug}}"
111+
x-organization-id: "{{organization_id}}"
109112
timeout: 60s
110113
retry_on_failure:
111114
enabled: true

0 commit comments

Comments
 (0)