Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: events for ng #26908

Closed
wants to merge 2 commits into from
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ zstd = "=0.12.4"

opentelemetry = "0.27.0"
opentelemetry-http = "0.27.0"
opentelemetry-otlp = { version = "0.27.0", features = ["logs", "http-proto", "http-json"] }
opentelemetry-otlp = { version = "0.27.0", features = ["logs", "http-proto", "http-json", "populate-logs-event-name"] }
opentelemetry-semantic-conventions = { version = "0.27.0", features = ["semconv_experimental"] }
opentelemetry_sdk = "0.27.0"

Expand Down
11 changes: 8 additions & 3 deletions cli/tools/run/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,14 @@ pub async fn run_script(
let worker_factory = factory.create_cli_main_worker_factory().await?;
let mut worker = worker_factory
.create_main_worker(mode, main_module.clone())
.await?;

let exit_code = worker.run().await?;
.await
.inspect_err(|e| {
deno_telemetry::report_event("boot_failure", e)
})?;

let exit_code = worker.run().await.inspect_err(|e| {
deno_telemetry::report_event("uncaught_exception", e)
})?;
Ok(exit_code)
}

Expand Down
19 changes: 19 additions & 0 deletions ext/telemetry/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,25 @@ fn op_otel_log(
logs.emit(&mut log_record, instrumentation_scope);
}

pub fn report_event(name: &'static str, data: impl std::fmt::Display) {
let Some(Processors { logs, .. }) = OTEL_PROCESSORS.get() else {
return;
};
let Some(instrumentation_scope) = BUILT_IN_INSTRUMENTATION_SCOPE.get() else {
return;
};

let mut log_record = LogRecord::default();

log_record.set_observed_timestamp(SystemTime::now());
log_record.set_event_name(name);
log_record.set_severity_number(Severity::Trace);
log_record.set_severity_text(Severity::Trace.name());
log_record.set_body(format!("{data}").into());

logs.emit(&mut log_record, instrumentation_scope);
}

fn owned_string<'s>(
scope: &mut v8::HandleScope<'s>,
string: v8::Local<'s, v8::String>,
Expand Down
Loading