Skip to content

Conversation

@rads-1996
Copy link
Member

No description provided.

@rads-1996 rads-1996 requested a review from a team as a code owner November 24, 2025 21:08
Copilot AI review requested due to automatic review settings November 24, 2025 21:08
@rads-1996 rads-1996 marked this pull request as draft November 24, 2025 21:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a comprehensive OpenTelemetry Logs SDK implementation to the shared OpenTelemetry module, enabling structured logging capabilities with trace context integration and configurable log record processing.

Key Changes:

  • Implements core logs SDK components including LoggerProvider, Logger, and LogRecordImpl
  • Adds multi-processor architecture for flexible log record handling
  • Provides configuration management with environment variable support and limits configuration
  • Includes comprehensive test coverage for all major components

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 17 comments.

Show a summary per file
File Description
shared/OpenTelemetry/src/sdk/config.ts Configuration loading and environment variable parsing for log record limits
shared/OpenTelemetry/src/sdk/IOTelMultiLogRecordProcessor.ts Multi-processor implementation for forwarding log records to multiple processors
shared/OpenTelemetry/src/sdk/IOTelLoggerProvider.ts Logger provider implementation managing logger instances and lifecycle
shared/OpenTelemetry/src/sdk/IOTelLogger.ts Logger implementation for emitting log records with trace context
shared/OpenTelemetry/src/sdk/IOTelLogRecordImpl.ts Log record implementation with attribute management and truncation
shared/OpenTelemetry/src/internal/loggerProviderSharedState.ts Shared state management for logger provider and processors
shared/OpenTelemetry/src/internal/commonUtils.ts Added timeout utilities for handling async operations with timeouts
shared/OpenTelemetry/src/internal/attributeHelpers.ts Improved attribute validation logic for better type checking
shared/OpenTelemetry/src/interfaces/logs/IOTelNoopLogRecordProcessor.ts No-op processor implementation for default behavior
shared/OpenTelemetry/src/api/noop/noopLogger.ts No-op logger implementation for post-shutdown scenarios
shared/OpenTelemetry/Tests/Unit/src/sdk/*.Tests.ts Comprehensive test suites for all SDK components
shared/OpenTelemetry/Tests/Unit/src/index.tests.ts Test registration for new log SDK test suites

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 11 comments.


You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

rads-1996 and others added 5 commits November 24, 2025 14:36
…cessor.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 11 comments.


You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@rads-1996 rads-1996 marked this pull request as ready for review November 25, 2025 18:20
Copy link
Collaborator

@MSNev MSNev left a comment

Choose a reason for hiding this comment

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

Should not have ANY classes and interfaces IXXXXXX need to be defined as interfaces

@rads-1996
Copy link
Member Author

@MSNev I am working on changing the console.warn to handleWarn, meanwhile can you please review and let me know if the structure for the interfaces and factory functions look correct?

@MSNev
Copy link
Collaborator

MSNev commented Nov 26, 2025

@MSNev I am working on changing the console.warn to handleWarn, meanwhile can you please review and let me know if the structure for the interfaces and factory functions look correct?

Yes, leaving a few more comments (mostly around bundle sizes etc)

@MSNev MSNev self-requested a review November 26, 2025 20:44
@rads-1996
Copy link
Member Author

@MSNev Could you please take a look again at the changes when you get a moment? Thanks!

context
} = logRecord;

const logAttributes = attributes || {};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider using an AttributeContainer for handling the attributes as there looks like there might be a bunch of duplicated code and the container is designed to handle inheritance in a clean manner.

This can be a followup PR, just create a task for it so we come back to it.

return value;
}

if (typeof value === "string") {
Copy link
Collaborator

@MSNev MSNev Dec 8, 2025

Choose a reason for hiding this comment

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

Several cases here where we could use the helpers (that get minified better) isString, isFunction, isArray, isUndefined etc.

Again, this can also be done as a follow up PR. We probably have a single task to search the entire code base for typeof and globals like Array.isArray etc.

* the LogRecords it emits MUST automatically include the Trace Context from the active Context,
* if Context has not been explicitly set.
*/
const logRecordData: IOTelLogRecord = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just a general FYI.

In some frameworks (not common for browsers / node), declaring a const object will also freeze the instance which then throws exceptions if someone trys to "update" (assign) one of the properties or add additional properties. So if this is possible in the usage of this object it "should" be defined as let rather than const

const envLogValueLength = getNumberFromEnv("OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT");
const envGeneralValueLength = getNumberFromEnv("OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT");

return {
Copy link
Collaborator

Choose a reason for hiding this comment

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

All config in the web sdk should be dynamic, reassigning an object may not work as expected for this (depending on how the config is defined). This should "probably" be passed the config that it wants to update rather than returning a new object.

Copy link
Collaborator

@MSNev MSNev left a comment

Choose a reason for hiding this comment

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

Left some feedback that can be addressed later.

@rads-1996 rads-1996 merged commit 6613ec9 into microsoft:otel-sdk Dec 8, 2025
8 checks passed
rads-1996 added a commit to rads-1996/ApplicationInsights-JS that referenced this pull request Dec 9, 2025
* Add OTEL Logs SDK

* Update shared/OpenTelemetry/src/sdk/IOTelLogRecordImpl.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Fix typing, formatting,  library issues

* Update shared/OpenTelemetry/src/interfaces/logs/IOTelNoopLogRecordProcessor.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update shared/OpenTelemetry/src/sdk/IOTelLogRecordImpl.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update shared/OpenTelemetry/src/sdk/IOTelLogRecordImpl.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Fixed promise return type

* Fix tests

* Changes classes structure and used Ixxx only for interfaces

* Addressed feedback

* Remove extra line

* Keep interfaces separate

* Remove duplicate file

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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