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(logging)!: set default value of DD_CALL_BASIC_CONFIG to False #3168

Merged
merged 1 commit into from
Feb 16, 2022

Conversation

mabdinur
Copy link
Contributor

@mabdinur mabdinur commented Jan 24, 2022

ddtrace should not call logging.basicConfig since it is not a logging library.

This PR updates the default value of DD_CALL_BASIC_CONFIG to False and logs a deprecation warning if DD_CALL_BASIC_CONFIG configuration is set to True.

Checklist

  • Added to the correct milestone.
  • Tests provided or description of manual testing performed is included in the code or PR.
  • Library documentation is updated.
  • Corp site documentation is updated (link to the PR).

@mabdinur mabdinur added the v1.0 label Jan 24, 2022
@mergify
Copy link
Contributor

mergify bot commented Jan 24, 2022

@mabdinur this pull request is now in conflict 😩

@mergify mergify bot added the conflict label Jan 24, 2022
@mabdinur mabdinur changed the base branch from master to 1.0-dev January 24, 2022 19:58
@mergify mergify bot removed the conflict label Jan 24, 2022
@mabdinur mabdinur changed the title feat:! Set default value of DD_CALL_BASIC_CONFIG to false feat!: Set default value of DD_CALL_BASIC_CONFIG to false Jan 24, 2022
@mergify
Copy link
Contributor

mergify bot commented Jan 24, 2022

@mabdinur this pull request is now in conflict 😩

@mergify mergify bot added the conflict label Jan 24, 2022
@mergify mergify bot removed the conflict label Jan 24, 2022
@mabdinur mabdinur changed the title feat!: Set default value of DD_CALL_BASIC_CONFIG to false feat!: Remove DD_CALL_BASIC_CONFIG from the public api [ddtrace 1.0] Jan 24, 2022
@mabdinur mabdinur marked this pull request as ready for review January 24, 2022 22:47
@mabdinur mabdinur requested a review from a team as a code owner January 24, 2022 22:47
@mabdinur mabdinur changed the title feat!: Remove DD_CALL_BASIC_CONFIG from the public api [ddtrace 1.0] chore!: Remove DD_CALL_BASIC_CONFIG from the public api [ddtrace 1.0] Jan 25, 2022
@mabdinur mabdinur changed the title chore!: Remove DD_CALL_BASIC_CONFIG from the public api [ddtrace 1.0] chore!: remove DD_CALL_BASIC_CONFIG from the public api [ddtrace 1.0] Jan 25, 2022
@mabdinur mabdinur changed the title chore!: remove DD_CALL_BASIC_CONFIG from the public api [ddtrace 1.0] chore!: remove DD_CALL_BASIC_CONFIG from the public api [merge to v1.0] Jan 25, 2022
@mabdinur mabdinur added the manual merge Do not automatically merge label Jan 25, 2022
brettlangdon
brettlangdon previously approved these changes Jan 27, 2022
Copy link
Member

@Kyle-Verhoog Kyle-Verhoog left a comment

Choose a reason for hiding this comment

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

The change looks good to me. The one concern I have is whether or not we want this to be included in 1.0.

The philosophy of 1.0 was to privatize/hide as much implementation detail as possible. While we definitely want to make this change I'm not sure if we want to add it to 1.0 as it could add additional overhead to upgrading.

I think once we have the almost complete list of release notes for 1.0 we can evaluate whether this change should be included or not.

@brettlangdon @mabdinur thoughts?

ddtrace/bootstrap/sitecustomize.py Outdated Show resolved Hide resolved
ddtrace/commands/ddtrace_run.py Outdated Show resolved Hide resolved
@brettlangdon
Copy link
Member

The change looks good to me. The one concern I have is whether or not we want this to be included in 1.0.

The philosophy of 1.0 was to privatize/hide as much implementation detail as possible. While we definitely want to make this change I'm not sure if we want to add it to 1.0 as it could add additional overhead to upgrading.

