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
bb50fc59
Unverified
Commit
bb50fc59
authored
Oct 22, 2019
by
Arve Knudsen
Committed by
GitHub
Oct 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pkg/tsdb: Check errors (#19837)
Check errors in pkg/tsdb.
parent
79cbe191
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
40 additions
and
20 deletions
+40
-20
pkg/tsdb/azuremonitor/azuremonitor-datasource.go
+5
-2
pkg/tsdb/elasticsearch/client/client_test.go
+5
-4
pkg/tsdb/graphite/graphite.go
+4
-2
pkg/tsdb/influxdb/response_parser_test.go
+2
-1
pkg/tsdb/interval_test.go
+2
-1
pkg/tsdb/mssql/mssql_test.go
+2
-1
pkg/tsdb/mysql/mysql.go
+3
-1
pkg/tsdb/mysql/mysql_test.go
+8
-4
pkg/tsdb/postgres/postgres_test.go
+4
-2
pkg/tsdb/stackdriver/stackdriver.go
+5
-2
No files found.
pkg/tsdb/azuremonitor/azuremonitor-datasource.go
View file @
bb50fc59
...
...
@@ -169,10 +169,13 @@ func (e *AzureMonitorDatasource) executeQuery(ctx context.Context, query *AzureM
defer
span
.
Finish
()
opentracing
.
GlobalTracer
()
.
Inject
(
if
err
:=
opentracing
.
GlobalTracer
()
.
Inject
(
span
.
Context
(),
opentracing
.
HTTPHeaders
,
opentracing
.
HTTPHeadersCarrier
(
req
.
Header
))
opentracing
.
HTTPHeadersCarrier
(
req
.
Header
));
err
!=
nil
{
queryResult
.
Error
=
err
return
queryResult
,
AzureMonitorResponse
{},
nil
}
azlog
.
Debug
(
"AzureMonitor"
,
"Request ApiURL"
,
req
.
URL
.
String
())
res
,
err
:=
ctxhttp
.
Do
(
ctx
,
e
.
httpClient
,
req
)
...
...
pkg/tsdb/elasticsearch/client/client_test.go
View file @
bb50fc59
...
...
@@ -12,6 +12,7 @@ import (
"github.com/grafana/grafana/pkg/components/simplejson"
"github.com/grafana/grafana/pkg/tsdb"
"github.com/stretchr/testify/require"
"github.com/grafana/grafana/pkg/models"
.
"github.com/smartystreets/goconvey/convey"
...
...
@@ -402,13 +403,13 @@ func httpClientScenario(t *testing.T, desc string, ds *models.DataSource, fn sce
ts
:=
httptest
.
NewServer
(
http
.
HandlerFunc
(
func
(
rw
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
sc
.
request
=
r
buf
,
err
:=
ioutil
.
ReadAll
(
r
.
Body
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed to read request body, err=%v"
,
err
)
}
require
.
Nil
(
t
,
err
)
sc
.
requestBody
=
bytes
.
NewBuffer
(
buf
)
rw
.
Header
()
.
Add
(
"Content-Type"
,
"application/json"
)
rw
.
Write
([]
byte
(
sc
.
responseBody
))
_
,
err
=
rw
.
Write
([]
byte
(
sc
.
responseBody
))
require
.
Nil
(
t
,
err
)
rw
.
WriteHeader
(
sc
.
responseStatus
)
}))
ds
.
Url
=
ts
.
URL
...
...
pkg/tsdb/graphite/graphite.go
View file @
bb50fc59
...
...
@@ -82,10 +82,12 @@ func (e *GraphiteExecutor) Query(ctx context.Context, dsInfo *models.DataSource,
defer
span
.
Finish
()
opentracing
.
GlobalTracer
()
.
Inject
(
if
err
:=
opentracing
.
GlobalTracer
()
.
Inject
(
span
.
Context
(),
opentracing
.
HTTPHeaders
,
opentracing
.
HTTPHeadersCarrier
(
req
.
Header
))
opentracing
.
HTTPHeadersCarrier
(
req
.
Header
));
err
!=
nil
{
return
nil
,
err
}
res
,
err
:=
ctxhttp
.
Do
(
ctx
,
httpClient
,
req
)
if
err
!=
nil
{
...
...
pkg/tsdb/influxdb/response_parser_test.go
View file @
bb50fc59
...
...
@@ -14,9 +14,10 @@ func TestInfluxdbResponseParser(t *testing.T) {
parser
:=
&
ResponseParser
{}
cfg
:=
setting
.
NewCfg
()
cfg
.
Load
(
&
setting
.
CommandLineArgs
{
err
:=
cfg
.
Load
(
&
setting
.
CommandLineArgs
{
HomePath
:
"../../../"
,
})
So
(
err
,
ShouldBeNil
)
response
:=
&
Response
{
Results
:
[]
Result
{
...
...
pkg/tsdb/interval_test.go
View file @
bb50fc59
...
...
@@ -11,9 +11,10 @@ import (
func
TestInterval
(
t
*
testing
.
T
)
{
Convey
(
"Default interval "
,
t
,
func
()
{
cfg
:=
setting
.
NewCfg
()
cfg
.
Load
(
&
setting
.
CommandLineArgs
{
err
:=
cfg
.
Load
(
&
setting
.
CommandLineArgs
{
HomePath
:
"../../"
,
})
So
(
err
,
ShouldBeNil
)
calculator
:=
NewIntervalCalculator
(
&
IntervalOptions
{})
...
...
pkg/tsdb/mssql/mssql_test.go
View file @
bb50fc59
...
...
@@ -382,7 +382,8 @@ func TestMSSQL(t *testing.T) {
if
exist
,
err
:=
sess
.
IsTableExist
(
metric_values
{});
err
!=
nil
||
exist
{
So
(
err
,
ShouldBeNil
)
sess
.
DropTable
(
metric_values
{})
err
=
sess
.
DropTable
(
metric_values
{})
So
(
err
,
ShouldBeNil
)
}
err
:=
sess
.
CreateTable
(
metric_values
{})
So
(
err
,
ShouldBeNil
)
...
...
pkg/tsdb/mysql/mysql.go
View file @
bb50fc59
...
...
@@ -46,7 +46,9 @@ func newMysqlQueryEndpoint(datasource *models.DataSource) (tsdb.TsdbQueryEndpoin
if
tlsConfig
.
RootCAs
!=
nil
||
len
(
tlsConfig
.
Certificates
)
>
0
{
tlsConfigString
:=
fmt
.
Sprintf
(
"ds%d"
,
datasource
.
Id
)
mysql
.
RegisterTLSConfig
(
tlsConfigString
,
tlsConfig
)
if
err
:=
mysql
.
RegisterTLSConfig
(
tlsConfigString
,
tlsConfig
);
err
!=
nil
{
return
nil
,
err
}
cnnstr
+=
"&tls="
+
tlsConfigString
}
...
...
pkg/tsdb/mysql/mysql_test.go
View file @
bb50fc59
...
...
@@ -68,7 +68,8 @@ func TestMySQL(t *testing.T) {
Convey
(
"Given a table with different native data types"
,
func
()
{
if
exists
,
err
:=
sess
.
IsTableExist
(
"mysql_types"
);
err
!=
nil
||
exists
{
So
(
err
,
ShouldBeNil
)
sess
.
DropTable
(
"mysql_types"
)
err
=
sess
.
DropTable
(
"mysql_types"
)
So
(
err
,
ShouldBeNil
)
}
sql
:=
"CREATE TABLE `mysql_types` ("
...
...
@@ -181,7 +182,8 @@ func TestMySQL(t *testing.T) {
if
exist
,
err
:=
sess
.
IsTableExist
(
metric
{});
err
!=
nil
||
exist
{
So
(
err
,
ShouldBeNil
)
sess
.
DropTable
(
metric
{})
err
=
sess
.
DropTable
(
metric
{})
So
(
err
,
ShouldBeNil
)
}
err
:=
sess
.
CreateTable
(
metric
{})
So
(
err
,
ShouldBeNil
)
...
...
@@ -413,7 +415,8 @@ func TestMySQL(t *testing.T) {
if
exist
,
err
:=
sess
.
IsTableExist
(
metric_values
{});
err
!=
nil
||
exist
{
So
(
err
,
ShouldBeNil
)
sess
.
DropTable
(
metric_values
{})
err
=
sess
.
DropTable
(
metric_values
{})
So
(
err
,
ShouldBeNil
)
}
err
:=
sess
.
CreateTable
(
metric_values
{})
So
(
err
,
ShouldBeNil
)
...
...
@@ -788,7 +791,8 @@ func TestMySQL(t *testing.T) {
if
exist
,
err
:=
sess
.
IsTableExist
(
event
{});
err
!=
nil
||
exist
{
So
(
err
,
ShouldBeNil
)
sess
.
DropTable
(
event
{})
err
=
sess
.
DropTable
(
event
{})
So
(
err
,
ShouldBeNil
)
}
err
:=
sess
.
CreateTable
(
event
{})
So
(
err
,
ShouldBeNil
)
...
...
pkg/tsdb/postgres/postgres_test.go
View file @
bb50fc59
...
...
@@ -392,7 +392,8 @@ func TestPostgres(t *testing.T) {
if
exist
,
err
:=
sess
.
IsTableExist
(
metric_values
{});
err
!=
nil
||
exist
{
So
(
err
,
ShouldBeNil
)
sess
.
DropTable
(
metric_values
{})
err
=
sess
.
DropTable
(
metric_values
{})
So
(
err
,
ShouldBeNil
)
}
err
:=
sess
.
CreateTable
(
metric_values
{})
So
(
err
,
ShouldBeNil
)
...
...
@@ -721,7 +722,8 @@ func TestPostgres(t *testing.T) {
if
exist
,
err
:=
sess
.
IsTableExist
(
event
{});
err
!=
nil
||
exist
{
So
(
err
,
ShouldBeNil
)
sess
.
DropTable
(
event
{})
err
=
sess
.
DropTable
(
event
{})
So
(
err
,
ShouldBeNil
)
}
err
:=
sess
.
CreateTable
(
event
{})
So
(
err
,
ShouldBeNil
)
...
...
pkg/tsdb/stackdriver/stackdriver.go
View file @
bb50fc59
...
...
@@ -303,10 +303,13 @@ func (e *StackdriverExecutor) executeQuery(ctx context.Context, query *Stackdriv
defer
span
.
Finish
()
opentracing
.
GlobalTracer
()
.
Inject
(
if
err
:=
opentracing
.
GlobalTracer
()
.
Inject
(
span
.
Context
(),
opentracing
.
HTTPHeaders
,
opentracing
.
HTTPHeadersCarrier
(
req
.
Header
))
opentracing
.
HTTPHeadersCarrier
(
req
.
Header
));
err
!=
nil
{
queryResult
.
Error
=
err
return
queryResult
,
StackdriverResponse
{},
nil
}
res
,
err
:=
ctxhttp
.
Do
(
ctx
,
e
.
httpClient
,
req
)
if
err
!=
nil
{
...
...
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