27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/javonet-ruby-sdk/sdk/tools/sdk_message_helper.rb', line 27
def self.send_message_to_app_insights_func(operation_name, message)
begin
formatted_datetime = Time.now.utc.strftime("%Y-%m-%dT%H:%M:%S")
license_key = ActivationHelper.get_license_key
payload = {
"name": "AppEvents",
"time": formatted_datetime,
"iKey": INSTRUMENTATION_KEY,
"tags": {
"ai.application.ver": JAVONET_VERSION,
"ai.cloud.roleInstance": NODE_NAME,
"ai.operation.id": "0",
"ai.operation.parentId": "0",
"ai.operation.name": operation_name,
"ai.internal.sdkVersion": "javonet:2",
"ai.internal.nodeName": NODE_NAME
},
"data": {
"baseType": "EventData",
"baseData": {
"ver": 2,
"name": message,
"properties": {
"OperatingSystem": OS_NAME,
"LicenseKey": license_key,
"CallingTechnology": CALLING_RUNTIME_NAME
}
}
}
}
uri = URI(ADDRESS)
request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
request.body = payload.to_json
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(request)
end
response.code.to_i
rescue Exception => e
500
end
end
|