testing/php84-pecl-opentelemetry: upgrade to 1.1.0_beta3

This commit is contained in:
Andy Postnikov 2024-09-10 14:15:14 +00:00
parent bea4c45d0b
commit 1410035db5
3 changed files with 3 additions and 141 deletions

View file

@ -1,7 +1,7 @@
# Maintainer: Andy Postnikov <apostnikov@gmail.com>
pkgname=php84-pecl-opentelemetry
_extname=opentelemetry
pkgver=1.1.0_beta2
pkgver=1.1.0_beta3
_pkgver=${pkgver/_/}
pkgrel=0
pkgdesc="PHP 8.4 extension for OpenTelemetry auto-instrumentation support - PECL"
@ -12,10 +12,7 @@ _phpv=84
_php=php$_phpv
depends="$_php-common"
makedepends="$_php-dev"
source="php-pecl-$_extname-$pkgver.tgz::https://pecl.php.net/get/$_extname-$_pkgver.tgz
fix-tests.patch
fix-php84.patch
"
source="php-pecl-$_extname-$pkgver.tgz::https://pecl.php.net/get/$_extname-$_pkgver.tgz"
builddir="$srcdir/$_extname-$_pkgver"
build() {
@ -37,7 +34,5 @@ package() {
}
sha512sums="
638efa6f30c8da7a1b347c50e676dfe373ff92cd434364989ed0168421778272520d8cfddba694768ffafaae5a41f7a134e4d592f4cf46eafb0059c87368f218 php-pecl-opentelemetry-1.1.0_beta2.tgz
04a4099b5b07b2c96274217c5ab425dbb72c35b118c94f9d41f8fd76a4928c627beccc581aeaa88b03a3791068ef041dda106d8d98e853f2a01d7465a4a84d82 fix-tests.patch
794e2b7c5cdc11cb1d8bd68bd1565767243d96bd089ec039c10b1e524d7be5b8658efb7c9b3df5fbde3641b09f93b7eb630e5c6d8a29c6be3f511479f6283ddf fix-php84.patch
cd028d5a67b71ac855bd208486a5b26b754405d71e050452041e292846588e06e9e53cabe4cfe50bcefd6c8cae7c36c79ea38749cb590711a4d7398b36863874 php-pecl-opentelemetry-1.1.0_beta3.tgz
"

View file

@ -1,94 +0,0 @@
Patch-Source: https://github.com/open-telemetry/opentelemetry-php-instrumentation/pull/153
diff --git a/ext/otel_observer.c b/ext/otel_observer.c
index b3138d1..080db36 100644
--- ext/otel_observer.c
+++ ext/otel_observer.c
@@ -152,6 +152,23 @@ static bool func_has_withspan_attribute(zend_execute_data *ex) {
return attr != NULL;
}
+/*
+ * OpenTelemetry attribute values may only be of limited types
+ */
+static bool is_valid_attribute_value(zval *val) {
+ switch (Z_TYPE_P(val)) {
+ case IS_STRING:
+ case IS_LONG: // Numeric (integer)
+ case IS_DOUBLE: // Numeric (floating point)
+ case IS_TRUE:
+ case IS_FALSE: // Boolean
+ case IS_ARRAY:
+ return true;
+ default:
+ return false;
+ }
+}
+
// get function args. any args with the
// SpanAttributes attribute are added to the attributes HashTable
static void func_get_args(zval *zv, HashTable *attributes,
@@ -198,7 +215,7 @@ static void func_get_args(zval *zv, HashTable *attributes,
zend_string *arg_name = ex->func->op_array.vars[i];
zend_attribute *attribute =
find_spanattribute_attribute(ex->func, i);
- if (attribute != NULL) {
+ if (attribute != NULL && is_valid_attribute_value(p)) {
if (attribute->argc) {
zend_string *key = Z_STR(attribute->args[0].value);
zend_hash_del(attributes, key);
@@ -1149,5 +1166,8 @@ void opentelemetry_observer_init(INIT_FUNC_ARGS) {
zend_observer_fcall_register(observer_fcall_init);
op_array_extension =
zend_get_op_array_extension_handle("opentelemetry");
+#if PHP_VERSION_ID >= 80400
+ zend_get_internal_function_extension_handle("opentelemetry");
+#endif
}
}
diff --git a/ext/tests/span_attribute/function_params_non_simple.phpt b/ext/tests/span_attribute/function_params_non_simple.phpt
index f637ab1..fc53f51 100644
--- ext/tests/span_attribute/function_params_non_simple.phpt
+++ ext/tests/span_attribute/function_params_non_simple.phpt
@@ -1,5 +1,5 @@
--TEST--
-Check if function non-simple types can be passed as function params
+Check if function non-simple types are ignored
--SKIPIF--
<?php if (PHP_VERSION_ID < 80100) die('skip requires PHP >= 8.1'); ?>
--EXTENSIONS--
@@ -28,28 +28,20 @@ function foo(
}
foo(
- ['foo' => 'bar'],
- new \stdClass(),
- function(){return 'fn';},
- null,
+ one: ['foo' => 'bar'],
+ two: new \stdClass(),
+ three: function(){return 'fn';},
+ four: null,
);
?>
--EXPECTF--
string(3) "pre"
-array(4) {
+array(1) {
["one"]=>
array(1) {
["foo"]=>
string(3) "bar"
}
- ["two"]=>
- object(stdClass)#1 (0) {
- }
- ["three"]=>
- object(Closure)#2 (0) {
- }
- ["four"]=>
- NULL
}
string(3) "foo"
string(4) "post"
\ No newline at end of file

View file

@ -1,39 +0,0 @@
Patch-Source: https://github.com/open-telemetry/opentelemetry-php-instrumentation/commit/cb03803c8a34b179b753e352a0a7879476295e9a
From cb03803c8a34b179b753e352a0a7879476295e9a Mon Sep 17 00:00:00 2001
From: Andy Postnikov <apostnikov@gmail.com>
Date: Fri, 6 Sep 2024 03:26:23 +0200
Subject: [PATCH] fix 2 tests for PHP 8.4 (#152)
- https://php.watch/rfcs/deprecate-implicitly-nullable-types
- https://github.com/php/php-src/pull/13550
---
ext/tests/post_hook_returns_cloned_modified_object.phpt | 2 +-
ext/tests/span_attribute/function_params_non_simple.phpt | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/ext/tests/post_hook_returns_cloned_modified_object.phpt b/ext/tests/post_hook_returns_cloned_modified_object.phpt
index f5985af..9f20f28 100644
--- ext/tests/post_hook_returns_cloned_modified_object.phpt
+++ ext/tests/post_hook_returns_cloned_modified_object.phpt
@@ -10,7 +10,7 @@ opentelemetry
class Foo
{
public ?string $a = null;
- public function __construct(string $a = null)
+ public function __construct(string|null $a = null)
{
$this->a = $a;
}
diff --git a/ext/tests/span_attribute/function_params_non_simple.phpt b/ext/tests/span_attribute/function_params_non_simple.phpt
index 1c09ce0..f637ab1 100644
--- ext/tests/span_attribute/function_params_non_simple.phpt
+++ ext/tests/span_attribute/function_params_non_simple.phpt
@@ -34,7 +34,7 @@ foo(
null,
);
?>
---EXPECT--
+--EXPECTF--
string(3) "pre"
array(4) {
["one"]=>