Skip to content

Commit

Permalink
Fixed inferred spans (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
intuibase authored Feb 12, 2025
1 parent 8d6fcc3 commit dc7864f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
10 changes: 5 additions & 5 deletions prod/native/extension/code/ModuleFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,13 @@ PHP_FUNCTION(enqueue) {
EAPM_GL(httpTransportAsync_)->enqueue(ZSTR_HASH(endpoint), std::span<std::byte>(reinterpret_cast<std::byte *>(ZSTR_VAL(payload)), ZSTR_LEN(payload)));
}

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(elastic_otel_force_set_object_propety_value_arginfo, 0, 3, _IS_BOOL, 0)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(elastic_otel_force_set_object_property_value_arginfo, 0, 3, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, object, IS_OBJECT, 0)
ZEND_ARG_TYPE_INFO(0, property_name, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0)
ZEND_END_ARG_INFO()

PHP_FUNCTION(force_set_object_propety_value) {
PHP_FUNCTION(force_set_object_property_value) {
zend_object *object = nullptr;
zend_string *property_name = nullptr;
zval *value = nullptr;
Expand All @@ -307,9 +307,9 @@ const zend_function_entry elastic_otel_functions[] = {
PHP_FE( elastic_otel_get_last_php_error, elastic_otel_get_last_php_error_arginfo )
PHP_FE( elastic_otel_hook, elastic_otel_hook_arginfo )

ZEND_NS_FE( "Elastic\\Otel\\HttpTransport", initialize, ArgInfoInitialize)
ZEND_NS_FE( "Elastic\\Otel\\HttpTransport", enqueue, elastic_otel_no_paramters_arginfo)
ZEND_NS_FE( "Elastic\\Otel\\InferredSpans", force_set_object_propety_value, elastic_otel_force_set_object_propety_value_arginfo)
ZEND_NS_FE( "Elastic\\OTel\\HttpTransport", initialize, ArgInfoInitialize)
ZEND_NS_FE( "Elastic\\OTel\\HttpTransport", enqueue, elastic_otel_no_paramters_arginfo)
ZEND_NS_FE( "Elastic\\OTel\\InferredSpans", force_set_object_property_value, elastic_otel_force_set_object_property_value_arginfo)

PHP_FE_END
};
Expand Down
4 changes: 1 addition & 3 deletions prod/php/ElasticOTel/InferredSpans/InferredSpans.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ public function captureStackTrace(int $durationMs, bool $topFrameIsInternalFunct

array_splice($stackTrace, 0, InferredSpans::FRAMES_TO_SKIP); // skip PhpFacade/Inferred spans logic frames
$apmFramesFilteredOutCount = $this->filterOutAPMFrames($stackTrace);
$apmFramesFilteredOutCount = null;

$this->compareStackTraces($stackTrace, $durationMs, $topFrameIsInternalFunction, $apmFramesFilteredOutCount);
} catch (\Throwable $throwable) {
Expand Down Expand Up @@ -229,7 +228,6 @@ private function getHowManyStackFramesAreIdenticalFromStackBottom(array $stackTr

$count = min($stackTraceCount, $lastStackTraceCount);

$index = 0;
for ($index = 1; $index <= $count; $index++) {
$stFrame = &$stackTrace[$stackTraceCount - $index];
$lastStFrame = &$this->lastStackTrace[$lastStackTraceCount - $index];
Expand Down Expand Up @@ -279,7 +277,7 @@ private function shouldReduceFrame(int $index, int $oldFramesCount, int &$previo
/** @noinspection PhpFullyQualifiedNameUsageInspection, PhpUndefinedFunctionInspection
* @phpstan-ignore function.notFound
*/
$forceParentChangeFailed = !force_set_object_propety_value($span, "parentSpanContext", $lastSpanParent);
$forceParentChangeFailed = !force_set_object_property_value($span, "parentSpanContext", $lastSpanParent);
}
}

Expand Down

0 comments on commit dc7864f

Please sign in to comment.