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

split config into own package #1248

Closed
wants to merge 14 commits into from
Closed

Conversation

brettmc
Copy link
Collaborator

@brettmc brettmc commented Mar 5, 2024

Moving configuration code out of the SDK means that it can be used by components that should not depend on the SDK.

  • move config into own package
  • update all core components which were self-managing config to use the config package
  • add some tests for config package to get coverage to 100%
  • add missing type-hints to config package
  • add missing config variables (OTEL_PHP_DEBUG_SCOPES_DISABLED and OTEL_PHP_FIBERS_ENABLED)

Prior to merge:

  • create gitsplit target repo
  • document that some components which formerly allowed truthy/falsey values will (or soon will) only accept true or false

Closes: #1245

@brettmc brettmc added this to the 1.1 milestone Mar 5, 2024
@brettmc brettmc requested a review from a team March 5, 2024 04:35
Copy link

codecov bot commented Mar 5, 2024

Codecov Report

Attention: Patch coverage is 83.87097% with 5 lines in your changes are missing coverage. Please review.

Project coverage is 72.83%. Comparing base (f2cba82) to head (28fe251).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main    #1248      +/-   ##
============================================
- Coverage     73.97%   72.83%   -1.14%     
+ Complexity     2365     2335      -30     
============================================
  Files           347      346       -1     
  Lines          7071     6988      -83     
============================================
- Hits           5231     5090     -141     
- Misses         1840     1898      +58     
Flag Coverage Δ
8.1 ?
8.2 ?
8.3 ?
8.4 72.83% <83.87%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
src/API/Behavior/Internal/LogWriterFactory.php 71.42% <100.00%> (-7.52%) ⬇️
...g/Configuration/Accessor/ClassConstantAccessor.php 100.00% <100.00%> (ø)
...c/Config/Configuration/Accessor/PhpIniAccessor.php 100.00% <100.00%> (ø)
src/Config/Configuration/Configuration.php 100.00% <100.00%> (ø)
src/Config/Configuration/Parser/BooleanParser.php 100.00% <100.00%> (ø)
src/Config/Configuration/Parser/ListParser.php 100.00% <100.00%> (ø)
src/Config/Configuration/Parser/MapParser.php 100.00% <100.00%> (ø)
src/Config/Configuration/Parser/RatioParser.php 100.00% <100.00%> (ø)
...onfig/Configuration/Resolver/CompositeResolver.php 100.00% <100.00%> (ø)
...fig/Configuration/Resolver/EnvironmentResolver.php 100.00% <100.00%> (ø)
... and 24 more

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f2cba82...28fe251. Read the comment docs.

@Nevay
Copy link
Contributor

Nevay commented Mar 5, 2024

IMO we shouldn't move everything out of the SDK, I would keep Variables (and Defaults + KnownValues if needed) in the component that uses them.

Configuration::validateVariableType() + ValueTypes + VariableTypes can be removed. They are only used to verify that code calls the correct method; no need to check this during runtime / should be verified by tests.

Because all of our configuration-management code is in the SDK, it's not usable by contrib modules etc which need to deal with config

We should also take file configuration and configuration via code into account. The configuration formats do not match 1:1 -> an intermediate instrumentation configuration model would make sense instead of using Configuration::getXXX() directly. This would be especially useful for complex configuration options that cannot be expressed as environment variable, e.g. configuration for a SQL sanitizer.

Example: HTTP instrumentation needs to know which request and response headers should be recorded as attributes. Env/ini configuration currently uses otel.instrumentation.http.request_headers and otel.instrumentation.http.response_headers, while file configuration might use:

instrumentation:
  config:
  - http_client:
      request_headers: []
      response_headers: []

Both formats could then populate the following intermediate model that is made available via a registry InstrumentationConfigurationRegistry::get(HttpClientInstrumentation::class).

class HttpClientInstrumentation implements InstrumentationConfiguration {
    public function __construct(
        public readonly array $requestHeaders = [],
        public readonly array $responseHeaders = [],
    ) {}
}

@Nevay Nevay mentioned this pull request Mar 5, 2024
@bobstrecansky bobstrecansky marked this pull request as draft April 3, 2024 12:02
per review feedback, this can be checked with tests rather than at runtime
@brettmc
Copy link
Collaborator Author

brettmc commented Apr 23, 2024

@Nevay

Configuration::validateVariableType() + ValueTypes + VariableTypes can be removed

Removed.

IMO we shouldn't move everything out of the SDK, I would keep Variables (and Defaults + KnownValues if needed) in the component that uses them.

I'm hesitant to do this, because then contrib packages need to depend on SDK to fetch config (unless we start splitting config up into SDK, general, and possibly also for any packages that have custom config)?

Both formats could then populate the following intermediate model that is made available via a registry

I started playing around with this. I thought perhaps factories could accept an InstrumentationConfiguration. It felt like double-handling if a ComponentProvider created an intermediate configuration, and as it stands the various factories build their own config as they go. Maybe this is worth a follow-up PR?

@Nevay
Copy link
Contributor

Nevay commented Apr 24, 2024

I'm hesitant to do this, because then contrib packages need to depend on SDK to fetch config (unless we start splitting config up into SDK, general, and possibly also for any packages that have custom config)?

Variables & co. contain only constants, not the code to actually fetch config.

I started playing around with this. I thought perhaps factories could accept an InstrumentationConfiguration. It felt like double-handling if a ComponentProvider created an intermediate configuration, and as it stands the various factories build their own config as they go. Maybe this is worth a follow-up PR?

I've created a prototype that utilizes the idea of #1274 to inject configuration into instrumentation: Nevay@2ecf4b2

@brettmc
Copy link
Collaborator Author

brettmc commented May 8, 2024

Closing, replaced by #1304

@brettmc brettmc closed this May 8, 2024
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.

Move SDK configuration into own package
3 participants