Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit c170039

Browse files
committed
with header
1 parent c4b4224 commit c170039

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

php_skywalking.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ extern zend_module_entry skywalking_module_entry;
4848
#define PHP_SKYWALKING_VERSION "4.0.0"
4949

5050

51-
#define SKY_STRCMP(s1, s2) s1 != nullptr && strcmp(s1, s2) == 0
51+
#define SKY_STRCMP(s1, s2) ((s1) != nullptr && strcmp(s1, s2) == 0)
5252

5353
#define SKY_IS_SWOOLE(func_name) (SKY_STRCMP(func_name, "{closure}"))
5454
#define SKY_IS_HYPERF(class_name, func_name) (SKY_STRCMP(class_name, "Hyperf\\HttpServer\\Server") && SKY_STRCMP(func_name, "onRequest"))

src/cross_process_bag.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ std::string CrossProcessBag::encode(int spanId, const std::string &peer) {
7272
tmp.emplace_back(Base64::encode(currentOperationName));
7373
tmp.emplace_back(Base64::encode(peer));
7474

75-
std::string header = "sw8: ";
75+
std::string header;
7676

7777
for (const auto &val:tmp) {
7878
header.append(val);

src/sky_curl.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ void sky_curl_exec_handler(INTERNAL_FUNCTION_PARAMETERS) {
155155
span->addTag("url", url_str);
156156

157157
std::string sw_header = segment->createHeader(span);
158-
add_next_index_string(option, sw_header.c_str());
158+
add_next_index_string(option, ("sw8: " + sw_header).c_str());
159159
}
160160

161161
zval argv[3];

src/sky_plugin_hyperf_guzzle.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ Span *sky_plugin_hyperf_guzzle(zend_execute_data *execute_data, const std::strin
5050
span->setPeer(std::string(Z_STRVAL(host)) + ":" + std::to_string(_port));
5151
span->setOperationName(Z_TYPE(path) == IS_NULL ? "/" : std::string(Z_STRVAL(path)));
5252
span->addTag("url", std::string(Z_STRVAL(to_string)));
53+
54+
// with header
55+
std::string header = segment->createHeader(span);
56+
zval name, value;
57+
ZVAL_STRING(&name, "sw8");
58+
ZVAL_STRING(&value, header.c_str());
59+
zend_call_method(request, Z_OBJCE_P(request), nullptr, ZEND_STRL("withheader"), nullptr, 2, &name, &value);
60+
zval_dtor(&name);
61+
zval_dtor(&value);
62+
5363
return span;
5464
}
5565
}

0 commit comments

Comments
 (0)