diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 339c3dd..cc0ad8f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,7 +17,7 @@ jobs: # All supported Perl versions except latest. perl: [ - '5.32', '5.34', '5.36', + '5.30', '5.32', '5.34', '5.36', ] # Variants of the latest Perl. diff --git a/Build.PL b/Build.PL index d614840..fc4a50e 100644 --- a/Build.PL +++ b/Build.PL @@ -3,7 +3,7 @@ use strict; use warnings; -use v5.32.0; +use v5.30.0; use Module::Build::Tiny 0.034; Build_PL(); diff --git a/Changes b/Changes index 33c2a95..1599385 100644 --- a/Changes +++ b/Changes @@ -3,6 +3,10 @@ Revision history for OpenTelemetry {{$NEXT}} * Fixed some minor nits in the documentation + * Add 'isa' as a dependency and reduce the minimum supported Perl + version to 5.30. If you are running 5.30 please consider installing + Type::Tiny::XS which should improve the performance of these 'isa' + checks. 0.026 2024-12-16 09:02:42+00:00 Europe/London diff --git a/META.json b/META.json index 0792fce..d2cb572 100644 --- a/META.json +++ b/META.json @@ -27,7 +27,7 @@ "configure" : { "requires" : { "Module::Build::Tiny" : "0.034", - "perl" : "v5.32.0" + "perl" : "v5.30.0" } }, "develop" : { @@ -61,7 +61,8 @@ "URL::Encode" : "0", "UUID::URandom" : "0", "X::Tiny" : "0", - "perl" : "v5.32.0" + "isa" : "0", + "perl" : "v5.30.0" } }, "test" : { @@ -75,7 +76,7 @@ "Metrics::Any" : "0", "Test2::V0" : "0", "Test::More" : "0", - "perl" : "v5.32.0" + "perl" : "v5.30.0" } } }, diff --git a/cpanfile b/cpanfile index 0c7ce60..015dfd8 100644 --- a/cpanfile +++ b/cpanfile @@ -1,3 +1,4 @@ +requires 'isa'; # To support perls older than 5.32 requires 'Bytes::Random::Secure'; requires 'Class::Method::Modifiers'; requires 'Exporter::Tiny', '0.044'; # For -as => CODE support diff --git a/dist.ini b/dist.ini index 7db7e8c..2085b6c 100644 --- a/dist.ini +++ b/dist.ini @@ -22,6 +22,8 @@ Release_Commit.commit_msg = Release v%V%t RewriteVersion.global = 1 [MinimumPerl] +perl = v5.30.0 + [Prereqs::FromCPANfile] [Repository] diff --git a/lib/OpenTelemetry.pm b/lib/OpenTelemetry.pm index c21638a..1e599f9 100644 --- a/lib/OpenTelemetry.pm +++ b/lib/OpenTelemetry.pm @@ -3,7 +3,7 @@ package OpenTelemetry; use strict; use warnings; -use experimental qw( isa signatures ); +use experimental qw( signatures ); our $VERSION = '0.027'; @@ -18,6 +18,11 @@ use Scalar::Util 'refaddr'; use Ref::Util 'is_coderef'; use Sentinel; +use isa qw( + OpenTelemetry::Logs::LoggerProvider + OpenTelemetry::Trace::TracerProvider +); + use Log::Any; use Exporter::Shiny qw( @@ -45,7 +50,7 @@ sub _generate_otel_logger { \&logger } my $set = sub ( $new ) { die OpenTelemetry::X->create( Invalid => 'Global tracer provider must be a subclass of OpenTelemetry::Trace::TracerProvider, got instead ' . ( ref $new || 'a plain scalar' ), - ) unless $new isa OpenTelemetry::Trace::TracerProvider; + ) unless isa_OpenTelemetry_Trace_TracerProvider $new; $lock->enter( sub { $instance = $new }); }; @@ -77,7 +82,7 @@ sub _generate_otel_logger { \&logger } my $set = sub ( $new ) { die OpenTelemetry::X->create( Invalid => 'Global logger provider must be a subclass of OpenTelemetry::Logs::LoggerProvider, got instead ' . ( ref $new || 'a plain scalar' ), - ) unless $new isa OpenTelemetry::Logs::LoggerProvider; + ) unless isa_OpenTelemetry_Logs_LoggerProvider $new; $lock->enter( sub { $instance = $new }); }; diff --git a/lib/OpenTelemetry/Context.pm b/lib/OpenTelemetry/Context.pm index 05dc08a..62123a6 100644 --- a/lib/OpenTelemetry/Context.pm +++ b/lib/OpenTelemetry/Context.pm @@ -25,7 +25,8 @@ sub key ( $, $name ) { class OpenTelemetry::Context { use OpenTelemetry::X; - use experimental 'isa'; + + use isa 'OpenTelemetry::Context::Key'; field $data :param = {}; @@ -34,7 +35,7 @@ class OpenTelemetry::Context { method get ( $key ) { die OpenTelemetry::X->create( Invalid => 'Keys in a context object must be instances of OpenTelemetry::Context::Key', - ) unless $key isa OpenTelemetry::Context::Key; + ) unless isa_OpenTelemetry_Context_Key $key; $data->{ $key->string }; } @@ -42,7 +43,7 @@ class OpenTelemetry::Context { method set ( $key, $value ) { die OpenTelemetry::X->create( Invalid => 'Keys in a context object must be instances of OpenTelemetry::Context::Key', - ) unless $key isa OpenTelemetry::Context::Key; + ) unless isa_OpenTelemetry_Context_Key $key; OpenTelemetry::Context->new( %$data, $key->string, $value ) } @@ -50,7 +51,7 @@ class OpenTelemetry::Context { method delete ( $key ) { die OpenTelemetry::X->create( Invalid => 'Keys in a context object must be instances of OpenTelemetry::Context::Key', - ) unless $key isa OpenTelemetry::Context::Key; + ) unless isa_OpenTelemetry_Context_Key $key; my %copy = %$data; delete $copy{$key->string}; @@ -61,9 +62,10 @@ class OpenTelemetry::Context { # Context management { - use experimental 'isa'; use Sentinel; + use isa 'OpenTelemetry::Context'; + my $current = OpenTelemetry::Context->new; sub current :lvalue { sentinel( @@ -71,7 +73,7 @@ class OpenTelemetry::Context { set => sub { die OpenTelemetry::X->create( Invalid => 'Current context must be an instance of OpenTelemetry::Context, received instead ' . ref $_[0], - ) unless $_[0] isa OpenTelemetry::Context; + ) unless isa_OpenTelemetry_Context $_[0]; $current = $_[0]; }, diff --git a/lib/OpenTelemetry/Propagator/Baggage.pm b/lib/OpenTelemetry/Propagator/Baggage.pm index bd2d610..27d1bfd 100644 --- a/lib/OpenTelemetry/Propagator/Baggage.pm +++ b/lib/OpenTelemetry/Propagator/Baggage.pm @@ -13,7 +13,7 @@ class OpenTelemetry::Propagator::Baggage :does(OpenTelemetry::Propagator) { use OpenTelemetry::Propagator::TextMap; use URL::Encode qw( url_decode_utf8 url_encode_utf8 ); - use experimental 'isa'; + use isa 'OpenTelemetry::X'; my $KEY = 'baggage'; my $MAX_ENTRIES = 180; @@ -68,7 +68,7 @@ class OpenTelemetry::Propagator::Baggage :does(OpenTelemetry::Propagator) { $setter->( $carrier, $KEY, $encoded ) if $encoded; } catch($e) { - if ( $e isa OpenTelemetry::X ) { $logger->warn($e->get_message) } + if ( isa_OpenTelemetry_X $e ) { $logger->warn($e->get_message) } else { OpenTelemetry->handle_error( exception => $e, @@ -102,7 +102,7 @@ class OpenTelemetry::Propagator::Baggage :does(OpenTelemetry::Propagator) { $builder->build($context); } catch($e) { - if ( $e isa OpenTelemetry::X ) { $logger->warn($e->get_message) } + if ( isa_OpenTelemetry_X $e ) { $logger->warn($e->get_message) } else { OpenTelemetry->handle_error( exception => $e, diff --git a/lib/OpenTelemetry/Propagator/TraceContext.pm b/lib/OpenTelemetry/Propagator/TraceContext.pm index 844a42e..8691770 100644 --- a/lib/OpenTelemetry/Propagator/TraceContext.pm +++ b/lib/OpenTelemetry/Propagator/TraceContext.pm @@ -6,7 +6,7 @@ package OpenTelemetry::Propagator::TraceContext; our $VERSION = '0.027'; class OpenTelemetry::Propagator::TraceContext :does(OpenTelemetry::Propagator) { - use experimental 'isa'; + use isa 'OpenTelemetry::X'; use Feature::Compat::Try; use URL::Encode qw( url_decode_utf8 url_encode_utf8 ); @@ -46,7 +46,7 @@ class OpenTelemetry::Propagator::TraceContext :does(OpenTelemetry::Propagator) { $setter->( $carrier, $TRACE_STATE_KEY, $span_context->trace_state->to_string ); } catch($e) { - if ( $e isa OpenTelemetry::X ) { $logger->warn($e->get_message) } + if ( isa_OpenTelemetry_X $e ) { $logger->warn($e->get_message) } else { OpenTelemetry->handle_error( exception => $e, @@ -89,7 +89,7 @@ class OpenTelemetry::Propagator::TraceContext :does(OpenTelemetry::Propagator) { return OpenTelemetry::Trace->context_with_span( $span, $context ); } catch ($e) { - if ( $e isa OpenTelemetry::X ) { $logger->warn($e->get_message) } + if ( isa_OpenTelemetry_X $e ) { $logger->warn($e->get_message) } else { OpenTelemetry->handle_error( exception => $e, diff --git a/lib/OpenTelemetry/Trace/Link.pm b/lib/OpenTelemetry/Trace/Link.pm index 35724d0..e974ba3 100644 --- a/lib/OpenTelemetry/Trace/Link.pm +++ b/lib/OpenTelemetry/Trace/Link.pm @@ -6,15 +6,15 @@ package OpenTelemetry::Trace::Link; our $VERSION = '0.027'; class OpenTelemetry::Trace::Link :does(OpenTelemetry::Attributes) { - use experimental 'isa'; - use OpenTelemetry::X; + use isa 'OpenTelemetry::Trace::SpanContext'; + field $context :param :reader; ADJUST { die OpenTelemetry::X->create( Invalid => "Required parameter 'context' must be a span context" - ) unless $context isa OpenTelemetry::Trace::SpanContext; + ) unless isa_OpenTelemetry_Trace_SpanContext $context; } }