Skip to content

feat: add span metrics processor #849

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

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open

Conversation

david-luna
Copy link
Member

@david-luna david-luna commented Jun 20, 2025

This PR adds the following OTEL SDK metrics:

Summary of changes:

  • add a processors.js module to resolve processors set via env or via configuration options
  • add a sdk-metrics.js module which exports setupSdkMetrics method. The method is used to add a new Span processor which keeps the counters up to date whenever a Span starts or ends.

@david-luna david-luna marked this pull request as ready for review June 25, 2025 09:10
@david-luna david-luna requested a review from a team as a code owner June 25, 2025 09:10
@@ -129,6 +130,7 @@
"@opentelemetry/sdk-logs": "^0.202.0",
"@opentelemetry/sdk-metrics": "^2.0.0",
"@opentelemetry/sdk-node": "^0.202.0",
"@opentelemetry/sdk-trace-base": "^2.0.1",
Copy link
Member Author

Choose a reason for hiding this comment

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

note to reviewer: added to make the linter happy but this is a dependency of @opentelemetry/sdk-node which is going to be installed regardless if here or not. I worry if this may lead to some side effects

Copy link
Member

Choose a reason for hiding this comment

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

Should be fine. However, I'd look into updating the other ^2.0.0 otel deps to ^2.0.1 as well. E.g.: sdk-metrics.

@@ -34,6 +34,9 @@ const testFixtures = [
t.ok(hasLog(`name: 'nodejs.eventloop.delay.min'`));
t.ok(hasLog(`name: 'nodejs.eventloop.delay.max'`));
t.ok(hasLog(`name: 'process.cpu.utilization'`));
t.ok(hasLog(`name: 'process.cpu.utilization'`));
Copy link
Member Author

Choose a reason for hiding this comment

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

note to reviewer: I think this is the best place to check the metrics EDOT is collecting. If disagree I can create a new test file.

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 a duplicate line?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes!

Copy link
Member

@trentm trentm left a comment

Choose a reason for hiding this comment

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

If the intent is to just implement a subset (two) of the SDK metrics mentioned in https://opentelemetry.io/docs/specs/semconv/otel/sdk-metrics please update the description to say so. Also need to update to https://opentelemetry.io/docs/specs/semconv/otel/sdk-metrics as the reference because the PR is out of date (e.g. otel.sdk.span.live.count -> otel.sdk.span.live).

@@ -129,6 +130,7 @@
"@opentelemetry/sdk-logs": "^0.202.0",
"@opentelemetry/sdk-metrics": "^2.0.0",
"@opentelemetry/sdk-node": "^0.202.0",
"@opentelemetry/sdk-trace-base": "^2.0.1",
Copy link
Member

Choose a reason for hiding this comment

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

Should be fine. However, I'd look into updating the other ^2.0.0 otel deps to ^2.0.1 as well. E.g.: sdk-metrics.

@david-luna
Copy link
Member Author

If the intent is to just implement a subset (two) of the SDK metrics mentioned in https://opentelemetry.io/docs/specs/semconv/otel/sdk-metrics please update the description to say so. Also need to update to https://opentelemetry.io/docs/specs/semconv/otel/sdk-metrics as the reference because the PR is out of date (e.g. otel.sdk.span.live.count -> otel.sdk.span.live).

Updated the title and description of the PR :)

@david-luna david-luna requested a review from trentm June 26, 2025 14:03
@david-luna
Copy link
Member Author

ready for another round of review @trentm

Copy link
Member

@trentm trentm left a comment

Choose a reason for hiding this comment

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

Sorry for taking so long to re-review.

@@ -34,6 +34,9 @@ const testFixtures = [
t.ok(hasLog(`name: 'nodejs.eventloop.delay.min'`));
t.ok(hasLog(`name: 'nodejs.eventloop.delay.max'`));
t.ok(hasLog(`name: 'process.cpu.utilization'`));
t.ok(hasLog(`name: 'process.cpu.utilization'`));
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 a duplicate line?

Copy link
Member

@trentm trentm left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@trentm trentm left a comment

Choose a reason for hiding this comment

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

I just saw open-telemetry/semantic-conventions#2431
We should understand that before merging this.

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.

2 participants