nexaas-auditor 1.0.0 → 1.0.1
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/README.md +5 -5
- data/lib/nexaas/auditor/statistics_trackers/base.rb +5 -5
- data/lib/nexaas/auditor/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41aa4aade90e929f1017124ecc8dc919dbdf8009
|
4
|
+
data.tar.gz: 140f0375f99bf74b7066dee4d4f7c7476c867f2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e04fd39437da7fe52f8b1da3eea32fc8fe09e2b284926a5e650fafd4cc4ed15422e34dffda5a46de83c6d0172b7ada47cdba70fc83636a7d678c310a2cf0d53c
|
7
|
+
data.tar.gz: f0902b3f3775e410f6572efeaa46b5707f6ed66c8e9e7e84379bca4ae8de49dc5990f8e0486e3df7b21fc6ae64b9910208981cdb0e7bf571c20573bf6c5a49b1
|
data/README.md
CHANGED
@@ -10,7 +10,7 @@ This has been tested with Rails 4.2.x only so far. It probably works fine as wel
|
|
10
10
|
|
11
11
|
The audit log is created in a [logfmt](https://www.brandur.org/logfmt) format only for now. Support for more log formats is planned in the future.
|
12
12
|
|
13
|
-
Both the audit log and statistics tracking assume all instrumented events are named in a dot notation format, for example you could use `'app.users.login.sucess'` to instrument a successful user login event. The `'app.'` prefix is a suggestion to separate your
|
13
|
+
Both the audit log and statistics tracking assume all instrumented events are named in a dot notation format, for example you could use `'app.users.login.sucess'` to instrument a successful user login event. The `'app.'` prefix is a suggestion to separate your business-logic events from framework-specific (Rails) events, which will always have a `'rails.'` prefix, for example `'rails.action_controller.runtime.total'` for example.
|
14
14
|
|
15
15
|
## Installation
|
16
16
|
|
@@ -43,10 +43,10 @@ Nexaas::Auditor.configure do |config|
|
|
43
43
|
config.enabled = true
|
44
44
|
config.logger = Rails.logger
|
45
45
|
|
46
|
-
# use audit logging for
|
46
|
+
# use audit logging for business-logic instrumented events
|
47
47
|
config.log_app_events = true
|
48
48
|
|
49
|
-
# use statistics tracking for
|
49
|
+
# use statistics tracking for business-logic instrumented events
|
50
50
|
config.track_app_events = true
|
51
51
|
|
52
52
|
# use statistics tracking for default Rails instrumented events
|
@@ -74,12 +74,12 @@ end
|
|
74
74
|
Nexaas::Auditor.subscribe_all
|
75
75
|
```
|
76
76
|
|
77
|
-
Then, create your loggers and statistic trackers in `app/loggers/` and `app/statistics/` for example, inheriting from `Nexaas::Auditor::
|
77
|
+
Then, create your loggers and statistic trackers in `app/loggers/` and `app/statistics/` for example, inheriting from `Nexaas::Auditor::LogsSubscriber` and `Nexaas::Auditor::StatsSubscriber` respectively.
|
78
78
|
|
79
79
|
For example:
|
80
80
|
|
81
81
|
```ruby
|
82
|
-
class UsersAppLogger < ::Nexaas::Auditor::
|
82
|
+
class UsersAppLogger < ::Nexaas::Auditor::LogsSubscriber
|
83
83
|
# The namespace for events to subscribe to. In this example, subscribe to all
|
84
84
|
# events beggining with "app.users.".
|
85
85
|
def self.pattern
|
@@ -3,18 +3,18 @@ module Nexaas
|
|
3
3
|
module StatisticsTrackers
|
4
4
|
class Base
|
5
5
|
|
6
|
-
def track_count(
|
7
|
-
|
6
|
+
def track_count(metric:, value: nil)
|
7
|
+
value ||= 1
|
8
|
+
track(:count, metric, value)
|
8
9
|
end
|
9
10
|
|
10
|
-
def track_value(
|
11
|
-
track(:value,
|
11
|
+
def track_value(metric:, value:)
|
12
|
+
track(:value, metric, value)
|
12
13
|
end
|
13
14
|
|
14
15
|
private
|
15
16
|
|
16
17
|
def track(type, name, value)
|
17
|
-
value ||= 1 if type == :count
|
18
18
|
validate_value!(value, type)
|
19
19
|
full_name = full_metric_name(name)
|
20
20
|
validate_name!(name, full_name)
|