Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
85db6721
Unverified
Commit
85db6721
authored
Nov 26, 2022
by
boojack
Committed by
GitHub
Nov 26, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: disable metrics collector (#580)
parent
b511a7b6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
9 deletions
+17
-9
main.go
bin/server/main.go
+2
-0
metric_collector.go
server/metric_collector.go
+15
-9
No files found.
bin/server/main.go
View file @
85db6721
...
@@ -40,6 +40,8 @@ func run(profile *profile.Profile) error {
...
@@ -40,6 +40,8 @@ func run(profile *profile.Profile) error {
serverInstance
.
Store
=
storeInstance
serverInstance
.
Store
=
storeInstance
metricCollector
:=
server
.
NewMetricCollector
(
profile
,
storeInstance
)
metricCollector
:=
server
.
NewMetricCollector
(
profile
,
storeInstance
)
// Disable metrics collector.
metricCollector
.
Enabled
=
false
serverInstance
.
Collector
=
&
metricCollector
serverInstance
.
Collector
=
&
metricCollector
println
(
greetingBanner
)
println
(
greetingBanner
)
...
...
server/metric_collector.go
View file @
85db6721
...
@@ -13,9 +13,10 @@ import (
...
@@ -13,9 +13,10 @@ import (
// MetricCollector is the metric collector.
// MetricCollector is the metric collector.
type
MetricCollector
struct
{
type
MetricCollector
struct
{
collector
metric
.
Collector
Collector
metric
.
Collector
profile
*
profile
.
Profile
Enabled
bool
store
*
store
.
Store
Profile
*
profile
.
Profile
Store
*
store
.
Store
}
}
const
(
const
(
...
@@ -26,23 +27,28 @@ func NewMetricCollector(profile *profile.Profile, store *store.Store) MetricColl
...
@@ -26,23 +27,28 @@ func NewMetricCollector(profile *profile.Profile, store *store.Store) MetricColl
c
:=
segment
.
NewCollector
(
segmentMetricWriteKey
)
c
:=
segment
.
NewCollector
(
segmentMetricWriteKey
)
return
MetricCollector
{
return
MetricCollector
{
collector
:
c
,
Collector
:
c
,
profile
:
profile
,
Enabled
:
true
,
store
:
store
,
Profile
:
profile
,
Store
:
store
,
}
}
}
}
func
(
mc
*
MetricCollector
)
Collect
(
_
context
.
Context
,
metric
*
metric
.
Metric
)
{
func
(
mc
*
MetricCollector
)
Collect
(
_
context
.
Context
,
metric
*
metric
.
Metric
)
{
if
mc
.
profile
.
Mode
==
"dev"
{
if
!
mc
.
Enabled
{
return
}
if
mc
.
Profile
.
Mode
==
"dev"
{
return
return
}
}
if
metric
.
Labels
==
nil
{
if
metric
.
Labels
==
nil
{
metric
.
Labels
=
map
[
string
]
string
{}
metric
.
Labels
=
map
[
string
]
string
{}
}
}
metric
.
Labels
[
"version"
]
=
version
.
GetCurrentVersion
(
mc
.
p
rofile
.
Mode
)
metric
.
Labels
[
"version"
]
=
version
.
GetCurrentVersion
(
mc
.
P
rofile
.
Mode
)
err
:=
mc
.
c
ollector
.
Collect
(
metric
)
err
:=
mc
.
C
ollector
.
Collect
(
metric
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Printf
(
"Failed to request segment, error: %+v
\n
"
,
err
)
fmt
.
Printf
(
"Failed to request segment, error: %+v
\n
"
,
err
)
}
}
...
...
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