Skip to content

Conversation

@smaddock
Copy link
Contributor

Related to the general issue tracked in open-telemetry/semantic-conventions#877

There have been related PRs for OpenTelemetry Semantic Conventions in an attempt to define this, but it seems they were too broad to gain consensus. However, I have not seen any comments contrary to the specific feature implemented by this PR, exemplified here:

For users who want to change the default behavior, OpenTelemetry should provide a consistent way instead of let the user struggle in a jungle of 20+ instrumentation libraries where each have different ways of doing redaction. ref

and here:

we discussed the idea of having generalized SDK capabilities for redaction, is this still something we want? If so I am happy to work towards a proposal for that.

I'd definitely answer that with a yes. Users might want to have redaction capabilities they can use for data that doesn't conform to OTel semantic conventions. ref

Since that has not yet come to fruition, but these is still a need, I propose implementing this PR for at a minimum this PHP auto-instrumentation library, with the goal of aligning the mechanism with what SemConv decides in the future.

Note that this PR does not allow for overriding the required query keys defined in footnote 6 here: https://github.com/open-telemetry/semantic-conventions/blob/main/docs/registry/attributes/url.md#url-query but allows the user of this library to add additional keys to the redaction list.

Slack conversation specifically for this PR: https://cloud-native.slack.com/archives/C01NFPCV44V/p1748367527296729

@smaddock smaddock requested a review from a team as a code owner May 27, 2025 19:14
@codecov
Copy link

codecov bot commented May 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.62%. Comparing base (138d1f1) to head (048fc56).
Report is 3 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##               main     #379   +/-   ##
=========================================
  Coverage     82.61%   82.62%           
- Complexity     1929     1930    +1     
=========================================
  Files           141      141           
  Lines          8063     8067    +4     
=========================================
+ Hits           6661     6665    +4     
  Misses         1402     1402           
Flag Coverage Δ
Aws 92.59% <ø> (ø)
Context/Swoole 0.00% <ø> (ø)
Instrumentation/AwsSdk 81.13% <ø> (ø)
Instrumentation/CakePHP 20.40% <ø> (ø)
Instrumentation/CodeIgniter 73.55% <ø> (ø)
Instrumentation/Curl 90.42% <ø> (ø)
Instrumentation/Doctrine 92.72% <ø> (ø)
Instrumentation/ExtAmqp 88.48% <ø> (ø)
Instrumentation/ExtRdKafka 86.11% <ø> (ø)
Instrumentation/Guzzle 69.13% <ø> (ø)
Instrumentation/HttpAsyncClient 78.04% <ø> (ø)
Instrumentation/IO 70.68% <ø> (ø)
Instrumentation/Laravel 63.91% <ø> (ø)
Instrumentation/MongoDB 74.28% <ø> (ø)
Instrumentation/MySqli 95.81% <ø> (ø)
Instrumentation/OpenAIPHP 87.21% <ø> (ø)
Instrumentation/PDO 94.21% <ø> (ø)
Instrumentation/Psr14 76.47% <ø> (ø)
Instrumentation/Psr15 89.15% <ø> (ø)
Instrumentation/Psr16 97.50% <ø> (ø)
Instrumentation/Psr18 77.46% <ø> (ø)
Instrumentation/Psr3 67.01% <ø> (ø)
Instrumentation/Psr6 97.61% <ø> (ø)
Instrumentation/ReactPHP 99.45% <100.00%> (+0.01%) ⬆️
Instrumentation/Slim 86.11% <ø> (ø)
Instrumentation/Symfony 84.74% <ø> (ø)
Instrumentation/Yii 77.50% <ø> (ø)
Logs/Monolog 100.00% <ø> (ø)
Propagation/Instana 98.11% <ø> (ø)
Propagation/ServerTiming 100.00% <ø> (ø)
Propagation/TraceResponse 100.00% <ø> (ø)
ResourceDetectors/Azure 91.66% <ø> (ø)
ResourceDetectors/Container 93.02% <ø> (ø)
Sampler/RuleBased 33.51% <ø> (ø)
Shims/OpenTracing 92.45% <ø> (ø)
Symfony 87.81% <ø> (ø)
Utils/Test 87.53% <ø> (ø)

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

Files with missing lines Coverage Δ
...mentation/ReactPHP/src/ReactPHPInstrumentation.php 99.43% <100.00%> (+0.01%) ⬆️

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 138d1f1...048fc56. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cedricziel
Copy link
Contributor

I like the PR - OTEL_PHP_INSTRUMENTATION_URL_SANITIZE_FIELD_NAMES makes it sound like this would be available in all instrumentations.

Do you see yourself adding this as a util so instrumentations could share the behavior?

@smaddock
Copy link
Contributor Author

smaddock commented Jun 3, 2025

I like the PR - OTEL_PHP_INSTRUMENTATION_URL_SANITIZE_FIELD_NAMES makes it sound like this would be available in all instrumentations.

Do you see yourself adding this as a util so instrumentations could share the behavior?

I would be happy to! Currently, this would add a dependency to the API package (guzzlehttp/psr7), per:

// http_build_query(parse_str()) is not idempotent, so using Guzzle’s Query class for now

Since that package is licensed MIT, perhaps it is acceptable to add that one class to the OTel-PHP codebase? https://github.com/guzzle/psr7/blob/2.7/src/Query.php

@Nevay
Copy link
Contributor

Nevay commented Jun 3, 2025

Somewhat related: I plan on adding support for env-based configuration of ConfigProperties which would unify access to declarative config and env-based config and could provide an UriSanitizer implementation that is available to all HTTP instrumentations.

Example configuration provider: InstrumentationConfigurationHttp; the entire package could be moved to contrib once config support is added/moved to an API package
Example instrumentation using the config: AmphpHttpClientInstrumentation

@smaddock
Copy link
Contributor Author

smaddock commented Jun 4, 2025

@Nevay are you saying it would be redundant for me to extract my current implementation to a shared utility, and eventually you’ll have something committed that I could replace mine with?

@smaddock
Copy link
Contributor Author

These checks should pass now with #371 merged.

@bobstrecansky bobstrecansky merged commit 63fc926 into open-telemetry:main Jun 11, 2025
144 checks passed
@smaddock smaddock deleted the reactphp branch June 11, 2025 18:29
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