Skip to content

feat(sdk-logs): implement log processor metrics#6554

Open
anuraaga wants to merge 8 commits intoopen-telemetry:mainfrom
anuraaga:log-processor-metrics
Open

feat(sdk-logs): implement log processor metrics#6554
anuraaga wants to merge 8 commits intoopen-telemetry:mainfrom
anuraaga:log-processor-metrics

Conversation

@anuraaga
Copy link
Copy Markdown
Contributor

@anuraaga anuraaga commented Apr 3, 2026

Which problem is this PR solving?

I am helping to implement SDK internal metrics

https://opentelemetry.io/docs/specs/semconv/otel/sdk-metrics/

This implements log processor metrics. This is the last PR for SDK metrics.

It is very similar to #6504 except for opentelemetry-sdk-node integration

/cc @trentm

Short description of the changes

Implement metrics for log processors per semconv

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Unit tests

Checklist:

  • Followed the style guidelines of this project
  • Unit tests have been added
  • Documentation has been updated

@anuraaga anuraaga requested a review from a team as a code owner April 3, 2026 05:41
const sdk = new NodeSDK({
metricReader: metricReader,
traceExporter: new ConsoleSpanExporter(),
logRecordProcessors: [
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I realized since SDK only accepts built log record processors, not exporter, we can't wire a meter provider into it like we can with a traceExporter. So I changed this test to exercise autoconfig for all signals, and also added a test that is autoconfig only for logs and keeps this pattern for the others to exercise both cases

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That being said, I wonder if we do need some internal mechanism to fill in passed-in log record processors, depending on how common that is

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.78%. Comparing base (8ee2a8b) to head (6267b29).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6554      +/-   ##
==========================================
+ Coverage   95.76%   95.78%   +0.01%     
==========================================
  Files         375      376       +1     
  Lines       12739    12796      +57     
  Branches     3013     3022       +9     
==========================================
+ Hits        12200    12257      +57     
  Misses        539      539              
Files with missing lines Coverage Δ
...imental/packages/opentelemetry-sdk-node/src/sdk.ts 95.95% <100.00%> (+0.02%) ⬆️
...ental/packages/opentelemetry-sdk-node/src/utils.ts 96.25% <100.00%> (ø)
...sdk-logs/src/export/BatchLogRecordProcessorBase.ts 91.77% <100.00%> (+0.61%) ⬆️
...s/sdk-logs/src/export/LogRecordProcessorMetrics.ts 100.00% <100.00%> (ø)
...es/sdk-logs/src/export/SimpleLogRecordProcessor.ts 95.00% <100.00%> (+1.45%) ⬆️
experimental/packages/sdk-logs/src/semconv.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@anuraaga anuraaga changed the title feat(sdk-logs): implement log processor metris feat(sdk-logs): implement log processor metrics Apr 3, 2026
);
queueCapacity.add(capacity, this.standardAttrs);

const queueSize = meter.createObservableUpDownCounter(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think because queueSize here is a local variable here and not assigned to this.queueSize that the removeCallback in shutdown() won't work (meaning the callback will keep firing even after the processor is shut down). I think it should be this.queueSize = meter.createObservableUpDownCounter(...)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Doh, sorry about that fixed

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