Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
bccc5397
Unverified
Commit
bccc5397
authored
Nov 22, 2019
by
Jon Gyllenswärd
Committed by
GitHub
Nov 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Instrumentation: Edition and license info to usage stats (#20589)
* Added edition and licensing info to usage stats
parent
be6a4e80
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
9 deletions
+36
-9
pkg/infra/usagestats/usage_stats.go
+36
-9
No files found.
pkg/infra/usagestats/usage_stats.go
View file @
bccc5397
...
@@ -28,12 +28,13 @@ func (uss *UsageStatsService) sendUsageStats(oauthProviders map[string]bool) {
...
@@ -28,12 +28,13 @@ func (uss *UsageStatsService) sendUsageStats(oauthProviders map[string]bool) {
metrics
:=
map
[
string
]
interface
{}{}
metrics
:=
map
[
string
]
interface
{}{}
report
:=
map
[
string
]
interface
{}{
report
:=
map
[
string
]
interface
{}{
"version"
:
version
,
"version"
:
version
,
"metrics"
:
metrics
,
"metrics"
:
metrics
,
"os"
:
runtime
.
GOOS
,
"os"
:
runtime
.
GOOS
,
"arch"
:
runtime
.
GOARCH
,
"arch"
:
runtime
.
GOARCH
,
"edition"
:
getEdition
(
uss
.
License
.
HasValidLicense
()),
"edition"
:
getEdition
(),
"packaging"
:
setting
.
Packaging
,
"hasValidLicense"
:
uss
.
License
.
HasValidLicense
(),
"packaging"
:
setting
.
Packaging
,
}
}
statsQuery
:=
models
.
GetSystemStatsQuery
{}
statsQuery
:=
models
.
GetSystemStatsQuery
{}
...
@@ -60,6 +61,9 @@ func (uss *UsageStatsService) sendUsageStats(oauthProviders map[string]bool) {
...
@@ -60,6 +61,9 @@ func (uss *UsageStatsService) sendUsageStats(oauthProviders map[string]bool) {
metrics
[
"stats.snapshots.count"
]
=
statsQuery
.
Result
.
Snapshots
metrics
[
"stats.snapshots.count"
]
=
statsQuery
.
Result
.
Snapshots
metrics
[
"stats.teams.count"
]
=
statsQuery
.
Result
.
Teams
metrics
[
"stats.teams.count"
]
=
statsQuery
.
Result
.
Teams
metrics
[
"stats.total_auth_token.count"
]
=
statsQuery
.
Result
.
AuthTokens
metrics
[
"stats.total_auth_token.count"
]
=
statsQuery
.
Result
.
AuthTokens
metrics
[
"stats.valid_license.count"
]
=
getValidLicenseCount
(
uss
.
License
.
HasValidLicense
())
metrics
[
"stats.edition.oss.count"
]
=
getOssEditionCount
()
metrics
[
"stats.edition.enterprise.count"
]
=
getEnterpriseEditionCount
()
userCount
:=
statsQuery
.
Result
.
Users
userCount
:=
statsQuery
.
Result
.
Users
avgAuthTokensPerUser
:=
statsQuery
.
Result
.
AuthTokens
avgAuthTokensPerUser
:=
statsQuery
.
Result
.
AuthTokens
...
@@ -182,9 +186,32 @@ func (uss *UsageStatsService) updateTotalStats() {
...
@@ -182,9 +186,32 @@ func (uss *UsageStatsService) updateTotalStats() {
metrics
.
StatsTotalActiveAdmins
.
Set
(
float64
(
statsQuery
.
Result
.
ActiveAdmins
))
metrics
.
StatsTotalActiveAdmins
.
Set
(
float64
(
statsQuery
.
Result
.
ActiveAdmins
))
}
}
func
getEdition
(
validLicense
bool
)
string
{
func
getEdition
()
string
{
edition
:=
"oss"
if
setting
.
IsEnterprise
{
edition
=
"enterprise"
}
return
edition
}
func
getEnterpriseEditionCount
()
int
{
if
setting
.
IsEnterprise
{
return
1
}
return
0
}
func
getOssEditionCount
()
int
{
if
setting
.
IsEnterprise
{
return
0
}
return
1
}
func
getValidLicenseCount
(
validLicense
bool
)
int
{
if
validLicense
{
if
validLicense
{
return
"enterprise"
return
1
}
}
return
"oss"
return
0
}
}
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