Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
8196fc46
Commit
8196fc46
authored
Sep 24, 2020
by
Alishan Ladhani
Committed by
Mike Jang
Sep 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add documentation for batch sum method
parent
dc8f839f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
1 deletion
+24
-1
doc/development/telemetry/usage_ping.md
doc/development/telemetry/usage_ping.md
+24
-1
No files found.
doc/development/telemetry/usage_ping.md
View file @
8196fc46
...
...
@@ -126,10 +126,11 @@ happened over time, such as how many CI pipelines have run. They are monotonic a
Observations are facts collected from one or more GitLab instances and can carry arbitrary data. There are no
general guidelines around how to collect those, due to the individual nature of that data.
There are
four
types of counters which are all found in
`usage_data.rb`
:
There are
several
types of counters which are all found in
`usage_data.rb`
:
-
**Ordinary Batch Counters:**
Simple count of a given ActiveRecord_Relation
-
**Distinct Batch Counters:**
Distinct count of a given ActiveRecord_Relation on given column
-
**Sum Batch Counters:**
Sum the values of a given ActiveRecord_Relation on given column
-
**Alternative Counters:**
Used for settings and configurations
-
**Redis Counters:**
Used for in-memory counts.
...
...
@@ -200,6 +201,28 @@ distinct_count(::Note.with_suggestions.where(time_period), :author_id, start: ::
distinct_count
(
::
Clusters
::
Applications
::
CertManager
.
where
(
time_period
).
available
.
joins
(
:cluster
),
'clusters.user_id'
)
```
### Sum Batch Counters
Handles
`ActiveRecord::StatementInvalid`
error
Sum the values of a given ActiveRecord_Relation on given column and handles errors.
Method:
`sum(relation, column, batch_size: nil, start: nil, finish: nil)`
Arguments:
-
`relation`
the ActiveRecord_Relation to perform the operation
-
`column`
the column to sum on
-
`batch_size`
: if none set it will use default value 1000 from
`Gitlab::Database::BatchCounter`
-
`start`
: custom start of the batch counting in order to avoid complex min calculations
-
`end`
: custom end of the batch counting in order to avoid complex min calculations
Examples:
```
ruby
sum
(
JiraImportState
.
finished
,
:imported_issues_count
)
```
### Redis Counters
Handles
`::Redis::CommandError`
and
`Gitlab::UsageDataCounters::BaseCounter::UnknownEvent`
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment