Skip to content

Commit 7d44eed

Browse files
authored
[k2] add few builtins stubs (#1456)
add stubs for * add kphp_backtrace * tracing builtins * kphp_turn_on_host_tag_in_inner_statshouse_metrics_toggle
1 parent db0398b commit 7d44eed

9 files changed

Lines changed: 96 additions & 55 deletions

File tree

builtin-functions/kphp-light/stdlib/error.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,5 @@ class Random\RandomException extends Exception {}
103103

104104
// === UNSUPPORTED ===
105105

106-
/** @kphp-extern-func-info stub generation-required */
106+
/** @kphp-extern-func-info stub */
107107
function kphp_backtrace($pretty ::: bool = true) ::: string[];

builtin-functions/kphp-light/stdlib/kphp-toggles.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function set_migration_php8_warning ($mask ::: int) ::: void;
66

77
// === UNSUPPORTED ===
88

9-
/** @kphp-extern-func-info stub generation-required */
9+
/** @kphp-extern-func-info stub */
1010
function kphp_turn_on_host_tag_in_inner_statshouse_metrics_toggle() ::: void;
1111

1212
function set_json_log_on_timeout_mode(bool $enabled) ::: void;

builtin-functions/kphp-light/stdlib/kphp-tracing.txt

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,74 +3,101 @@
33
// ===== UNSUPPORTED =====
44

55
final class KphpDiv {
6-
/** @kphp-extern-func-info stub generation-required */
6+
/** @kphp-extern-func-info stub */
77
private function __construct();
88

9+
/** @kphp-extern-func-info stub */
910
function generateTraceCtxForChild(int $div_id, int $trace_flags): tuple(int, int);
1011

12+
/** @kphp-extern-func-info stub */
1113
function assignTraceCtx(int $int1, int $int2, ?int $override_div_id): int;
1214

13-
/** @kphp-extern-func-info stub generation-required */
15+
/** @kphp-extern-func-info stub */
1416
function getStartTimestamp(): float;
1517

16-
/** @kphp-extern-func-info stub generation-required */
18+
/** @kphp-extern-func-info stub */
1719
function getEndTimestamp(): float;
1820
}
1921

2022
final class KphpSpan {
23+
/** @kphp-extern-func-info stub */
2124
private function __construct();
2225

26+
/** @kphp-extern-func-info stub */
2327
function addAttributeString(string $key, string $value) ::: void;
2428

29+
/** @kphp-extern-func-info stub */
2530
function addAttributeInt(string $key, int $value) ::: void;
26-
/** @kphp-extern-func-info stub generation-required */
31+
32+
/** @kphp-extern-func-info stub */
2733
function addAttributeFloat(string $key, float $value) ::: void;
28-
/** @kphp-extern-func-info stub generation-required */
34+
35+
/** @kphp-extern-func-info stub */
2936
function addAttributeBool(string $key, bool $value) ::: void;
30-
/** @kphp-extern-func-info stub generation-required */
37+
38+
/** @kphp-extern-func-info stub */
3139
function addAttributeEnum(string $key, int $enum_id, int $value) ::: void;
3240

41+
/** @kphp-extern-func-info stub */
3342
function addEvent(string $name, ?float $timestamp = null): KphpSpanEvent;
34-
/** @kphp-extern-func-info stub generation-required */
35-
function addLink(KphpSpan $another) ::: void;
3643

44+
/** @kphp-extern-func-info stub */
45+
function addLink(KphpSpan $another) ::: void;
3746

47+
/** @kphp-extern-func-info stub */
3848
function updateName(string $title, string $short_desc) ::: void;
3949

50+
/** @kphp-extern-func-info stub */
4051
function finish(?float $end_timestamp = null) ::: void;
4152

53+
/** @kphp-extern-func-info stub */
4254
function finishWithError(int $error_code, string $error_msg, ?float $end_timestamp = null) ::: void;
43-
/** @kphp-extern-func-info stub generation-required */
55+
56+
/** @kphp-extern-func-info stub */
4457
function exclude() ::: void;
4558
}
4659

4760
final class KphpSpanEvent {
61+
/** @kphp-extern-func-info stub */
4862
private function __construct();
4963

50-
/** @kphp-extern-func-info stub generation-required */
64+
/** @kphp-extern-func-info stub */
5165
function addAttributeString(string $key, string $value) ::: void;
52-
/** @kphp-extern-func-info stub generation-required */
66+
67+
/** @kphp-extern-func-info stub */
5368
function addAttributeInt(string $key, int $value) ::: void;
54-
/** @kphp-extern-func-info stub generation-required */
69+
70+
/** @kphp-extern-func-info stub */
5571
function addAttributeFloat(string $key, float $value) ::: void;
56-
/** @kphp-extern-func-info stub generation-required */
72+
73+
/** @kphp-extern-func-info stub */
5774
function addAttributeBool(string $key, bool $value) ::: void;
5875
}
5976

77+
/** @kphp-extern-func-info stub */
6078
function kphp_tracing_init(string $root_span_title): KphpDiv;
6179

80+
/** @kphp-extern-func-info stub */
6281
function kphp_tracing_set_level(int $trace_level): void;
6382

83+
/** @kphp-extern-func-info stub */
6484
function kphp_tracing_get_level(): int;
6585

86+
/** @kphp-extern-func-info stub */
6687
function kphp_tracing_register_on_finish(callable(float $now_timestamp):bool $cb_should_be_flushed);
88+
/** @kphp-extern-func-info stub */
6789
function kphp_tracing_register_enums_provider(callable():tuple(int, string, string[])[] $cb_custom_enums);
90+
/** @kphp-extern-func-info stub */
6891
function kphp_tracing_register_rpc_details_provider(callable(@tl\RpcFunction):string $cb_for_typed, callable(mixed):string $cb_for_untyped);
6992

93+
/** @kphp-extern-func-info stub */
7094
function kphp_tracing_start_span(string $title, string $short_desc, float $start_timestamp): KphpSpan;
7195

96+
/** @kphp-extern-func-info stub */
7297
function kphp_tracing_get_root_span(): KphpSpan;
7398

99+
/** @kphp-extern-func-info stub */
74100
function kphp_tracing_get_current_active_span(): KphpSpan;
75101

102+
/** @kphp-extern-func-info stub */
76103
function kphp_tracing_func_enter_branch(int $branch_num) ::: void;

runtime-light/stdlib/diagnostics/error-handling-functions.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ inline array<array<string>> f$debug_backtrace() noexcept {
9292
return {};
9393
}
9494

95+
inline array<string> f$kphp_backtrace([[maybe_unused]] bool pretty = true) noexcept {
96+
return {};
97+
}
98+
9599
inline int64_t f$error_reporting(Optional<int64_t> new_error_level_opt = {}) noexcept {
96100
auto& error_handling_st{ErrorHandlingState::get()};
97101
const int64_t current_error_level{error_handling_st.minimum_log_level};

runtime-light/stdlib/system/system-functions.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,3 +245,5 @@ inline string f$get_kphp_cluster_name() noexcept {
245245
kphp::log::warning("called stub get_kphp_cluster_name");
246246
return string{"adm512"};
247247
}
248+
249+
inline void f$kphp_turn_on_host_tag_in_inner_statshouse_metrics_toggle() noexcept {}

runtime-light/stdlib/tracing/tracing-div.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,25 @@
1111

1212
struct C$KphpDiv : public refcountable_php_classes<C$KphpDiv>, private DummyVisitorMethods {
1313
using DummyVisitorMethods::accept;
14+
15+
C$KphpDiv() noexcept = default;
1416
};
1517

1618
inline int64_t f$KphpDiv$$assignTraceCtx([[maybe_unused]] const class_instance<C$KphpDiv>& v$this, [[maybe_unused]] int64_t int1, [[maybe_unused]] int64_t int2,
1719
[[maybe_unused]] const Optional<int64_t>& override_div_id) {
18-
kphp::log::info("called stub KphpDiv::assignTraceCtx");
20+
1921
return {};
2022
}
2123

2224
inline std::tuple<int64_t, int64_t> f$KphpDiv$$generateTraceCtxForChild([[maybe_unused]] const class_instance<C$KphpDiv>& v$this,
2325
[[maybe_unused]] int64_t div_id, [[maybe_unused]] int64_t trace_flags) {
24-
kphp::log::info("called stub KphpDiv::generateTraceCtxForChild");
26+
return {};
27+
}
28+
29+
inline double f$KphpDiv$$getStartTimestamp([[maybe_unused]] const class_instance<C$KphpDiv>& v$this) noexcept {
30+
return {};
31+
}
32+
33+
inline double f$KphpDiv$$getEndTimestamp([[maybe_unused]] const class_instance<C$KphpDiv>& v$this) noexcept {
2534
return {};
2635
}

runtime-light/stdlib/tracing/tracing-event.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,14 @@ struct C$KphpSpanEvent : public refcountable_php_classes<C$KphpSpanEvent> {
1515
explicit C$KphpSpanEvent(int32_t span_id) noexcept
1616
: span_id(span_id) {}
1717
};
18+
19+
inline void f$KphpSpanEvent$$addAttributeString([[maybe_unused]] const string& value) noexcept {}
20+
21+
inline void f$KphpSpanEvent$$addAttributeInt([[maybe_unused]] const class_instance<C$KphpSpanEvent>& v$this, [[maybe_unused]] const string& key,
22+
[[maybe_unused]] int64_t value) noexcept {}
23+
24+
inline void f$KphpSpanEvent$$addAttributeFloat([[maybe_unused]] const class_instance<C$KphpSpanEvent>& v$this, [[maybe_unused]] const string& key,
25+
[[maybe_unused]] double value) noexcept {}
26+
27+
inline void f$KphpSpanEvent$$addAttributeBool([[maybe_unused]] const class_instance<C$KphpSpanEvent>& v$this, [[maybe_unused]] const string& key,
28+
[[maybe_unused]] bool value) noexcept {}

runtime-light/stdlib/tracing/tracing-functions.h

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,50 +10,35 @@
1010
#include "runtime-light/stdlib/tracing/tracing-span.h"
1111

1212
inline class_instance<C$KphpSpan> f$kphp_tracing_get_current_active_span() noexcept {
13-
kphp::log::info("called stub kphp_tracing_get_current_active_span");
1413
return {};
1514
}
1615

17-
inline void f$kphp_tracing_func_enter_branch(int /*$branch_num*/) noexcept {
18-
kphp::log::info("called stub kphp_tracing_func_enter_branch");
19-
}
16+
inline void f$kphp_tracing_func_enter_branch(int64_t /*$branch_num*/) noexcept {}
2017

2118
inline class_instance<C$KphpSpan> f$kphp_tracing_get_root_span() noexcept {
22-
kphp::log::info("called stub kphp_tracing_get_root_span");
2319
return {};
2420
}
2521

2622
inline class_instance<C$KphpDiv> f$kphp_tracing_init([[maybe_unused]] const string& root_span_title) noexcept {
27-
kphp::log::info("called stub kphp_tracing_init");
2823
return {};
2924
}
3025

3126
inline int64_t f$kphp_tracing_get_level() {
32-
kphp::log::info("called stub kphp_tracing_get_level");
3327
return -1; // Not initialized
3428
}
3529

3630
inline class_instance<C$KphpSpan> f$kphp_tracing_start_span([[maybe_unused]] const string& title, [[maybe_unused]] const string& short_desc,
3731
[[maybe_unused]] double start_timestamp) noexcept {
38-
kphp::log::info("called stub kphp_tracing_start_span");
3932
return {};
4033
}
4134

4235
template<typename F>
43-
void f$kphp_tracing_register_enums_provider([[maybe_unused]] F&& cb_custom_enums) noexcept {
44-
kphp::log::info("called stub kphp_tracing_register_enums_provider");
45-
}
36+
void f$kphp_tracing_register_enums_provider([[maybe_unused]] F&& cb_custom_enums) noexcept {}
4637

4738
template<typename F>
48-
void f$kphp_tracing_register_on_finish([[maybe_unused]] F&& cb_should_be_flushed) noexcept {
49-
kphp::log::info("called stub kphp_tracing_register_on_finish");
50-
}
39+
void f$kphp_tracing_register_on_finish([[maybe_unused]] F&& cb_should_be_flushed) noexcept {}
5140

5241
template<typename F1, typename F2>
53-
void f$kphp_tracing_register_rpc_details_provider([[maybe_unused]] F1&& cb_for_typed, [[maybe_unused]] F2&& cb_for_untyped) noexcept {
54-
kphp::log::info("called stub kphp_tracing_register_rpc_details_provider");
55-
}
42+
void f$kphp_tracing_register_rpc_details_provider([[maybe_unused]] F1&& cb_for_typed, [[maybe_unused]] F2&& cb_for_untyped) noexcept {}
5643

57-
inline void f$kphp_tracing_set_level([[maybe_unused]] int64_t trace_level) noexcept {
58-
kphp::log::info("called stub kphp_tracing_set_level");
59-
}
44+
inline void f$kphp_tracing_set_level([[maybe_unused]] int64_t trace_level) noexcept {}

runtime-light/stdlib/tracing/tracing-span.h

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,33 +20,36 @@ struct C$KphpSpan : public refcountable_php_classes<C$KphpSpan>, private DummyVi
2020
: span_id(span_id) {}
2121
};
2222

23+
inline void f$KphpSpan$$addAttributeString([[maybe_unused]] const class_instance<C$KphpSpan>& v$this, [[maybe_unused]] const string& key,
24+
[[maybe_unused]] const string& value) noexcept {}
25+
2326
inline void f$KphpSpan$$addAttributeInt([[maybe_unused]] const class_instance<C$KphpSpan>& v$this, [[maybe_unused]] const string& key,
24-
[[maybe_unused]] int64_t value) noexcept {
25-
kphp::log::info("called stub KphpSpan::addAttributeInt");
26-
}
27+
[[maybe_unused]] int64_t value) noexcept {}
2728

28-
inline void f$KphpSpan$$addAttributeString([[maybe_unused]] const class_instance<C$KphpSpan>& v$this, [[maybe_unused]] const string& key,
29-
[[maybe_unused]] const string& value) noexcept {
30-
kphp::log::info("called stub KphpSpan::addAttributeString");
31-
}
29+
inline void f$KphpSpan$$addAttributeFloat([[maybe_unused]] const class_instance<C$KphpSpan>& v$this, [[maybe_unused]] const string& key,
30+
[[maybe_unused]] double value) noexcept {}
31+
32+
inline void f$KphpSpan$$addAttributeBool([[maybe_unused]] const class_instance<C$KphpSpan>& v$this, [[maybe_unused]] const string& key,
33+
[[maybe_unused]] bool value) noexcept {}
34+
35+
inline void f$KphpSpan$$addAttributeEnum([[maybe_unused]] const class_instance<C$KphpSpan>& v$this, [[maybe_unused]] const string& key,
36+
[[maybe_unused]] int64_t enum_id, [[maybe_unused]] int64_t value) noexcept {}
3237

3338
inline class_instance<C$KphpSpanEvent> f$KphpSpan$$addEvent([[maybe_unused]] const class_instance<C$KphpSpan>& v$this, [[maybe_unused]] const string& name,
3439
[[maybe_unused]] const Optional<double>& manual_timestamp = {}) noexcept {
35-
kphp::log::info("called stub KphpSpan::addEvent");
3640
return {};
3741
}
3842

