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/events SDK #3400

Closed
wants to merge 4 commits into from
Closed

Conversation

martinkuba
Copy link
Contributor

@martinkuba martinkuba commented Nov 9, 2022

This PR is not finished, but open to early feedback on the interfaces/classes of the SDK.

Related spec
https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/sdk.md

Copy link
Member

@dyladan dyladan left a comment

Choose a reason for hiding this comment

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

Overall structure of the package looks good to me. Have a few comments which amount to style preferences rather than actual issues. Named exports one is important though.

Some files are missing copyright headers.

Comment on lines +35 to +45
constructor(
resource: Resource,
instrumentationScope: InstrumentationScope,
timestamp?: number,
severityNumber?: number,
severityText?: string,
body?: string,
attributes?: Attributes,
traceFlags?: number,
traceId?: string,
spanId?: string
Copy link
Member

Choose a reason for hiding this comment

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

Might be better to use an object here since there are many optional arguments and there could be more added in the future. I would suggest resource and scope stay as required positional arguments, then make a third required positional arg with log record properties.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe even use api.LogRecord type?

Comment on lines +25 to +33
readonly timestamp?: number | undefined;
readonly severityNumber?: number | undefined;
readonly severityText?: string | undefined;
readonly body?: string | undefined;
readonly traceFlags?: number | undefined;
readonly traceId?: string | undefined;
readonly spanId?: string | undefined;
readonly resource: Resource;
readonly instrumentationScope: InstrumentationScope;
Copy link
Member

Choose a reason for hiding this comment

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

These are all public by default, is that intentional?

import { ReadableLogRecord } from './export/ReadableLogRecord';

export class LogRecord implements ReadableLogRecord {
private attributes?: Attributes | undefined;
Copy link
Member

Choose a reason for hiding this comment

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

Maybe set a default value of {} in the constructor unless undefined has special meaning

Comment on lines +24 to +26
readonly resource: Resource;
readonly instrumentationScope: InstrumentationScope;
readonly provider: LoggerProvider;
Copy link
Member

Choose a reason for hiding this comment

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

Should these be private?

this._emit(logRecord);
}

_emit(logRecord: LogRecord): void {
Copy link
Member

Choose a reason for hiding this comment

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

private?

));
}

emitEvent(event: api.LogEvent): void {
Copy link
Member

Choose a reason for hiding this comment

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

This moved to a separate API in open-telemetry/opentelemetry-specification#2941

Comment on lines +25 to +26
readonly processors: LogRecordProcessor[] = [];
readonly resource: Resource;
Copy link
Member

Choose a reason for hiding this comment

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

private?

return Promise.resolve();
}

private _exportInfo(logRecord: ReadableLogRecord) {
Copy link
Member

Choose a reason for hiding this comment

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

What is this function doing?

Comment on lines +1 to +5
export * from './Logger';
export * from './LoggerProvider';
export * from './LogRecordProcessor';
export * from './export/SimpleLogProcessor';
export * from './export/ConsoleLogExporter';
Copy link
Member

Choose a reason for hiding this comment

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

Explicit named exports would make it so that we don't accidentally leak internals. We've been moving that way in other packages.

@github-actions
Copy link

This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.

@github-actions github-actions bot added the stale label Jan 16, 2023
@github-actions
Copy link

This PR was closed because it has been stale for 14 days with no activity.

@github-actions github-actions bot closed this Feb 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants