diff --git a/skywalking.c b/skywalking.c index f9fc49aca57c1eeb9441fcbad3023d2925de6593..eed17bbf897213d2c5defa6e079668a8b934f795 100644 --- a/skywalking.c +++ b/skywalking.c @@ -68,6 +68,7 @@ static int application_instance = 0; static int application_id = 0; static int sky_close = 0; static int sky_increment_id = 0; +char *uuid = NULL; /* {{{ PHP_INI */ @@ -706,6 +707,7 @@ static void request_init() { add_assoc_long(&SKYWALKING_G(UpstreamSegment), "pid", getppid()); add_assoc_long(&SKYWALKING_G(UpstreamSegment), "application_id", application_id); add_assoc_long(&SKYWALKING_G(UpstreamSegment), "version", SKYWALKING_G(version)); + add_assoc_string(&SKYWALKING_G(UpstreamSegment), "uuid", uuid); SKY_ADD_ASSOC_ZVAL(&SKYWALKING_G(UpstreamSegment), "segment"); SKY_ADD_ASSOC_ZVAL(&SKYWALKING_G(UpstreamSegment), "globalTraceIds"); diff --git a/src/greeter_client.cc b/src/greeter_client.cc index 1343df5b749df9cc283c37d6435d91415c883959..332c774a27b3d1171607048e583ce511603a7a01 100644 --- a/src/greeter_client.cc +++ b/src/greeter_client.cc @@ -45,8 +45,8 @@ extern "C" void networkAddressRegister(); extern "C" void endpointRegister(); - -static boost::uuids::uuid uuid = boost::uuids::random_generator()(); +extern char *uuid; +static boost::uuids::uuid boost_uuid = boost::uuids::random_generator()(); class GreeterClient { public: @@ -84,9 +84,15 @@ public: ServiceInstances request; ServiceInstance *s = request.add_instances(); + if (uuid == NULL) { + std::string uuid_str = boost::uuids::to_string(boost_uuid); + uuid = (char *) malloc(uuid_str.size() + 1); + bzero(uuid, uuid_str.size() + 1); + strncpy(uuid, uuid_str.c_str(), uuid_str.size() + 1); + } s->set_serviceid(applicationid); - s->set_instanceuuid(boost::uuids::to_string(uuid)); + s->set_instanceuuid(std::string(uuid)); s->set_time(registertime); KeyStringValuePair *os = s->add_properties(); @@ -120,8 +126,8 @@ public: std::cout << "Register Instance:"<< std::endl; std::cout << kv.key() << ": " << kv.value() << std::endl; - if (kv.key() == boost::uuids::to_string(uuid)) { - std::cout << "uuid" << ": " << boost::uuids::to_string(uuid) << std::endl; + if (kv.key() == uuid) { + std::cout << "uuid" << ": " << uuid << std::endl; return kv.value(); } }