From d0927d4fa222d41baae6d82ac2f27e8b736e6c90 Mon Sep 17 00:00:00 2001 From: heyanlong Date: Thu, 6 Dec 2018 12:14:32 +0800 Subject: [PATCH] report --- sky-php7ext/skywalking.c | 9 ++++++++- sky-php7ext/src/report/report_client.cpp | 10 +++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/sky-php7ext/skywalking.c b/sky-php7ext/skywalking.c index e23e3b5..026c2ed 100644 --- a/sky-php7ext/skywalking.c +++ b/sky-php7ext/skywalking.c @@ -455,7 +455,7 @@ static void request_init() { efree(l_millisecond); add_assoc_long(&temp, "startTime", millisecond); add_assoc_string(&temp, "operationName", get_page_request_uri()); -// add_assoc_string(&sky_entry_span, "peer", "127.0.0.1"); + add_assoc_string(&temp, "peer", ""); add_assoc_long(&temp, "spanType", 0); add_assoc_long(&temp, "spanLayer", 3); add_assoc_long(&temp, "componentId", COMPONENT_HTTPCLIENT); @@ -517,6 +517,10 @@ static void module_init() { do { application_id = applicationCodeRegister(SKYWALKING_G(grpc), SKYWALKING_G(app_code)); + if(application_id == -100000) { + sleep(1); + } + i++; } while (application_id == -100000 && i <= 3); @@ -546,6 +550,9 @@ static void module_init() { application_instance = registerInstance(SKYWALKING_G(grpc), application_id, millisecond, uuid, SKY_OS_NAME, hostname, getpid(), ipv4s); + if(application_instance == -100000) { + sleep(1); + } i++; } while (application_instance == -100000 && i <= 3); diff --git a/sky-php7ext/src/report/report_client.cpp b/sky-php7ext/src/report/report_client.cpp index 3e63502..c7cb54e 100644 --- a/sky-php7ext/src/report/report_client.cpp +++ b/sky-php7ext/src/report/report_client.cpp @@ -185,11 +185,15 @@ int main(int argc, char **argv) { for (int i = 0; i < spans.size(); i++) { SpanObject *spanObject = traceSegmentObject.add_spans(); - spanObject->set_spanid(spans[i]["spanId"]); - spanObject->set_parentspanid(spans[i]["parentSpanId"]); + spanObject->set_spanid(spans[i]["spanId"].get()); + spanObject->set_parentspanid(spans[i]["parentSpanId"].get()); spanObject->set_starttime(spans[i]["startTime"]); spanObject->set_endtime(spans[i]["endTime"]); spanObject->set_operationname(spans[i]["operationName"]); + std::string peer(spans[i]["peer"].get()); + if(!peer.empty()) { + spanObject->set_peer(peer); + } int spanType = spans[i]["spanType"].get(); if (spanType == 0) { @@ -205,7 +209,7 @@ int main(int argc, char **argv) { spanObject->set_spanlayer(SpanLayer::Http); } - spanObject->set_componentid(spans[i]["componentId"]); + spanObject->set_componentid(spans[i]["componentId"].get()); spanObject->set_iserror(spans[i]["isError"].get()); } -- GitLab