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 OTEL_LOG_LEVEL env var #974

Merged
merged 5 commits into from
Jul 27, 2020

Conversation

naseemkullah
Copy link
Member

@naseemkullah naseemkullah commented Apr 18, 2020

User can now control the log level by means of env var.

Addresses JS implementation of open-telemetry/opentelemetry-specification#569

@naseemkullah
Copy link
Member Author

How can we get the test passing for node-12: browsers? Getting: ReferenceError: process is not defined.

@codecov-io
Copy link

codecov-io commented Apr 18, 2020

Codecov Report

Merging #974 into master will decrease coverage by 0.11%.
The diff coverage is 72.72%.

@@            Coverage Diff             @@
##           master     #974      +/-   ##
==========================================
- Coverage   93.28%   93.17%   -0.12%     
==========================================
  Files         149      149              
  Lines        4200     4218      +18     
  Branches      861      867       +6     
==========================================
+ Hits         3918     3930      +12     
- Misses        282      288       +6     
Impacted Files Coverage Δ
packages/opentelemetry-core/src/common/types.ts 100.00% <ø> (ø)
...ckages/opentelemetry-core/src/utils/environment.ts 81.39% <66.66%> (-10.92%) ⬇️
...ges/opentelemetry-core/src/common/ConsoleLogger.ts 95.00% <100.00%> (+0.26%) ⬆️
packages/opentelemetry-metrics/src/types.ts 100.00% <100.00%> (ø)
packages/opentelemetry-tracing/src/config.ts 100.00% <100.00%> (ø)

@vmarchaud
Copy link
Member

@naseemkullah process is only available within node, you need to have a different mecanism for the browser. We already have multiple functions that have different implementation depending on the platform here