I think once we have the almost complete list of release notes for 1.0 we can evaluate whether this change should be included or not.

@brettlangdon @mabdinur thoughts?

An alternative idea is to just change the default of DD_CALL_BASIC_CONFIG to False. That way people can still enable if they rely on it. Then in a future version we can mark as deprecated and then remove.

@mabdinur
Copy link
Contributor Author

mabdinur commented Feb 1, 2022

The change looks good to me. The one concern I have is whether or not we want this to be included in 1.0.
The philosophy of 1.0 was to privatize/hide as much implementation detail as possible. While we definitely want to make this change I'm not sure if we want to add it to 1.0 as it could add additional overhead to upgrading.
I think once we have the almost complete list of release notes for 1.0 we can evaluate whether this change should be included or not.
@brettlangdon @mabdinur thoughts?

An alternative idea is to just change the default of DD_CALL_BASIC_CONFIG to False. That way people can still enable if they rely on it. Then in a future version we can mark as deprecated and then remove.

After discussing this offline we'll move forward with removing logging.basicConfig from tracer startup. A ddtrace logging handler will be introduced in a future change.

Copy link
Member

@brettlangdon brettlangdon left a comment

Choose a reason for hiding this comment

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

I can't remember if we discussed this, but I wonder if we should keep the code as-is, but just change DD_CALL_BASIC_CONFIG default to False.

Keeping the env variable means if someone was relying on it then there is at least a feature flag they can toggle to get the behavior back.

However, keeping it also means we should get rid of it in the future.

What do others think?

@mabdinur mabdinur removed the v1.0 label Feb 14, 2022
@mergify mergify bot removed the conflict label Feb 15, 2022
@mabdinur mabdinur changed the base branch from 1.0-dev to next-1.0-dev February 15, 2022 16:54
@mergify
Copy link
Contributor

mergify bot commented Feb 15, 2022

@mabdinur this pull request is now in conflict 😩

@mergify mergify bot added conflict and removed conflict labels Feb 15, 2022
@mabdinur mabdinur added the v1.0 label Feb 15, 2022
@mabdinur mabdinur changed the title chore(logging): deprecate DD_CALL_BASIC_CONFIG and update default value chore(logging): set default value of DD_CALL_BASIC_CONFIG to False Feb 15, 2022
@brettlangdon brettlangdon changed the title chore(logging): set default value of DD_CALL_BASIC_CONFIG to False chore(logging)!: set default value of DD_CALL_BASIC_CONFIG to False Feb 15, 2022
@mabdinur mabdinur force-pushed the munir/disable-logging branch 2 times, most recently from 6e7fa7e to ff69c23 Compare February 15, 2022 21:30
@mabdinur mabdinur force-pushed the munir/disable-logging branch 3 times, most recently from 5990c5e to 6901d21 Compare February 15, 2022 22:05
@mergify mergify bot merged this pull request into next-1.0-dev Feb 16, 2022
@mergify mergify bot deleted the munir/disable-logging branch February 16, 2022 02:16
majorgreys pushed a commit that referenced this pull request Feb 16, 2022
…3168)

ddtrace should not call `logging.basicConfig` since it is not a logging library.  

This PR updates the default value of ``DD_CALL_BASIC_CONFIG`` to False and logs a deprecation warning if DD_CALL_BASIC_CONFIG configuration is set to True.

## Checklist
- [ ] Added to the correct milestone.
- [ ] Tests provided or description of manual testing performed is included in the code or PR.
- [ ] Library documentation is updated.
- [ ] [Corp site](https://github.com/DataDog/documentation/) documentation is updated (link to the PR).
majorgreys pushed a commit that referenced this pull request Feb 17, 2022
…3168)

ddtrace should not call `logging.basicConfig` since it is not a logging library.  

This PR updates the default value of ``DD_CALL_BASIC_CONFIG`` to False and logs a deprecation warning if DD_CALL_BASIC_CONFIG configuration is set to True.

