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(unstable): replace SpanExporter with TracerProvider #27473

Merged
merged 9 commits into from
Jan 6, 2025

Conversation

lucacasonato
Copy link
Member

This is needed to make no-config @opentelemetry/api integration work.

@lucacasonato lucacasonato marked this pull request as ready for review January 3, 2025 11:34
This is needed to make no-config @opentelemetry/api integration work.
@@ -288,28 +284,28 @@ class InnerRequest {

// * is valid for OPTIONS
if (path === "*") {
return this.#urlValue = "*";
return (this.#urlValue = "*");
Copy link
Member

Choose a reason for hiding this comment

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

Surprised that dprint is not removing these changes to parentheses

Copy link
Member Author

Choose a reason for hiding this comment

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

I accidentally ran prettier - it added these parentheses

try {
if (TRACING_ENABLED) {
span = new Span("fetch", { kind: 2 });
enterSpan(span);
span = builtinTracer().startSpan("fetch", { kind: 2 });
Copy link
Member

Choose a reason for hiding this comment

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

Not important for this PR, but could we use some sort of enum object for the kind? The numerical value is not super informative.

Copy link
Member Author

Choose a reason for hiding this comment

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

It is an enum in the user API. I'll see about adding it to the internal api too

Comment on lines +700 to +705
const onError = options.onError ??
function (error) {
// deno-lint-ignore no-console
console.error(error);
return internalServerError();
};
Copy link
Member

Choose a reason for hiding this comment

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

Lots of unrelated changes due to moving code around :D

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry

BasicTracerProvider,
SimpleSpanProcessor,
} from "npm:@opentelemetry/sdk-trace-base@1";
import { context, trace, metrics } from "npm:@opentelemetry/api@1";

// @ts-ignore Deno.telemetry is not typed yet
const telemetry = Deno.telemetry ?? Deno.tracing;
Copy link
Member

Choose a reason for hiding this comment

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

Is this on purpose? Are we gonna have both Deno.telemetry and Deno.tracing?

Copy link
Member Author

Choose a reason for hiding this comment

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

No this was just to support both old and newer Deno versions - it is now superfluous and my follow up removes this entirely.

ext/telemetry/telemetry.ts Show resolved Hide resolved
ext/telemetry/telemetry.ts Outdated Show resolved Hide resolved
@@ -1,12 +1,15 @@
// Copyright 2018-2025 the Deno authors. MIT license.

#![allow(clippy::too_many_arguments)]
Copy link
Member

Choose a reason for hiding this comment

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

Do we have to do it for the whole module? :(

Copy link
Member Author

Choose a reason for hiding this comment

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

It's due to a bug in core - Divy already knows about it

Copy link
Member Author

Choose a reason for hiding this comment

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

@@ -851,6 +911,9 @@ macro_rules! attr_raw {
} else if let Ok(bigint) = $value.try_cast::<v8::BigInt>() {
let (i64_value, _lossless) = bigint.i64_value();
Some(Value::I64(i64_value))
} else if let Ok(_array) = $value.try_cast::<v8::Array>() {
// TODO: implement array attributes
Copy link
Member

Choose a reason for hiding this comment

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

Open an issue about it before landing?

Copy link
Member Author

Choose a reason for hiding this comment

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

Comment on lines +1064 to +1075
#[op2]
impl OtelTracer {
#[constructor]
#[cppgc]
fn new(
#[string] name: String,
#[string] version: Option<String>,
#[string] schema_url: Option<String>,
) -> OtelTracer {
let mut builder = opentelemetry::InstrumentationScope::builder(name);
if let Some(version) = version {
builder = builder.with_version(version);
Copy link
Member

Choose a reason for hiding this comment

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

Pinging @littledivy to review cppgc/object wrap bits in this PR

ext/telemetry/lib.rs Show resolved Hide resolved
Copy link
Member

@littledivy littledivy left a comment

Choose a reason for hiding this comment

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

cppgc stuff lgtm

Comment on lines +1397 to +1401
let Some(span) =
deno_core::_ops::try_unwrap_cppgc_object::<OtelSpan>(scope, span)
else {
return;
};
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should support something like Option<OtelSpan> in the macro

Copy link
Member Author

Choose a reason for hiding this comment

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

We actually do support that - the problem is that right now an op can take on of cppgc object, or HandleScope, not both - I have a fix in a PR somewhere in core - I think the one that changes string handling.

@lucacasonato lucacasonato requested a review from devsnek January 6, 2025 10:24
@lucacasonato lucacasonato merged commit 4b35ba6 into denoland:main Jan 6, 2025
17 checks passed
@lucacasonato lucacasonato deleted the trace_provider branch January 6, 2025 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants