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

Be less restrictive when autoloading instrumentation libraries #133

Merged
merged 2 commits into from
Mar 29, 2023

Conversation

xvilo
Copy link
Contributor

@xvilo xvilo commented Mar 28, 2023

Emit a warning through PHP's trigger_error instead of using an assert function call. This allows one to use the libraries in environments where the extension might not be available. However, in case of issues, it will be clear through logs why code might not be instrumented.

The following approach was shortly discussed in the CNCF Slack, which should be fine for the use case at hand. The project can still run in environments that are not compatible or that are misconfigured.

I would personally also add a check for the OTEL_PHP_AUTOLOAD_ENABLED to let these autoload/configure. Through that, one could use the code in the libraries but not autoload it, or just let it autoload when needed. This can be discussed at a later point in time, though.

As a side note, I noticed that only the WordPress auto-instrumenter had an import for the Instrumentation class, so I took the liberty to add imports in all the files. Now they are more the same.

@xvilo xvilo requested a review from a team March 28, 2023 12:44
@welcome
Copy link

welcome bot commented Mar 28, 2023

Thanks for opening your first pull request! If you haven't yet signed our Contributor License Agreement (CLA), then please do so that we can accept your contribution. A link should appear shortly in this PR if you have not already signed one.

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Mar 28, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: xvilo / name: Sem Schilder (44668c3)

Emit a warning through trigger_error instead of using an assert. This will allow one
to use the libraries in environments where the extension might not be available.
However in case of issues, it will be clear through logs why code might not be
instrumented
@codecov
Copy link

codecov bot commented Mar 28, 2023

Codecov Report

Merging #133 (1c31e86) into main (ccd5c7b) will not change coverage.
The diff coverage is n/a.

❗ Current head 1c31e86 differs from pull request most recent head ea80c0e. Consider uploading reports for the commit ea80c0e to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##               main     #133   +/-   ##
=========================================
  Coverage     52.72%   52.72%           
  Complexity      447      447           
=========================================
  Files            48       48           
  Lines          1686     1686           
=========================================
  Hits            889      889           
  Misses          797      797           
Flag Coverage Δ
7.4 81.76% <ø> (ø)
8.0 59.42% <ø> (ø)
8.1 59.49% <ø> (ø)
8.2 52.64% <ø> (ø)

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


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 ccd5c7b...ea80c0e. Read the comment docs.

@brettmc
Copy link
Collaborator

brettmc commented Mar 28, 2023

This PR reminded me that we also have the capability to turn off auto-instrumentations by config, since open-telemetry/opentelemetry-php#909, but it has not been added to the . I think it should be an extra check right where you have added the various _register scripts. How do you feel about adding that here?

@xvilo
Copy link
Contributor Author

xvilo commented Mar 29, 2023

That would be a great idea @brettmc, I didn't know that was already there. However, I do feel personally a discussion is in place about certain things and would like to discuss this first in an issue. So for now, I'd like this PR scoped to just replacing the assert function calls.

Furthermore, I have fixed the code style issues for some sub-libraries. We might want to stream-line those as well, as not all projects have php-cs-fixer in them, but that's also something for later.

@pdelewski
Copy link
Member

I forgot about this capability open-telemetry/opentelemetry-php#909, but I agree that this is right place to discuss such things

@brettmc brettmc merged commit 0fc74cb into open-telemetry:main Mar 29, 2023
@brettmc
Copy link
Collaborator

brettmc commented Mar 29, 2023

created open-telemetry/opentelemetry-php#947 for somebody to implement disabling via config

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