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

[Discussion] How to handle creating spans when PHP Generators are involved? #1444

Open
dciprian-petrisor opened this issue Nov 28, 2024 · 1 comment

Comments

@dciprian-petrisor
Copy link

dciprian-petrisor commented Nov 28, 2024

Hi,

Sorry for posting this as an issue, don't know where else to ask.
I am using open-telemetry/opentelemetry-auto-psr16 to automatically create spans for CacheInterface calls.
Among the hooked-into methods, there are some that return iterable via yield keyword (Generators) (e.g. getMultiple).

This results in one span for each yield call, resulting in very long traces.

Is there any way that these can be grouped or deduplicated?
Do maintainers consider this an issue?

Thank you!

@brettmc
Copy link
Collaborator

brettmc commented Nov 29, 2024

Hello and welcome.
That seems correct, according to the integration tests: https://github.com/open-telemetry/opentelemetry-php-contrib/blob/main/src/Instrumentation/Psr16/tests/Integration/Psr16InstrumentationTest.php#L120

I don't think that the iterator/generator is relevant here, the issue is that getMultiple seems to then call get for each param to getMultiple.

I think the correct OpenTelemetry solution to your issue would be to use sampling. Since getMultiple already records each of the cache keys, perhaps you could just sample out all of the get spans?

The collector's filterprocessor will probably do what you want - the telemetry will still be generated, but you can discard the noisy parts as part of the processing pipeline.

You might be interested in trying out our RuleBasedSampler. It's still fairly new, but I think you'll be able to use it to not generate the get's.

We've also recently added scope configuration, which allows turning off providers by name: https://github.com/open-telemetry/opentelemetry-php/blob/main/tests/Integration/SDK/Trace/TracerConfigTest.php#L25 It wouldn't work now with Psr16 since everything uses the same tracer name io.opentelemetry.contrib.php.psr16, but it could possibly be refactored to allow it to work with scope configuration.

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

No branches or pull requests

2 participants