azure-loganalytics-datacollector-api 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ChangeLog.md +6 -0
- data/README.md +16 -0
- data/lib/azure/loganalytics/datacollectorapi/client.rb +26 -2
- data/lib/azure/loganalytics/datacollectorapi/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0499f95d897bc46dae9b39636ac2dda0c9aa5750b70bc2703c0d3dc41bfa34f1'
|
4
|
+
data.tar.gz: 057401456546b8ac6b23e75bbc0e6c61a8a4c9ddb534f54508018011d3268d85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed73c860640a73f1d0d0176e482361ebb30a082634410c44b7d540fc444b56e1a6548d1f81b43f10f5aef9967e1e8d17b63379c377250ed00b050157c29d4f79
|
7
|
+
data.tar.gz: 5bcb8d45153164a92ddeeaae37544d7722806c8726e2653d2f3fefa07e65f93f854e26e4e657cb9fef1d1d1c26d68d69daa963266b28cb62bfcaef1cbde42b29
|
data/ChangeLog.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## 0.4.0
|
2
|
+
* restclient retries request on the following status code - [issue #10](https://github.com/yokawasa/azure-log-analytics-data-collector/issues/10)
|
3
|
+
* 429 - Too Many Requests
|
4
|
+
* 500 - Internal Server Error
|
5
|
+
* 503 - Service Unavailable
|
6
|
+
|
1
7
|
## 0.3.0
|
2
8
|
* Enhance log type validation: check not only alpha but also numeric, underscore, and character length (may not exceed 100) - [issue #11](https://github.com/yokawasa/azure-log-analytics-data-collector/issues/11)
|
3
9
|
|
data/README.md
CHANGED
@@ -3,6 +3,22 @@
|
|
3
3
|
[Azure Log Analytics Data Collector API](https://docs.microsoft.com/en-us/azure/azure-monitor/platform/data-collector-api) Client Libraries for Ruby. The repository was originally created for multiple programming languages, but it was refactored as a dedicated one for Ruby client. Python and PHP client libraries were moved to [azure-log-analytics-data-colloector-python](https://github.com/yokawasa/azure-log-analytics-data-collector-python) and [azure-log-analytics-data-colloector-php](https://github.com/yokawasa/azure-log-analytics-data-collector-php) respectively.
|
4
4
|
|
5
5
|
|
6
|
+
## Retry policy
|
7
|
+
|
8
|
+
The client internal leverage [rest-client] to send HTTP request to the API. The client library retries request using the rest-client on the following status code (which is [recommended action](https://docs.microsoft.com/en-us/azure/azure-monitor/platform/data-collector-api)).
|
9
|
+
* `429` - Too Many Requests
|
10
|
+
* `500` - Internal Server Error
|
11
|
+
* `503` - Service Unavailable
|
12
|
+
|
13
|
+
By default, the client library retres for a total of `3` times, sleeping `5 sec` between retries. The number of retries and sleeping time between retries can be changed with `set_retries` in the client class.
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
def set_retries(max_retries, retry_sleep_period)
|
17
|
+
@max_retries = max_retries
|
18
|
+
@retry_sleep_period = retry_sleep_period
|
19
|
+
end
|
20
|
+
```
|
21
|
+
|
6
22
|
## Installation
|
7
23
|
```bash
|
8
24
|
gem install azure-loganalytics-datacollector-api
|
@@ -8,6 +8,9 @@ module Azure
|
|
8
8
|
|
9
9
|
class Client
|
10
10
|
|
11
|
+
DEFAUT_MAX_RETRIES = 3.freeze
|
12
|
+
DEFAULT_RETRY_SLEEP_PERIOD = 5.freeze
|
13
|
+
|
11
14
|
def initialize (customer_id, shared_key, endpoint ='ods.opinsights.azure.com')
|
12
15
|
require 'rest-client'
|
13
16
|
require 'json'
|
@@ -19,6 +22,9 @@ module Azure
|
|
19
22
|
@shared_key = shared_key
|
20
23
|
@endpoint = endpoint
|
21
24
|
@default_azure_resource_id = ''
|
25
|
+
|
26
|
+
@max_retries = DEFAUT_MAX_RETRIES
|
27
|
+
@retry_sleep_period = DEFAULT_RETRY_SLEEP_PERIOD
|
22
28
|
end
|
23
29
|
|
24
30
|
def post_data(log_type, json_records, record_timestamp ='', azure_resource_id ='' )
|
@@ -40,8 +46,21 @@ module Azure
|
|
40
46
|
'time-generated-field' => record_timestamp
|
41
47
|
}
|
42
48
|
|
43
|
-
|
44
|
-
|
49
|
+
retries = 0
|
50
|
+
begin
|
51
|
+
res = RestClient.post( uri, body, headers)
|
52
|
+
res
|
53
|
+
rescue => e
|
54
|
+
c = e.response.code.to_i
|
55
|
+
if c == 429 || c == 500 || c==503
|
56
|
+
if retries < @max_retries
|
57
|
+
retries += 1
|
58
|
+
sleep(@retry_sleep_period)
|
59
|
+
retry
|
60
|
+
end
|
61
|
+
end
|
62
|
+
raise e
|
63
|
+
end
|
45
64
|
end
|
46
65
|
|
47
66
|
def set_proxy(proxy='')
|
@@ -51,6 +70,11 @@ module Azure
|
|
51
70
|
def set_default_azure_resoruce_id(azure_resource_id)
|
52
71
|
@default_azure_resource_id = azure_resource_id
|
53
72
|
end
|
73
|
+
|
74
|
+
def set_retres(max_retries, retry_sleep_period)
|
75
|
+
@max_retries = max_retries
|
76
|
+
@retry_sleep_period = retry_sleep_period
|
77
|
+
end
|
54
78
|
|
55
79
|
def self.is_success(res)
|
56
80
|
return (res.code == 200) ? true : false
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: azure-loganalytics-datacollector-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yoichi Kawasaki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|