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
ec29b469
Commit
ec29b469
authored
Sep 14, 2017
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adds custom tags from settings
parent
e3211f6e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
68 additions
and
8 deletions
+68
-8
conf/defaults.ini
+2
-0
conf/sample.ini
+2
-0
pkg/middleware/request_tracing.go
+1
-3
pkg/tracing/tracing.go
+27
-5
pkg/tracing/tracing_test.go
+36
-0
No files found.
conf/defaults.ini
View file @
ec29b469
...
...
@@ -456,6 +456,8 @@ url = https://grafana.com
[tracing.jaeger]
# jaeger destination (ex localhost:6831)
address
=
# tag that will always be included in when creating new spans. ex (tag1:value1,tag2:value2)
always_included_tag
=
#################################### External Image Storage ##############
[external_image_storage]
...
...
conf/sample.ini
View file @
ec29b469
...
...
@@ -395,6 +395,8 @@
[tracing.jaeger]
# Enable by setting the address sending traces to jaeger (ex localhost:6831)
;address = localhost:6831
# Tag that will always be included in when creating new spans. ex (tag1:value1,tag2:value2)
;always_included_tag = tag1:value1
#################################### Grafana.com integration ##########################
# Url used to to import dashboards directly from Grafana.com
...
...
pkg/middleware/request_tracing.go
View file @
ec29b469
...
...
@@ -14,11 +14,9 @@ func RequestTracing(handler string) macaron.Handler {
return
func
(
res
http
.
ResponseWriter
,
req
*
http
.
Request
,
c
*
macaron
.
Context
)
{
rw
:=
res
.
(
macaron
.
ResponseWriter
)
var
span
opentracing
.
Span
tracer
:=
opentracing
.
GlobalTracer
()
wireContext
,
_
:=
tracer
.
Extract
(
opentracing
.
HTTPHeaders
,
opentracing
.
HTTPHeadersCarrier
(
req
.
Header
))
spanName
:=
fmt
.
Sprintf
(
"HTTP %s"
,
handler
)
span
=
tracer
.
StartSpan
(
spanName
,
ext
.
RPCServerOption
(
wireContext
))
span
:=
tracer
.
StartSpan
(
fmt
.
Sprintf
(
"HTTP %s"
,
handler
),
ext
.
RPCServerOption
(
wireContext
))
defer
span
.
Finish
()
ctx
:=
opentracing
.
ContextWithSpan
(
req
.
Context
(),
span
)
...
...
pkg/tracing/tracing.go
View file @
ec29b469
...
...
@@ -3,6 +3,7 @@ package tracing
import
(
"io"
"io/ioutil"
"strings"
"github.com/grafana/grafana/pkg/log"
"github.com/grafana/grafana/pkg/setting"
...
...
@@ -15,7 +16,8 @@ import (
)
var
(
logger
log
.
Logger
=
log
.
New
(
"tracing"
)
logger
log
.
Logger
=
log
.
New
(
"tracing"
)
customTags
map
[
string
]
string
=
map
[
string
]
string
{}
)
type
TracingSettings
struct
{
...
...
@@ -41,6 +43,8 @@ func parseSettings(file *ini.File) *TracingSettings {
settings
.
Enabled
=
true
}
customTags
=
splitTagSettings
(
section
.
Key
(
"always_included_tag"
)
.
MustString
(
""
))
return
settings
}
...
...
@@ -63,10 +67,14 @@ func internalInit(settings *TracingSettings) (io.Closer, error) {
jLogger
:=
jaegerlog
.
StdLogger
tracer
,
closer
,
err
:=
cfg
.
New
(
"grafana"
,
jaegercfg
.
Logger
(
jLogger
),
)
options
:=
[]
jaegercfg
.
Option
{}
options
=
append
(
options
,
jaegercfg
.
Logger
(
jLogger
))
for
tag
,
value
:=
range
customTags
{
options
=
append
(
options
,
jaegercfg
.
Tag
(
tag
,
value
))
}
tracer
,
closer
,
err
:=
cfg
.
New
(
"grafana"
,
options
...
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -75,3 +83,17 @@ func internalInit(settings *TracingSettings) (io.Closer, error) {
opentracing
.
InitGlobalTracer
(
tracer
)
return
closer
,
nil
}
func
splitTagSettings
(
input
string
)
map
[
string
]
string
{
res
:=
map
[
string
]
string
{}
tags
:=
strings
.
Split
(
input
,
","
)
for
_
,
v
:=
range
tags
{
kv
:=
strings
.
Split
(
v
,
":"
)
if
len
(
kv
)
>
1
{
res
[
kv
[
0
]]
=
kv
[
1
]
}
}
return
res
}
pkg/tracing/tracing_test.go
0 → 100644
View file @
ec29b469
package
tracing
import
"testing"
func
TestGroupSplit
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
input
string
expected
map
[
string
]
string
}{
{
input
:
"tag1:value1,tag2:value2"
,
expected
:
map
[
string
]
string
{
"tag1"
:
"value1"
,
"tag2"
:
"value2"
,
},
},
{
input
:
""
,
expected
:
map
[
string
]
string
{},
},
{
input
:
"tag1"
,
expected
:
map
[
string
]
string
{},
},
}
for
_
,
test
:=
range
tests
{
tags
:=
splitTagSettings
(
test
.
input
)
for
k
,
v
:=
range
test
.
expected
{
value
,
exists
:=
tags
[
k
]
if
!
exists
||
value
!=
v
{
t
.
Errorf
(
"tags does not match %v "
,
test
)
}
}
}
}
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