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

feat: Add log level config option to SDK #315

Merged
merged 14 commits into from
Oct 15, 2024
Merged

Conversation

jairo-mendoza
Copy link
Contributor

@jairo-mendoza jairo-mendoza commented Oct 1, 2024

Which problem is this PR solving?

Short description of the changes

Users will now have the option to set a log level when initializing the SDK. This log level controls the verbosity of logs outputted. The current log levels includes DEBUG, INFO, WARN, and ERROR.

How to verify that this has the expected result

  • Unit tests have been added
  • I tested locally by reproducing the issue and seeing if my changes fixed the issue

@@ -33,32 +33,48 @@ export const FAILED_AUTH_FOR_LOCAL_VISUALIZATIONS =
);

export const validateOptionsWarnings = (options?: HoneycombOptions) => {
const logLevel = options?.logLevel
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Q for this change: Are there any other areas we'd like to see the logs being controlled?

Copy link
Contributor

Choose a reason for hiding this comment

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

If we search for console.* Looks like there's some statements in packages/honeycomb-opentelemetry-web/src/console-trace-link-exporter.ts.
We might need to tweak the API for ConsoleTraceLinkExporter to accept the full options object rather than just the service name.

@jairo-mendoza jairo-mendoza marked this pull request as ready for review October 1, 2024 17:08
@jairo-mendoza jairo-mendoza requested a review from a team as a code owner October 1, 2024 17:08
README.md Outdated Show resolved Hide resolved
Comment on lines 36 to 48
constructor(serviceName?: string, apikey?: string) {
if (!serviceName || !apikey) {
console.debug(MISSING_FIELDS_FOR_LOCAL_VISUALIZATIONS);
this._logLevel >= DiagLogLevel.DEBUG &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's move this into a nested if clause so that it's explicit. Fall through side effects can be difficult to reason over.

@jairo-mendoza jairo-mendoza merged commit 06d05ad into main Oct 15, 2024
16 checks passed
@jairo-mendoza jairo-mendoza deleted the jairo.logLevel-config-opt branch October 15, 2024 16:10
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.

Add logLevel as an SDK init option
3 participants