in lib/skywalking/client.lua [89:123]
function Client:reportServiceInstance(metadata_buffer, backend_http_uri)
local log = ngx.log
local DEBUG = ngx.DEBUG
local ERR = ngx.ERR
local serviceName = metadata_buffer:get('serviceName')
local serviceInstanceName = metadata_buffer:get('serviceInstanceName')
local cjson = require('cjson')
local reportInstance = require("skywalking.management").newReportInstanceProperties(serviceName, serviceInstanceName)
local reportInstanceParam, err = cjson.encode(reportInstance)
if err then
log(ERR, "Request to report instance fails, ", err)
return
end
local http = require('resty.http')
local httpc = http.new()
local res, err = httpc:request_uri(backend_http_uri .. '/v3/management/reportProperties', {
method = "POST",
body = reportInstanceParam,
headers = {
["Content-Type"] = "application/json",
},
})
if not res then
log(ERR, "Instance report fails, ", err)
elseif res.status == 200 then
log(DEBUG, "Instance report response = ", res.body)
metadata_buffer:set('instancePropertiesSubmitted', true)
else
log(ERR, "Instance report fails, response code ", res.status)
end
end