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

[Shim] Fix JSON Config #1203

Merged
merged 12 commits into from
Sep 15, 2023

Conversation

JacksonWeber
Copy link
Contributor

@JacksonWeber JacksonWeber commented Sep 6, 2023

  • Add remaining JSON config values.
  • Fix JSON config file path and stop us from overwriting defined env vars with undefined values from the JSON file.

@JacksonWeber JacksonWeber changed the title [Shim] Fix JSON Config & Native Metrics Init [Shim] Fix JSON Config Sep 8, 2023
src/shim/config.ts Outdated Show resolved Hide resolved
isInitialized = true;
const individualOptOuts: string = ShimJsonConfig.getInstance().noPatchModules;
Copy link
Member

Choose a reason for hiding this comment

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

Why are you adding the check here? you should be checking for config options in the subscriber code not here in publishers side

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rationale was that we used to disable diagnostic channels on the publisher side, however I agree it makes sense to disable them at a subscriber level. Will update that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactored this to use the publisher's enable functions (specifically not calling them if noDiagnosticChannel is set to true) in the same way as noPatchModules.

Copy link
Member

Choose a reason for hiding this comment

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

Not seeing those changes here, is there a commit missing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed such that we still do this check on the publisher side (line 26 is where we do the check for noDiagnosticChannel). It takes advantage of the same enable() methods each of the subscribers has. If we don't want to do this check for noDiagnosticChannel here we could move the logic for both noDiagnosticChannel and noPatchModules to each individual subscriber, but after looking into moving the code to the subscribers it seems like it'd make this logic more complicated than necessary.

@@ -4,14 +4,17 @@
// Don't reference modules from these directly. Use only for types.
import * as DiagChannelPublishers from "diagnostic-channel-publishers";
import { Logger } from "../../shared/logging";
import { ShimJsonConfig } from "../../shim/jsonConfig";
Copy link
Member

Choose a reason for hiding this comment

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

JSON config should never used outside of our Internal config class, value could be overridden using JS code so this ignores that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

noDiagnosticChannel and noPatchModules cannot be configured via defaultClient.config.noDiagnosticChannel or defaultClient.config.noPatchModules, only via env var or JSON config, so I don't believe this could be overridden before being read here. Were you referring to another way it could be overridden?

Copy link
Member

@hectorhdzg hectorhdzg left a comment

Choose a reason for hiding this comment

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

LGTM

@JacksonWeber JacksonWeber merged commit 4f792ac into microsoft:beta Sep 15, 2023
7 checks passed
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.

None yet

2 participants