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

chore: remove NoopLogger from sdk and use from api #1746

Merged
merged 9 commits into from
Dec 22, 2020

Conversation

srikanthccv
Copy link
Member

Fixes #1738

@codecov
Copy link

codecov bot commented Dec 14, 2020

Codecov Report

Merging #1746 (1716138) into master (a2304c9) will increase coverage by 0.03%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #1746      +/-   ##
==========================================
+ Coverage   92.11%   92.15%   +0.03%     
==========================================
  Files         166      165       -1     
  Lines        5571     5568       -3     
  Branches     1197     1197              
==========================================
- Hits         5132     5131       -1     
+ Misses        439      437       -2     
Impacted Files Coverage Δ
...elemetry-core/src/context/propagation/composite.ts 100.00% <ø> (ø)
...ry-exporter-collector/src/CollectorExporterBase.ts 92.45% <100.00%> (+0.14%) ⬆️
...kages/opentelemetry-exporter-collector/src/util.ts 100.00% <100.00%> (ø)
...ckages/opentelemetry-exporter-jaeger/src/jaeger.ts 87.01% <100.00%> (+0.17%) ⬆️
...etry-exporter-prometheus/src/PrometheusExporter.ts 92.30% <100.00%> (+0.12%) ⬆️
...ckages/opentelemetry-exporter-zipkin/src/zipkin.ts 100.00% <100.00%> (ø)
packages/opentelemetry-metrics/src/Metric.ts 91.89% <100.00%> (-0.22%) ⬇️
...ry-resources/src/platform/node/detect-resources.ts 20.83% <100.00%> (ø)
...ackages/opentelemetry-shim-opentracing/src/shim.ts 87.60% <100.00%> (-0.11%) ⬇️

@obecny
Copy link
Member

obecny commented Dec 14, 2020

it looks fine, @lonewolf3739 just please update to latest and run "npm run lint:fix" to fix the linting, thx

@srikanthccv
Copy link
Member Author

it looks fine, @lonewolf3739 just please update to latest and run "npm run lint:fix" to fix the linting, thx

It seems like my lint is different from ci one. I will check.

@obecny
Copy link
Member

obecny commented Dec 14, 2020

it looks fine, @lonewolf3739 just please update to latest and run "npm run lint:fix" to fix the linting, thx

It seems like my lint is different from ci one. I will check.

Make sure you have up to date all node modules, sometimes you have to remove node_modules and package-lock.json from all places.

@obecny obecny added the enhancement New feature or request label Dec 15, 2020
@@ -39,7 +35,7 @@ export class JaegerExporter implements SpanExporter {

constructor(config: jaegerTypes.ExporterConfig) {
const localConfig = Object.assign({}, config);
this._logger = localConfig.logger || new NoopLogger();
this._logger = localConfig.logger || new api.NoopLogger();
Copy link
Contributor

@MSNev MSNev Dec 16, 2020

Choose a reason for hiding this comment

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

Suggestion:
This appears to be a common pattern which is effectively necessary boilerplate code.

Provide an api function called getLogger(logger?: Logger) which returns either the provided Logger
OR a No-op implementation logger.

This allows a couple of things

  • We can then don't need ANY NoopLogger class
  • No more need for the boilerplate code everywhere that wants to ensure it has a logger instance

public getLogger(logger?: Logger): Logger {
if (!logger) {
logger = {
debug: () => {},
error: () => {},
warn: () => {},
info: () => {},
};
}
return logger;
}

Copy link
Contributor

@MSNev MSNev Dec 16, 2020

Choose a reason for hiding this comment

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

So this then would (potentially) become

this._logger = api.getLogger(localConfig.logger);

Copy link
Member

Choose a reason for hiding this comment

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

I think is out of scope for this PR, please create a separate issue "discussion" and move it there. It should not be here, thx

@dyladan
Copy link
Member

dyladan commented Dec 21, 2020

Ah I was going to merge this but there are conflicts

@dyladan dyladan added the Merge:LGTM This PR is ready to be merged by a Maintainer (has enough valid approvals, successful build, etc.) label Dec 21, 2020
@srikanthccv
Copy link
Member Author

Ah I was going to merge this but there are conflicts

@dyladan resolved the merge conflicts :)

@srikanthccv
Copy link
Member Author

@dyladan I resolved the conflicts again. It seems version badge service was unavailable for some time and test docs failed. I don't have chance to re-trigger pipeline. Could you please check that?

@dyladan
Copy link
Member

dyladan commented Dec 22, 2020

@dyladan I resolved the conflicts again. It seems version badge service was unavailable for some time and test docs failed. I don't have chance to re-trigger pipeline. Could you please check that?

Yeah that is a recurring problem :(

@dyladan dyladan merged commit 80ea2e0 into open-telemetry:master Dec 22, 2020
@srikanthccv srikanthccv deleted the no-nooplogger-sdk branch December 26, 2020 15:19
mike-marcacci added a commit to mike-marcacci/opentelemetry-operations-js that referenced this pull request Jan 29, 2021
It appears that OT removed the `NoopLogger` export from `core`:
open-telemetry/opentelemetry-js#1746

This prevents app crashes when a logger is not provided.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Merge:LGTM This PR is ready to be merged by a Maintainer (has enough valid approvals, successful build, etc.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove core NoopLogger
6 participants