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
f160ad3b
Commit
f160ad3b
authored
Sep 10, 2017
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add trace parameters for outgoing requests
parent
2e350bbb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
4 deletions
+36
-4
pkg/tsdb/graphite/graphite.go
+25
-4
pkg/tsdb/prometheus/prometheus.go
+11
-0
No files found.
pkg/tsdb/graphite/graphite.go
View file @
f160ad3b
...
...
@@ -17,6 +17,8 @@ import (
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/tsdb"
opentracing
"github.com/opentracing/opentracing-go"
tlog
"github.com/opentracing/opentracing-go/log"
)
type
GraphiteExecutor
struct
{
...
...
@@ -49,21 +51,27 @@ func init() {
func
(
e
*
GraphiteExecutor
)
Execute
(
ctx
context
.
Context
,
queries
tsdb
.
QuerySlice
,
context
*
tsdb
.
QueryContext
)
*
tsdb
.
BatchResult
{
result
:=
&
tsdb
.
BatchResult
{}
from
:=
"-"
+
formatTimeRange
(
context
.
TimeRange
.
From
)
until
:=
formatTimeRange
(
context
.
TimeRange
.
To
)
var
target
string
formData
:=
url
.
Values
{
"from"
:
[]
string
{
"-"
+
formatTimeRange
(
context
.
TimeRange
.
From
)
},
"until"
:
[]
string
{
formatTimeRange
(
context
.
TimeRange
.
To
)
},
"from"
:
[]
string
{
from
},
"until"
:
[]
string
{
until
},
"format"
:
[]
string
{
"json"
},
"maxDataPoints"
:
[]
string
{
"500"
},
}
for
_
,
query
:=
range
queries
{
if
fullTarget
,
err
:=
query
.
Model
.
Get
(
"targetFull"
)
.
String
();
err
==
nil
{
formData
[
"target"
]
=
[]
string
{
fixIntervalFormat
(
fullTarget
)}
target
=
fixIntervalFormat
(
fullTarget
)
}
else
{
formData
[
"target"
]
=
[]
string
{
fixIntervalFormat
(
query
.
Model
.
Get
(
"target"
)
.
MustString
())}
target
=
fixIntervalFormat
(
query
.
Model
.
Get
(
"target"
)
.
MustString
())
}
}
formData
[
"target"
]
=
[]
string
{
target
}
if
setting
.
Env
==
setting
.
DEV
{
glog
.
Debug
(
"Graphite request"
,
"params"
,
formData
)
}
...
...
@@ -74,6 +82,19 @@ func (e *GraphiteExecutor) Execute(ctx context.Context, queries tsdb.QuerySlice,
return
result
}
span
,
ctx
:=
opentracing
.
StartSpanFromContext
(
ctx
,
"alerting.graphite"
)
span
.
LogFields
(
tlog
.
String
(
"target"
,
target
),
tlog
.
String
(
"from"
,
from
),
tlog
.
String
(
"until"
,
until
),
)
defer
span
.
Finish
()
opentracing
.
GlobalTracer
()
.
Inject
(
span
.
Context
(),
opentracing
.
HTTPHeaders
,
opentracing
.
HTTPHeadersCarrier
(
req
.
Header
))
res
,
err
:=
ctxhttp
.
Do
(
ctx
,
e
.
HttpClient
,
req
)
if
err
!=
nil
{
result
.
Error
=
err
...
...
pkg/tsdb/prometheus/prometheus.go
View file @
f160ad3b
...
...
@@ -7,6 +7,8 @@ import (
"strings"
"time"
"github.com/opentracing/opentracing-go"
"net/http"
"github.com/grafana/grafana/pkg/components/null"
...
...
@@ -18,6 +20,7 @@ import (
"github.com/prometheus/common/model"
//api "github.com/prometheus/client_golang/api"
//apiv1 "github.com/prometheus/client_golang/api/prometheus/v1"
tlog
"github.com/opentracing/opentracing-go/log"
)
type
PrometheusExecutor
struct
{
...
...
@@ -101,6 +104,14 @@ func (e *PrometheusExecutor) Execute(ctx context.Context, queries tsdb.QuerySlic
Step
:
query
.
Step
,
}
span
,
ctx
:=
opentracing
.
StartSpanFromContext
(
ctx
,
"alerting.prometheus"
)
span
.
LogFields
(
tlog
.
String
(
"expr"
,
query
.
Expr
),
tlog
.
Int64
(
"start_unixnano"
,
int64
(
query
.
Start
.
UnixNano
())),
tlog
.
Int64
(
"stop_unixnano"
,
int64
(
query
.
End
.
UnixNano
())),
)
defer
span
.
Finish
()
value
,
err
:=
client
.
QueryRange
(
ctx
,
query
.
Expr
,
timeRange
)
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