@naseemkullah naseemkullah force-pushed the otel-log-level branch 11 times, most recently from 4acac5f to c4516f7 Compare May 17, 2020 00:10
@dyladan dyladan added enhancement New feature or request and removed waiting-for-spec labels Jul 24, 2020
Comment on lines 82 to 83
const regex = new RegExp(logLevelStrings.join('|'), 'i');
if (value && typeof value === 'string' && regex.test(value)) {
Copy link

@iliasbhal iliasbhal Jul 24, 2020

Choose a reason for hiding this comment

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

@naseemkullah would that work here?

Suggested change
const regex = new RegExp(logLevelStrings.join('|'), 'i');
if (value && typeof value === 'string' && regex.test(value)) {
if (logLevelStrings.includes(value)) {

Copy link
Member Author

Choose a reason for hiding this comment

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

Probably @iliasbhal but I just changed the function to a simpler switch case 😅

User can now control the log level by means of env var.

Sets default log level to INFO as per open-telemetry#856

Also shares mock environment functions for tests to be used in
ConsoleLogger tests as well as environment tests.

Signed-off-by: Naseem <naseem@transit.app>
@naseemkullah
Copy link
Member Author

Please excuse the force pushes, it is weekend and I presume nobody will be re-reviewing until Monday and would like a clean commit history by then.

@dyladan dyladan added Has Merge Conflict Merge:LGTM This PR is ready to be merged by a Maintainer (has enough valid approvals, successful build, etc.) labels Jul 27, 2020
/**
* Mocks environment used for tests.
*/
export function mockEnvironment(values: ENVIRONMENT_MAP) {
Copy link
Member

Choose a reason for hiding this comment

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

What's the reason you move it ?. keeping them just in tests it is fine, but exporting them as our sdk api with checking if process exists might not be a good solution Whatever we export to be a public must be platform dependent. If you are doing a helper function for you tests it is fine, but not when you try to export it.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

So the idea was to use it in multiple test files. While moving it here and exporting it so that multiple test files could use it seems to work it might not be the best solution.

We had a test-utils package but that was moved to contrib repo I believe. Should I copy paste these functions in both test files?

Copy link
Member

Choose a reason for hiding this comment

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

but it was inside file /test/utils/environment.test.ts which is perfectly fine, by moving this to environment.ts mean we are exporting a test function as our api which is not something we want

Copy link
Member

Choose a reason for hiding this comment

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

test-utils is in the contrib repo because it was only used by contrib plugins, but it might be a good idea to move it back into the main repo. I have said on other PRs I don't like the idea of exporting testing/fake/mock behavior from modules because users will find them and they will use them even if we dont want them to, and they will be confused and we will have to deal with it.

Copy link
Member

Choose a reason for hiding this comment

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

so you can still easily share this function between tests in the same package, just don't export them as our sdk

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks I will change accordingly as not to export the function

Copy link
Member Author

Choose a reason for hiding this comment

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

Alright, exported from its original location (test file itself) not sure why i did not do that first time around, think I was fatigued at that time.

Copy link
Member

Choose a reason for hiding this comment

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

just fix the conflicts pls

@obecny obecny removed the Merge:LGTM This PR is ready to be merged by a Maintainer (has enough valid approvals, successful build, etc.) label Jul 27, 2020
Signed-off-by: Naseem <naseem@transit.app>
@obecny obecny added the Merge:LGTM This PR is ready to be merged by a Maintainer (has enough valid approvals, successful build, etc.) label Jul 27, 2020
@dyladan dyladan merged commit cf00494 into open-telemetry:master Jul 27, 2020
@naseemkullah naseemkullah deleted the otel-log-level branch July 27, 2020 19:31
sidharthv96 added a commit to sidharthv96/opentelemetry-js that referenced this pull request Jul 28, 2020
* upstream/master:
  fix: add missing grpc-js index (open-telemetry#1358)
  chore: 0.10.0 release proposal (open-telemetry#1345)
  Proto update to latest to support arrays and maps (open-telemetry#1339)
  feat: add OTEL_LOG_LEVEL env var (open-telemetry#974)
  Add nodejs sdk package (open-telemetry#1187)
  feat: add baggage support to the opentracing shim (open-telemetry#918)
  Removing default span attributes (open-telemetry#1342)
jonahrosenblum pushed a commit to jonahrosenblum/opentelemetry-js that referenced this pull request Aug 8, 2020
obecny added a commit that referenced this pull request Aug 17, 2020
* feat: graceful shutdown for tracing and metrics

* fix: wording in test case

* fix: typo

* fix meterprovider config to use bracket notation

Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com>

* fix meterprovider config to use bracket notation

Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com>

* fix: add callbacks to shutdown methods

* fix: merge conflict

* simplify meter shutdown code

Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com>

* fix: fix one-liner

* private function name style fix

Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com>

* fix: naming of private member variables

* fix: graceful shutdown now works in browser

* fix: window event listener will trigger once

* fix: modify global shutdown helper functions

* fix: remove callback from remove listener args

* fix: change global shutdown function names and simplify functionality

* fix: add rest of function refactoring and simplification

* fix: remove unintended code snippet

* fix: refactor naming of listener cleanup function and fix sandbox issue

* fix: make global shutdown cleanup local

* fix: change interval of MeterProvider collection to ensure it does not trigger through clock

* chore: removing _cleanupGlobalShutdownListeners

* fix: remove unnecesary trace provider member function

* Removing default span attributes (#1342)

* refactor(opentelemetry-tracing): removing default span attributes

Signed-off-by: Aravin Sivakumar <aravinarjunn@gmail.com>

* refactor(opentelemetry-tracing): removing default span attributed from tracer object

Signed-off-by: Aravin Sivakumar <aravinarjunn@gmail.com>

* refactor(opentelemetry-tracing): removing accidental add to package.json

Signed-off-by: Aravin Sivakumar <aravinarjunn@gmail.com>

* refactor(opentelemetry-tracing): removing redundant test and fixing suggestions by Shawn and Daniel

Signed-off-by: Aravin Sivakumar <aravinarjunn@gmail.com>

* feat: add baggage support to the opentracing shim (#918)

Co-authored-by: Mayur Kale <mayurkale@google.com>

* Add nodejs sdk package (#1187)

Co-authored-by: Naseem <naseemkullah@gmail.com>
Co-authored-by: legendecas <legendecas@gmail.com>
Co-authored-by: Mark Wolff <mrw00010@gmail.com>
Co-authored-by: Matthew Wear <matthew.wear@gmail.com>

* feat: add OTEL_LOG_LEVEL env var (#974)

* Proto update to latest to support arrays and maps (#1339)

* chore: 0.10.0 release proposal (#1345)

* fix: add missing grpc-js index (#1358)

* chore: 0.10.1 release proposal (#1359)

* feat(api/context-base): change compile target to es5 (#1368)

* Feat: Make ID generator configurable (#1331)

Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com>

* fix: require grpc-js instead of grpc in grpc-js example (#1364)

Co-authored-by: Bartlomiej Obecny <bobecny@gmail.com>

* chore(deps): update all non-major dependencies (#1371)

* chore: bump metapackage dependencies (#1383)

* chore: 0.10.2 proposal (#1382)

* fix: remove unnecesary trace provider member function

* refactor(metrics): distinguish different aggregator types (#1325)

Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com>

* Propagate b3 parentspanid and debug flag (#1346)

* feat: Export MinMaxLastSumCountAggregator metrics to the collector as Summary (#1320)

Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com>

* feat: Collector Metric Exporter for the Web (#1308)

Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com>

* Fix issues in TypeScript getting started example code (#1374)

Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com>

* chore: deploy canary releases (#1384)

* fix: protos pull

* fix: address marius' feedback

* chore: deleting removeAllListeners from prometheus, fixing tests, cleanu of events when using shutdown notifier

* fix: add documentation and cleanup code

* fix: remove async label from shutdown and cleanup test case

* fix: update controller collect to return promise

* fix: make downsides of disabling graceful shutdown more apparent

Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com>
Co-authored-by: Bartlomiej Obecny <bobecny@gmail.com>
Co-authored-by: Aravin <34178459+aravinsiva@users.noreply.github.com>
Co-authored-by: Ruben Vargas Palma <ruben.vp8510@gmail.com>
Co-authored-by: Mayur Kale <mayurkale@google.com>
Co-authored-by: Naseem <naseemkullah@gmail.com>
Co-authored-by: legendecas <legendecas@gmail.com>
Co-authored-by: Mark Wolff <mrw00010@gmail.com>
Co-authored-by: Matthew Wear <matthew.wear@gmail.com>
Co-authored-by: Naseem <naseem@transit.app>
Co-authored-by: Mark Wolff <mark.wolff@microsoft.com>
Co-authored-by: Cong Zou <32532612+EdZou@users.noreply.github.com>
Co-authored-by: Reginald McDonald <40721169+reggiemcdonald@users.noreply.github.com>
Co-authored-by: WhiteSource Renovate <bot@renovateapp.com>
Co-authored-by: srjames90 <srjames@lightstep.com>
Co-authored-by: David W <dwitt12345@gmail.com>
Co-authored-by: Mick Dekkers <mickdekkersnl@gmail.com>
pichlermarc pushed a commit to dynatrace-oss-contrib/opentelemetry-js that referenced this pull request Dec 15, 2023
pichlermarc pushed a commit to dynatrace-oss-contrib/opentelemetry-js that referenced this pull request Dec 15, 2023
* feat: use Otel SDK 1.2/0.28

* fixup! chore(deps): update dependency @types/react-dom to v18 (open-telemetry#974)

* host-metrics back to 0.27

* fix: correctly depen on contrib-test-utils

* fixup! fix: correctly depen on contrib-test-utils

* fixup! feat: use Otel SDK 1.2/0.28
martinkuba pushed a commit to martinkuba/opentelemetry-js that referenced this pull request Mar 13, 2024
* feat: use Otel SDK 1.2/0.28

* fixup! chore(deps): update dependency @types/react-dom to v18 (open-telemetry#974)

* host-metrics back to 0.27

* fix: correctly depen on contrib-test-utils

* fixup! fix: correctly depen on contrib-test-utils

* fixup! feat: use Otel SDK 1.2/0.28
martinkuba pushed a commit to martinkuba/opentelemetry-js that referenced this pull request Mar 16, 2024
* feat: use Otel SDK 1.2/0.28

* fixup! chore(deps): update dependency @types/react-dom to v18 (open-telemetry#974)

* host-metrics back to 0.27

* fix: correctly depen on contrib-test-utils

* fixup! fix: correctly depen on contrib-test-utils

* fixup! feat: use Otel SDK 1.2/0.28
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.

None yet

10 participants