-
Notifications
You must be signed in to change notification settings - Fork 255
Add OTEL Logs SDK #2671
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
Add OTEL Logs SDK #2671
Conversation
There was a problem hiding this 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.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this 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.
shared/OpenTelemetry/src/interfaces/logs/IOTelNoopLogRecordProcessor.ts
Outdated
Show resolved
Hide resolved
…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>
There was a problem hiding this 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.
MSNev
left a comment
There was a problem hiding this 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
|
@MSNev I am working on changing the |
Yes, leaving a few more comments (mostly around bundle sizes etc) |
|
@MSNev Could you please take a look again at the changes when you get a moment? Thanks! |
| context | ||
| } = logRecord; | ||
|
|
||
| const logAttributes = attributes || {}; |
There was a problem hiding this comment.
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") { |
There was a problem hiding this comment.
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 = { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
MSNev
left a comment
There was a problem hiding this 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.
* 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>
No description provided.