## Checklist
- [ ] Added to the correct milestone.
- [ ] Tests provided or description of manual testing performed is included in the code or PR.
- [ ] Library documentation is updated.
- [ ] [Corp site](https://github.com/DataDog/documentation/) documentation is updated (link to the PR).
majorgreys pushed a commit that referenced this pull request Feb 18, 2022
…3168)

ddtrace should not call `logging.basicConfig` since it is not a logging library.  

This PR updates the default value of ``DD_CALL_BASIC_CONFIG`` to False and logs a deprecation warning if DD_CALL_BASIC_CONFIG configuration is set to True.

## Checklist
- [ ] Added to the correct milestone.
- [ ] Tests provided or description of manual testing performed is included in the code or PR.
- [ ] Library documentation is updated.
- [ ] [Corp site](https://github.com/DataDog/documentation/) documentation is updated (link to the PR).
Yun-Kim added a commit that referenced this pull request Sep 1, 2023
## Summary

This PR removes the `DD_CALL_BASIC_CONFIG` environment variable and
`DD_LOG_FORMAT` constant from the public API, and features a subtle
change in the library's logging functionality to avoid configuring the
user application's root-level logger. Moving forward, we will configure
the `ddtrace` level logger instead.

Additionally, this PR adds a new default behavior to ensure that ddtrace
will always log to both stdout (stream) and/or file if configured to log
to file. Previously ddtrace would only log to stream OR file, but this
isn't intuitive for users.

## Background

`DD_CALL_BASIC_CONFIG` was deprecated as of #3168 (February 2022). This
environment variable is currently used to enable the ddtrace library to
call `logging.basicConfig()` to configure and format the root logger to
print logs to stdout (when being run in `ddtrace-run` or through tracer
debugging mode).

However, the ddtrace library is not a logging library and calling
`logging.basicConfig()` will configure the root-level logger and
invalidate any future calls to `logging.basicConfig()`, meaning this
will potentially interfere with user logging configuration. User
applications should be responsible for calling `logging.basicConfig()`
instead of ddtrace.

## Proposed Solution

Instead of calling loggging.basicConfig(), we instead now configure the
ddtrace level logger at module startup (no longer at sitecustomize.py or
tracer startup) to add a stdout Streamhandler (or file logger if
specified by `DD_TRACE_LOG_FILE`) to avoid interfering with root-level
logger configurations. Note that we still configure logging injection at
sitecustomize.py and tracer startup since that requires logging to be
patched.

Note: this PR leaves one usage of `logging.basicConfig()` in
`ddtrace/commands/ddtrace_run.py`. This will not impact user application
logging because our `ddtrace-run` script replaces the currently running
process with the bootstrap script and user application through
`os.execl(...)`, meaning this will reset a new logging configuration to
default and be unaffected once the bootstrap sitecustomize and user
application starts running. This approach will leave ddtrace-run
debugging logs to be printed to stdout but still avoids interfering with
user application logging configurations.

## Checklist

- [x] Change(s) are motivated and described in the PR description.
- [x] Testing strategy is described if automated tests are not included
in the PR.
- [x] Risk is outlined (performance impact, potential for breakage,
maintainability, etc).
- [x] Change is maintainable (easy to change, telemetry, documentation).
- [x] [Library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
are followed. If no release note is required, add label
`changelog/no-changelog`.
- [x] Documentation is included (in-code, generated user docs, [public
corp docs](https://github.com/DataDog/documentation/)).
- [x] Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## Reviewer Checklist

- [x] Title is accurate.
- [x] No unnecessary changes are introduced.
- [x] Description motivates each change.
- [x] Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes unless absolutely necessary.
- [x] Testing strategy adequately addresses listed risk(s).
- [x] Change is maintainable (easy to change, telemetry, documentation).
- [x] Release note makes sense to a user of the library.
- [x] Reviewer has explicitly acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment.
- [x] Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)
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.

3 participants