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(configs): make rc and http configs internal [3.0] [backport #12055 2.20] #12086

Open
wants to merge 1 commit into
base: 2.20
Choose a base branch
from

Conversation

mabdinur
Copy link
Contributor

@mabdinur mabdinur commented Jan 24, 2025

Backports: #12055

Checklist

  • PR author has checked that all the criteria below are met
  • The PR description includes an overview of the change
  • The PR description articulates the motivation for the change
  • The change includes tests OR the PR description describes a testing strategy
  • The PR description notes risks associated with the change, if any
  • Newly-added code is easy to change
  • The change follows the library release note guidelines
  • The change includes or references documentation updates if necessary
  • Backport labels are set (if applicable)

Reviewer Checklist

  • Reviewer has checked that all the criteria below are met
  • Title is accurate
  • All changes are related to the pull request's stated goal
  • Avoids breaking API changes
  • Testing strategy adequately addresses listed risks
  • Newly-added code is easy to change
  • Release note makes sense to a user of the library
  • If necessary, author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment
  • Backport labels are set in a manner that is consistent with the release branch maintenance policy

Prefixes the following `ddtrace.config` attributes with an `_`. These
attributes are internal to the tracer and should not be referenced or
modified by users:
- http
- http_server
- trace_headers
- header_is_traced
- convert_rc_trace_sampling_rules
- enable_remote_configuration
- get_from

Users should enable remote configuration and set `http` configurations
via environment variables.

- [ ] PR author has checked that all the criteria below are met
- The PR description includes an overview of the change
- The PR description articulates the motivation for the change
- The change includes tests OR the PR description describes a testing
strategy
- The PR description notes risks associated with the change, if any
- Newly-added code is easy to change
- The change follows the [library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

- [ ] Reviewer has checked that all the criteria below are met
- Title is accurate
- All changes are related to the pull request's stated goal
- Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- Testing strategy adequately addresses listed risks
- Newly-added code is easy to change
- Release note makes sense to a user of the library
- If necessary, author has acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment
- 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)
Copy link
Contributor

CODEOWNERS have been resolved as:

ddtrace/settings/_config.py                                             @DataDog/apm-core-python
releasenotes/notes/munir-deprecate-rc-http-configs-206f6c60ff383c05.yaml  @DataDog/apm-python
ddtrace/__init__.py                                                     @DataDog/apm-core-python
ddtrace/_monkey.py                                                      @DataDog/apm-core-python
ddtrace/_trace/sampler.py                                               @DataDog/apm-sdk-api-python
ddtrace/contrib/flask/__init__.py                                       @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/httplib/__init__.py                                     @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/internal/aiohttp/middlewares.py                         @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/internal/botocore/patch.py                              @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/internal/dramatiq/patch.py                              @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/internal/httplib/patch.py                               @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/internal/requests/connection.py                         @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/internal/sanic/patch.py                                 @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/internal/tornado/handlers.py                            @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/internal/trace_utils.py                                 @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/jinja2/__init__.py                                      @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/requests/__init__.py                                    @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/internal/remoteconfig/worker.py                                 @DataDog/remote-config @DataDog/apm-core-python
ddtrace/internal/sampling.py                                            @DataDog/apm-sdk-api-python
ddtrace/internal/writer/writer.py                                       @DataDog/apm-core-python
ddtrace/propagation/_database_monitoring.py                             @DataDog/apm-sdk-api-python
ddtrace/settings/__init__.py                                            @DataDog/apm-core-python
ddtrace/settings/config.py                                              @DataDog/python-guild @DataDog/apm-sdk-api-python
ddtrace/settings/dynamic_instrumentation.py                             @DataDog/debugger-python
ddtrace/settings/integration.py                                         @DataDog/apm-core-python
docs/advanced_usage.rst                                                 @DataDog/python-guild
tests/ci_visibility/test_ci_visibility.py                               @DataDog/ci-app-libraries
tests/contrib/httplib/test_httplib_distributed.py                       @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/jinja2/test_jinja2.py                                     @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/requests/test_requests.py                                 @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/requests/test_requests_distributed.py                     @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/tornado/test_tornado_web.py                               @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/vertica/test_vertica.py                                   @DataDog/apm-core-python @DataDog/apm-idm-python
tests/internal/remoteconfig/test_remoteconfig.py                        @DataDog/remote-config @DataDog/apm-core-python
tests/internal/test_settings.py                                         @DataDog/apm-core-python
tests/telemetry/test_writer.py                                          @DataDog/apm-python
tests/tracer/test_env_vars.py                                           @DataDog/apm-sdk-api-python
tests/tracer/test_global_config.py                                      @DataDog/apm-sdk-api-python
tests/tracer/test_instance_config.py                                    @DataDog/apm-sdk-api-python
tests/tracer/test_settings.py                                           @DataDog/apm-sdk-api-python
tests/tracer/test_trace_utils.py                                        @DataDog/apm-sdk-api-python

Comment on lines +1023 to +1024
else:
return None
Copy link
Contributor

Choose a reason for hiding this comment

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

Code Quality Violation

else is not necessary since the if clause has a return (...read more)

If the code in the if branch returns a value, do not have the else branch present.

View in Datadog  Leave us feedback  Documentation

# If no data is submitted then the RC config has been deleted. Revert the settings.
base_rc_config = {n: None for n in self._config}

if config and "lib_config" in config:
Copy link
Contributor

Choose a reason for hiding this comment

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

🟠 Code Quality Violation

Found too many nested ifs within this condition (...read more)

Too many nested loops make the code hard to read and understand. Simplify your code by removing nesting levels and separate code in small units.

View in Datadog  Leave us feedback  Documentation

def get_error_ranges(error_range_str):
# type: (str) -> List[Tuple[int, int]]
error_ranges = []
error_range_str = error_range_str.strip()
Copy link
Contributor

Choose a reason for hiding this comment

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

🟠 Code Quality Violation

variable name is the same as a function parameter (...read more)

A function parameter should only be read and not be modified. If your intent is to modify the value of the parameter, return the value in the function and handle the new value in the caller of the function.

View in Datadog  Leave us feedback  Documentation

break
telemetry_writer.add_configuration(self._name, self.value(), self.source())

def set_value_source(self, value: Any, source: _ConfigSource) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

🟠 Code Quality Violation

do not use Any, use a concrete type (...read more)

Use the Any type very carefully. Most of the time, the Any type is used because we do not know exactly what type is being used. If you want to specify that a value can be of any type, use object instead of Any.

Learn More

View in Datadog  Leave us feedback  Documentation

Example of a converted rule:
'[{"sample_rate":1.0,"service":"my-service","resource":"*","name":"web.request","tags":{"care_about":"yes","region":"us-*"},provenance":"customer"}]'
"""
rc_rules = self._remove_invalid_rules(rc_rules)
Copy link
Contributor

Choose a reason for hiding this comment

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

🟠 Code Quality Violation

variable name is the same as a function parameter (...read more)

A function parameter should only be read and not be modified. If your intent is to modify the value of the parameter, return the value in the function and handle the new value in the caller of the function.

View in Datadog  Leave us feedback  Documentation

"""
# DEV: Use `getattr()` to call our `__getattr__` helper
existing = getattr(self, integration)
settings = deepcopy(settings)
Copy link
Contributor

Choose a reason for hiding this comment

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

🟠 Code Quality Violation

variable name is the same as a function parameter (...read more)

A function parameter should only be read and not be modified. If your intent is to modify the value of the parameter, return the value in the function and handle the new value in the caller of the function.

View in Datadog  Leave us feedback  Documentation

@mabdinur mabdinur changed the title chore(configs): make rc and http configs internal [3.0] (backport #12055 to 2.20) chore(configs): make rc and http configs internal [3.0] [backport #12055 to 2.20] Jan 24, 2025
@mabdinur mabdinur changed the title chore(configs): make rc and http configs internal [3.0] [backport #12055 to 2.20] chore(configs): make rc and http configs internal [3.0] [backport #12055 2.20] Jan 24, 2025
@datadog-dd-trace-py-rkomorn
Copy link

Datadog Report

Branch report: munir/backport-12055-2-20
Commit report: d278658
Test service: dd-trace-py

✅ 0 Failed, 130 Passed, 1468 Skipped, 4m 30.53s Total duration (36m 53.14s time saved)

@pr-commenter
Copy link

pr-commenter bot commented Jan 24, 2025

Benchmarks

Benchmark execution time: 2025-01-24 22:34:48

Comparing candidate commit d278658 in PR branch munir/backport-12055-2-20 with baseline commit fe4d74a in branch 2.20.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 394 metrics, 2 unstable metrics.

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.

1 participant