39-
inline void f$KphpSpan$$finish([[maybe_unused]] const class_instance<C$KphpSpan>& v$this,
40-
[[maybe_unused]] const Optional<double>& manual_timestamp = {}) noexcept {
41-
kphp::log::info("called stub KphpSpan::finish");
42-
}
43+
inline void f$KphpSpan$$addLink([[maybe_unused]] const class_instance<C$KphpSpan>& v$this,
44+
[[maybe_unused]] const class_instance<C$KphpSpan>& another) noexcept {}
4345

4446
inline void f$KphpSpan$$updateName([[maybe_unused]] const class_instance<C$KphpSpan>& v$this, [[maybe_unused]] const string& title,
45-
[[maybe_unused]] const string& short_desc) noexcept {
46-
kphp::log::info("called stub KphpSpan::updateName");
47-
}
47+
[[maybe_unused]] const string& short_desc) noexcept {}
48+
49+
inline void f$KphpSpan$$finish([[maybe_unused]] const class_instance<C$KphpSpan>& v$this,
50+
[[maybe_unused]] const Optional<double>& manual_timestamp = {}) noexcept {}
4851

4952
inline void f$KphpSpan$$finishWithError([[maybe_unused]] const class_instance<C$KphpSpan>& v$this, [[maybe_unused]] int64_t error_code,
50-
[[maybe_unused]] const string& error_msg, [[maybe_unused]] const Optional<float>& manual_timestamp = {}) {
51-
kphp::log::info("called stub KphpSpan::finishWithError");
52-
}
53+
[[maybe_unused]] const string& error_msg, [[maybe_unused]] const Optional<float>& manual_timestamp = {}) {}
54+
55+
inline void f$KphpSpan$$exclude([[maybe_unused]] const class_instance<C$KphpSpan>& v$this) noexcept {}

0 commit comments

Comments
 (0)