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

Can't locate object method "allow_bignum" via package "JSON::XS" when using OpenTracing::Implementation->bootstrap_global_default_tracer(); #35

Open
marrem opened this issue Apr 17, 2024 · 4 comments

Comments

@marrem
Copy link

marrem commented Apr 17, 2024

I tested the DD implementation. First I did this:

use OpenTracing::Implementation qw(DataDog);

use OpenTracing::GlobalTracer qw ($tracer);
use OpenTracing::WrapScope qw(process);
use OpenTracing::AutoScope;

...

sub someMethod {
    OpenTracing::AutoScope->start_guarded_span();
    ... 
}

sub process {
    ...
}

That went OK. Traces being sent to DD.

Output:

imta@96fb838f3fe3:/usr/local/imta/lib/perl/CAIW/REST/Client/t$ perl OpenTracingExample.pl
---- start span context
---- start fetch context
Fetching ....
Fetching done
Processing ....
Done

But when running stuff locally, we don't always have a DD agent present. So I thought, let's use the OpenTracing::Implementation->bootstrap_global_default_tracer(); and set the environment variable PERL_OPENTRACING_IMPLEMENTATION as desired. Leaving the variable unset, we don't get ugly warnings when DD agent is not reachable.

So I did this:

use OpenTracing::Implementation;
OpenTracing::Implementation->bootstrap_global_default_tracer();

use OpenTracing::GlobalTracer qw ($tracer);
use OpenTracing::WrapScope qw(process);
use OpenTracing::AutoScope;

... 

etc 

Running the script with the PERL_OPENTRACING_IMPLEMENTATION unset, the script runs without warnings (when there is no DD agent reachable).

But when running with the variable set to 'DataDog' I get:

Output:

imta@96fb838f3fe3:/usr/local/imta/lib/perl/CAIW/REST/Client/t$ PERL_OPENTRACING_IMPLEMENTATION=DataDog perl OpenTracingExample.pl
---- start span context
---- start fetch context
Fetching ....
Fetching done
Processing ....
Done
Can't locate object method "allow_bignum" via package "JSON::XS" at /usr/local/share/perl/5.36.0/OpenTracing/Implementation/DataDog/Client.pm line 234.
	(in cleanup) Can't call method "get_context" on an undefined value at /usr/local/share/perl/5.36.0/OpenTracing/Implementation/DataDog/Client.pm line 439 during global destruction.
@marrem
Copy link
Author

marrem commented Apr 17, 2024

Seems like doing use OpenTracing::Implementation qw(DataDog); loads the Cpanel::JSON::XS module, which has a allow_bignum method.
Using use OpenTracing::Implementation; OpenTracing::Implementation->bootstrap_global_default_tracer(); Cpanel::JSON::XS is probably not loaded and JSON::XS is used, which hasn't got a allow_bignum.

So a temporary fix is to do a use Cpanel::JSON::XS; before use OpenTracing::Implementation;. This stops the error from occurring.

@vanHoesel
Copy link
Contributor

I'm afraid we overlooked that JSON::XS does not have a allow_bignum

Probably we'll need to borrow from JSON::MaybeXS and select either Channel::JSON::XS or old-fashioned JSON::PP to exclude JSON::XS.

@vanHoesel
Copy link
Contributor

I have a patch available to skip JSON::XS and will try to use Cpanel::JSON::XS in favour of JSON::PP, both supporting ->allow_bignum.

However, I find it hard to write proper test to prove correctness of this approach. I need to figure out how to bypass loading Cpanel::JSON::XS even though that is installed correctly.

@marrem
Copy link
Author

marrem commented May 8, 2024 via email

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