Skip to content

Commit 4820fea

Browse files
committed
Create stub
1 parent 1f4dab6 commit 4820fea

File tree

3 files changed

+93
-26
lines changed

3 files changed

+93
-26
lines changed

ext/integrations/exec_integration.c

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
#include <ext/standard/file.h>
88
#include <ext/standard/proc_open.h>
99

10-
#include "compatibility.h"
11-
#include "ddtrace.h"
12-
#include "span.h"
10+
#include "../compatibility.h"
11+
#include "../ddtrace.h"
12+
#include "../span.h"
13+
#include "exec_integration_arginfo.h"
1314

1415
#define NS "DDTrace\\Integrations\\Exec\\"
1516

@@ -262,33 +263,16 @@ static PHP_FUNCTION(DDTrace_integrations_exec_test_rshutdown) {
262263

263264
ddtrace_exec_handlers_rshutdown();
264265
dd_exec_init_track_streams();
265-
(void)return_value;
266+
RETURN_TRUE;
266267
}
267268

268269
// clang-format off
269-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(register_stream, 0, 2, _IS_BOOL, 0)
270-
ZEND_ARG_TYPE_INFO(0, stream, IS_RESOURCE, 0)
271-
ZEND_ARG_OBJ_INFO(0, span, DDTrace\\SpanData, 0)
272-
ZEND_END_ARG_INFO()
273-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(proc_assoc_span, 0, 2, _IS_BOOL, 1)
274-
ZEND_ARG_TYPE_INFO(0, proc_res, IS_RESOURCE, 0)
275-
ZEND_ARG_OBJ_INFO(0, span, DDTrace\\SpanData, 0)
276-
ZEND_END_ARG_INFO()
277-
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(proc_get_span, 0, 1, DDTrace\\SpanData, 0)
278-
ZEND_ARG_TYPE_INFO(0, proc_res, IS_RESOURCE, 0)
279-
ZEND_END_ARG_INFO()
280-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(proc_get_pid, 0, 1, IS_LONG, 1)
281-
ZEND_ARG_TYPE_INFO(0, proc_res, IS_RESOURCE, 0)
282-
ZEND_END_ARG_INFO()
283-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(test_rshutdown, 0, 0, IS_NULL, 1)
284-
ZEND_END_ARG_INFO()
285-
286270
static const zend_function_entry functions[] = {
287-
ZEND_RAW_FENTRY(NS "register_stream", PHP_FN(DDTrace_integrations_exec_register_stream), register_stream, 0)
288-
ZEND_RAW_FENTRY(NS "proc_assoc_span", PHP_FN(DDTrace_integrations_exec_proc_assoc_span), proc_assoc_span, 0)
289-
ZEND_RAW_FENTRY(NS "proc_get_span", PHP_FN(DDTrace_integrations_exec_proc_get_span), proc_get_span, 0)
290-
ZEND_RAW_FENTRY(NS "proc_get_pid", PHP_FN(DDTrace_integrations_exec_proc_get_pid), proc_get_pid, 0)
291-
ZEND_RAW_FENTRY(NS "test_rshutdown", PHP_FN(DDTrace_integrations_exec_test_rshutdown), test_rshutdown, 0)
271+
ZEND_RAW_FENTRY(NS "register_stream", PHP_FN(DDTrace_integrations_exec_register_stream), arginfo_DDTrace_Integrations_Exec_register_stream, 0)
272+
ZEND_RAW_FENTRY(NS "proc_assoc_span", PHP_FN(DDTrace_integrations_exec_proc_assoc_span), arginfo_DDTrace_Integrations_Exec_proc_assoc_span, 0)
273+
ZEND_RAW_FENTRY(NS "proc_get_span", PHP_FN(DDTrace_integrations_exec_proc_get_span), arginfo_DDTrace_Integrations_Exec_proc_get_span, 0)
274+
ZEND_RAW_FENTRY(NS "proc_get_pid", PHP_FN(DDTrace_integrations_exec_proc_get_pid), arginfo_DDTrace_Integrations_Exec_proc_get_pid, 0)
275+
ZEND_RAW_FENTRY(NS "test_rshutdown", PHP_FN(DDTrace_integrations_exec_test_rshutdown), arginfo_DDTrace_Integrations_Exec_test_rshutdown, 0)
292276
PHP_FE_END
293277
};
294278
// clang-format on
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
3+
namespace DDTrace\Integrations\Exec {
4+
5+
/**
6+
* Associates a popen() stream resource with a span so that when the resource is destroyed, the span is updated
7+
* with the exit code and closed.
8+
*
9+
* It is not validated that the stream is actually a popen() stream resource.
10+
*
11+
* Only one span can be associated with a stream resource. A subsequent call replaces the first span.
12+
*
13+
* @internal for use by the exec integration only
14+
* @param resource $stream A stream resource
15+
* @param \DDTrace\SpanData $span The command_execution span to associate
16+
* @return bool true on success or false if the resource is not a stream
17+
*/
18+
function register_stream($stream, \DDTrace\SpanData $span): bool {}
19+
20+
/**
21+
* Associates a proc_open() process handle with a span so that when the handle is closed, there is a waitpid()
22+
* call on the child, and the span is updated with the exit code and closed.
23+
*
24+
* Only one call to this function can be made per process handle. A subsequent call has undefined behavior.
25+
*
26+
* @internal for use by the exec integration only
27+
* @param resource $proc_h A process handle
28+
* @param \DDTrace\SpanData $span The command_execution span to associate
29+
* @return bool true on success or false if the resource is not a process handle
30+
*/
31+
function proc_assoc_span($proc_h, \DDTrace\SpanData $span) : bool {}
32+
33+
/**
34+
* Retrieves a span previously associated with a process handle by proc_assoc_span(), or
35+
* null if there's none.
36+
*
37+
* @internal for use by the exec integration only
38+
* @param resource $proc_h A process handle
39+
* @return \DDTrace\SpanData|null The associated span, if any.
40+
*/
41+
function proc_get_span($proc_h) : ?\DDTrace\SpanData {}
42+
43+
/**
44+
* Retrieves the pid associated with a process handle.
45+
*
46+
* @internal for use by the testes of the exec integration only
47+
* @param resource $proc_h A process handle
48+
* @return int|null The associated span, if any.
49+
*/
50+
function proc_get_pid($proc_h) : ?int {}
51+
52+
/**
53+
* Closes the spans associated with live resources opened by popen() and proc_open()
54+
*
55+
* @internal for use by the testes of the exec integration only
56+
* @return bool
57+
*/
58+
function test_rshutdown() : bool {}
59+
}
60+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* This is a generated file, edit the .stub.php file instead.
2+
* Stub hash: 97cc0e5375b6d1d07fa0db5a4dba3e102709674f */
3+
4+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_DDTrace_Integrations_Exec_register_stream, 0, 2, _IS_BOOL, 0)
5+
ZEND_ARG_INFO(0, stream)
6+
ZEND_ARG_OBJ_INFO(0, span, DDTrace\\SpanData, 0)
7+
ZEND_END_ARG_INFO()
8+
9+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_DDTrace_Integrations_Exec_proc_assoc_span, 0, 2, _IS_BOOL, 0)
10+
ZEND_ARG_INFO(0, proc_h)
11+
ZEND_ARG_OBJ_INFO(0, span, DDTrace\\SpanData, 0)
12+
ZEND_END_ARG_INFO()
13+
14+
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_DDTrace_Integrations_Exec_proc_get_span, 0, 1, DDTrace\\SpanData, 1)
15+
ZEND_ARG_INFO(0, proc_h)
16+
ZEND_END_ARG_INFO()
17+
18+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_DDTrace_Integrations_Exec_proc_get_pid, 0, 1, IS_LONG, 1)
19+
ZEND_ARG_INFO(0, proc_h)
20+
ZEND_END_ARG_INFO()
21+
22+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_DDTrace_Integrations_Exec_test_rshutdown, 0, 0, _IS_BOOL, 0)
23+
ZEND_END_ARG_INFO()

0 commit comments

Comments
 (0)