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

Logs API: Add emitEvent to Logs API #5050

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

Karlie-777
Copy link

@Karlie-777 Karlie-777 commented Oct 7, 2024

[Draft] Add emitEvent to Logs API
TODO: Bridge current events API emit to logs API emitEvent for backward compatibility.

@Karlie-777 Karlie-777 requested a review from a team as a code owner October 7, 2024 17:49
@Karlie-777 Karlie-777 marked this pull request as draft October 7, 2024 17:50
Copy link

codecov bot commented Oct 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.27%. Comparing base (55a1fc8) to head (1789427).
Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5050      +/-   ##
==========================================
+ Coverage   93.26%   93.27%   +0.01%     
==========================================
  Files         317      317              
  Lines        8195     8209      +14     
  Branches     1641     1646       +5     
==========================================
+ Hits         7643     7657      +14     
  Misses        552      552              
Files with missing lines Coverage Δ
experimental/packages/api-logs/src/NoopLogger.ts 100.00% <100.00%> (ø)
experimental/packages/api-logs/src/ProxyLogger.ts 88.88% <100.00%> (+1.38%) ⬆️
experimental/packages/sdk-logs/src/Logger.ts 100.00% <100.00%> (ø)

@Karlie-777 Karlie-777 marked this pull request as ready for review October 23, 2024 01:16

public emitEvent(eventRecord: logsAPI.EventRecord): void {
const attributes = eventRecord.attributes || {};
attributes['event.name'] = eventRecord.name;
Copy link
Member

Choose a reason for hiding this comment

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

Nit: (use semantic conventions)

Suggested change
attributes['event.name'] = eventRecord.name;
attributes[ATTR_EVENT_NAME] = eventRecord.name;

https://github.com/open-telemetry/opentelemetry-js/blob/main/semantic-conventions/src/experimental_attributes.ts#L2431

@Karlie-777 Karlie-777 marked this pull request as draft November 4, 2024 23:59

type Get<T> = (version: number) => T;
type OtelGlobal = Partial<{
[GLOBAL_LOGS_API_KEY]: Get<LoggerProvider>;
[GLOBAL_EXPERIMENTAL_LOGS_API_KEY]: Get<ExperimentalLoggerProvider>;
Copy link
Author

Choose a reason for hiding this comment

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

created a new key for the experimental logs, to be confirmed

Copy link
Author

Choose a reason for hiding this comment

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

to make a comment in the code as well

@@ -53,4 +53,23 @@ export class Logger implements logsAPI.Logger {
*/
logRecordInstance._makeReadonly();
}

// public emitEvent(eventRecord: logsAPI.EventRecord): void {
Copy link
Author

Choose a reason for hiding this comment

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

Should we have an experimental entry for sdk-logs as well?

Copy link
Author

Choose a reason for hiding this comment

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

need a experimental one

version?: string,
options?: LoggerOptions
): Logger | undefined;
}
Copy link
Author

Choose a reason for hiding this comment

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

maybe add a baseLogger as well?

* @param logRecord
*/
emitEvent(eventRecord: EventRecord): void {
this._getLogger().emitEvent(eventRecord);
Copy link
Author

Choose a reason for hiding this comment

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

make sure emitevent exists

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