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

[core-tracing] Allow tracing to be disabled by environment #5748

Closed
wants to merge 3 commits into from

Conversation

sophiajt
Copy link
Contributor

This allows tracing to be disabled via the AZURE_TRACING_DISABLED environment variable.

Part of the implementation for #5696.

@sophiajt sophiajt requested a review from daviwil October 23, 2019 20:35
@sophiajt sophiajt requested a review from ramya-rao-a as a code owner October 23, 2019 20:35
@@ -23,5 +23,8 @@ export function getTracer() {
if (!cache.tracer) {
cache.tracer = new NoOpTracer();
}
if (process.env.AZURE_TRACING_DISABLED) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Builds are failing in some places because of the use of process, I think event-hubs doesn't have its shim set up right. Might need to wrap this in a if (isNode) { block so that it gets elided in the browser builds.

Copy link
Member

@xirzec xirzec Oct 23, 2019

Choose a reason for hiding this comment

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

it seems like we were trying to check window.__env__ in the browser tho

Copy link
Member

Choose a reason for hiding this comment

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

in the logger package we were able to pass process: false in package.json:

{
"browser": {
    "./dist/index.js": "./browser/logger.js",
    "./dist-esm/src/log.js": "./dist-esm/src/log.browser.js",
    "process": false
  },
}

Copy link
Member

Choose a reason for hiding this comment

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

maybe that will help with the build breaks?

Copy link
Member

@bterlson bterlson Oct 24, 2019

Choose a reason for hiding this comment

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

process: false in the package.json browser map, plus guarding the process.env check with isNode, is probably the right way to go. I don't think we should support environment variables in the browser.

@daviwil
Copy link
Contributor

daviwil commented Oct 23, 2019

Hey @chradek, how does this approach look to you for disabling tracing via environment variable? Is there any possible gotcha here?

@@ -23,5 +28,8 @@ export function getTracer() {
if (!cache.tracer) {
cache.tracer = new NoOpTracer();
}
if (env.AZURE_TRACING_DISABLED) {
Copy link
Member

Choose a reason for hiding this comment

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

it does feel weird that this doesn't have to be truthy at all, e.g. someone could set AZURE_TRACING_DISABLED=false or AZURE_TRACING_DISABLED=0 and it would still disable

@@ -23,5 +28,8 @@ export function getTracer() {
if (!cache.tracer) {
cache.tracer = new NoOpTracer();
}
if (env.AZURE_TRACING_DISABLED) {
cache.tracer = new NoOpTracer();
Copy link
Member

Choose a reason for hiding this comment

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

getTracer gets called a lot, but right now you'd create a new no-op tracer each time... feels like we should maybe just have a static noop tracer that you can return early with instead of making a new one

@sophiajt sophiajt closed this Oct 24, 2019
@sophiajt sophiajt deleted the env_tracing branch October 24, 2019 01:26
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.

4 participants