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
66441650
Commit
66441650
authored
Sep 01, 2017
by
Nevins
Committed by
Torkel Ödegaard
Sep 01, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changing ordering so AWS API is only called if cache has expired (#9136)
parent
7b147364
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
10 deletions
+8
-10
pkg/api/cloudwatch/metrics.go
+8
-10
No files found.
pkg/api/cloudwatch/metrics.go
View file @
66441650
...
...
@@ -292,11 +292,6 @@ func getAllMetrics(cwData *datasourceInfo) (cloudwatch.ListMetricsOutput, error)
var
metricsCacheLock
sync
.
Mutex
func
getMetricsForCustomMetrics
(
dsInfo
*
datasourceInfo
,
getAllMetrics
func
(
*
datasourceInfo
)
(
cloudwatch
.
ListMetricsOutput
,
error
))
([]
string
,
error
)
{
result
,
err
:=
getAllMetrics
(
dsInfo
)
if
err
!=
nil
{
return
[]
string
{},
err
}
metricsCacheLock
.
Lock
()
defer
metricsCacheLock
.
Unlock
()
...
...
@@ -314,6 +309,10 @@ func getMetricsForCustomMetrics(dsInfo *datasourceInfo, getAllMetrics func(*data
if
customMetricsMetricsMap
[
dsInfo
.
Profile
][
dsInfo
.
Region
][
dsInfo
.
Namespace
]
.
Expire
.
After
(
time
.
Now
())
{
return
customMetricsMetricsMap
[
dsInfo
.
Profile
][
dsInfo
.
Region
][
dsInfo
.
Namespace
]
.
Cache
,
nil
}
result
,
err
:=
getAllMetrics
(
dsInfo
)
if
err
!=
nil
{
return
[]
string
{},
err
}
customMetricsMetricsMap
[
dsInfo
.
Profile
][
dsInfo
.
Region
][
dsInfo
.
Namespace
]
.
Cache
=
make
([]
string
,
0
)
customMetricsMetricsMap
[
dsInfo
.
Profile
][
dsInfo
.
Region
][
dsInfo
.
Namespace
]
.
Expire
=
time
.
Now
()
.
Add
(
5
*
time
.
Minute
)
...
...
@@ -330,11 +329,6 @@ func getMetricsForCustomMetrics(dsInfo *datasourceInfo, getAllMetrics func(*data
var
dimensionsCacheLock
sync
.
Mutex
func
getDimensionsForCustomMetrics
(
dsInfo
*
datasourceInfo
,
getAllMetrics
func
(
*
datasourceInfo
)
(
cloudwatch
.
ListMetricsOutput
,
error
))
([]
string
,
error
)
{
result
,
err
:=
getAllMetrics
(
dsInfo
)
if
err
!=
nil
{
return
[]
string
{},
err
}
dimensionsCacheLock
.
Lock
()
defer
dimensionsCacheLock
.
Unlock
()
...
...
@@ -352,6 +346,10 @@ func getDimensionsForCustomMetrics(dsInfo *datasourceInfo, getAllMetrics func(*d
if
customMetricsDimensionsMap
[
dsInfo
.
Profile
][
dsInfo
.
Region
][
dsInfo
.
Namespace
]
.
Expire
.
After
(
time
.
Now
())
{
return
customMetricsDimensionsMap
[
dsInfo
.
Profile
][
dsInfo
.
Region
][
dsInfo
.
Namespace
]
.
Cache
,
nil
}
result
,
err
:=
getAllMetrics
(
dsInfo
)
if
err
!=
nil
{
return
[]
string
{},
err
}
customMetricsDimensionsMap
[
dsInfo
.
Profile
][
dsInfo
.
Region
][
dsInfo
.
Namespace
]
.
Cache
=
make
([]
string
,
0
)
customMetricsDimensionsMap
[
dsInfo
.
Profile
][
dsInfo
.
Region
][
dsInfo
.
Namespace
]
.
Expire
=
time
.
Now
()
.
Add
(
5
*
time
.
Minute
)
...
...
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