Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
telegraf-nftables
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Due to inactivity, this project is scheduled to be deleted on 2035-04-24.
Why is this scheduled?
Show more breadcrumbs
vqgroup
telegraf-nftables
Commits
8d328552
Commit
8d328552
authored
8 years ago
by
Cameron Sparr
Browse files
Options
Downloads
Patches
Plain Diff
Prometheus output: do not remake metrics map each write
closes #1775
parent
b613405f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CHANGELOG.md
+7
-1
7 additions, 1 deletion
CHANGELOG.md
plugins/outputs/prometheus_client/prometheus_client.go
+15
-5
15 additions, 5 deletions
plugins/outputs/prometheus_client/prometheus_client.go
with
22 additions
and
6 deletions
CHANGELOG.md
+
7
−
1
View file @
8d328552
...
@@ -23,13 +23,19 @@
...
@@ -23,13 +23,19 @@
### Bugfixes
### Bugfixes
-
[
#1628
](
https://github.com/influxdata/telegraf/issues/1628
)
: Fix mongodb input panic on version 2.2.
-
[
#1628
](
https://github.com/influxdata/telegraf/issues/1628
)
: Fix mongodb input panic on version 2.2.
-
[
#1738
](
https://github.com/influxdata/telegraf/issues/1738
)
: Fix unmarshal of influxdb metrics with null tags
-
[
#1733
](
https://github.com/influxdata/telegraf/issues/1733
)
: Fix statsd scientific notation parsing
-
[
#1733
](
https://github.com/influxdata/telegraf/issues/1733
)
: Fix statsd scientific notation parsing
-
[
#1716
](
https://github.com/influxdata/telegraf/issues/1716
)
: Sensors plugin strconv.ParseFloat: parsing "": invalid syntax
-
[
#1716
](
https://github.com/influxdata/telegraf/issues/1716
)
: Sensors plugin strconv.ParseFloat: parsing "": invalid syntax
-
[
#1530
](
https://github.com/influxdata/telegraf/issues/1530
)
: Fix prometheus_client reload panic
-
[
#1530
](
https://github.com/influxdata/telegraf/issues/1530
)
: Fix prometheus_client reload panic
-
[
#1764
](
https://github.com/influxdata/telegraf/issues/1764
)
: Fix kafka consumer panic when nil error is returned down errs channel.
-
[
#1764
](
https://github.com/influxdata/telegraf/issues/1764
)
: Fix kafka consumer panic when nil error is returned down errs channel.
-
[
#1768
](
https://github.com/influxdata/telegraf/pull/1768
)
: Speed up statsd parsing.
-
[
#1768
](
https://github.com/influxdata/telegraf/pull/1768
)
: Speed up statsd parsing.
## v1.0.1 [unreleased]
### Bugfixes
-
[
#1775
](
https://github.com/influxdata/telegraf/issues/1775
)
: Prometheus output: Fix bug with multi-batch writes.
-
[
#1738
](
https://github.com/influxdata/telegraf/issues/1738
)
: Fix unmarshal of influxdb metrics with null tags
## v1.0 [2016-09-08]
## v1.0 [2016-09-08]
### Release Notes
### Release Notes
...
...
This diff is collapsed.
Click to expand it.
plugins/outputs/prometheus_client/prometheus_client.go
+
15
−
5
View file @
8d328552
...
@@ -17,7 +17,8 @@ var invalidNameCharRE = regexp.MustCompile(`[^a-zA-Z0-9_]`)
...
@@ -17,7 +17,8 @@ var invalidNameCharRE = regexp.MustCompile(`[^a-zA-Z0-9_]`)
type
PrometheusClient
struct
{
type
PrometheusClient
struct
{
Listen
string
Listen
string
metrics
map
[
string
]
prometheus
.
Metric
metrics
map
[
string
]
prometheus
.
Metric
lastMetrics
map
[
string
]
prometheus
.
Metric
sync
.
Mutex
sync
.
Mutex
}
}
...
@@ -28,6 +29,8 @@ var sampleConfig = `
...
@@ -28,6 +29,8 @@ var sampleConfig = `
`
`
func
(
p
*
PrometheusClient
)
Start
()
error
{
func
(
p
*
PrometheusClient
)
Start
()
error
{
p
.
metrics
=
make
(
map
[
string
]
prometheus
.
Metric
)
p
.
lastMetrics
=
make
(
map
[
string
]
prometheus
.
Metric
)
prometheus
.
Register
(
p
)
prometheus
.
Register
(
p
)
defer
func
()
{
defer
func
()
{
if
r
:=
recover
();
r
!=
nil
{
if
r
:=
recover
();
r
!=
nil
{
...
@@ -83,8 +86,17 @@ func (p *PrometheusClient) Collect(ch chan<- prometheus.Metric) {
...
@@ -83,8 +86,17 @@ func (p *PrometheusClient) Collect(ch chan<- prometheus.Metric) {
p
.
Lock
()
p
.
Lock
()
defer
p
.
Unlock
()
defer
p
.
Unlock
()
for
_
,
m
:=
range
p
.
metrics
{
if
len
(
p
.
metrics
)
>
0
{
ch
<-
m
p
.
lastMetrics
=
make
(
map
[
string
]
prometheus
.
Metric
)
for
k
,
m
:=
range
p
.
metrics
{
ch
<-
m
p
.
lastMetrics
[
k
]
=
m
}
p
.
metrics
=
make
(
map
[
string
]
prometheus
.
Metric
)
}
else
{
for
_
,
m
:=
range
p
.
lastMetrics
{
ch
<-
m
}
}
}
}
}
...
@@ -92,8 +104,6 @@ func (p *PrometheusClient) Write(metrics []telegraf.Metric) error {
...
@@ -92,8 +104,6 @@ func (p *PrometheusClient) Write(metrics []telegraf.Metric) error {
p
.
Lock
()
p
.
Lock
()
defer
p
.
Unlock
()
defer
p
.
Unlock
()
p
.
metrics
=
make
(
map
[
string
]
prometheus
.
Metric
)
if
len
(
metrics
)
==
0
{
if
len
(
metrics
)
==
0
{
return
nil
return
nil
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment