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
a234e894
Commit
a234e894
authored
Sep 11, 2017
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
makes jaeger tracing configurable
parent
f160ad3b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
91 additions
and
28 deletions
+91
-28
conf/defaults.ini
+5
-0
conf/sample.ini
+5
-0
pkg/cmd/grafana-server/server.go
+4
-28
pkg/tracing/tracing.go
+77
-0
No files found.
conf/defaults.ini
View file @
a234e894
...
...
@@ -452,6 +452,11 @@ url = https://grafana.com
[grafana_com]
url
=
https://grafana.com
#################################### Distributed tracing ############
[tracing.jaeger]
# jaeger destination (ex localhost:5775)
address
=
#################################### External Image Storage ##############
[external_image_storage]
# You can choose between (s3, webdav, gcs)
...
...
conf/sample.ini
View file @
a234e894
...
...
@@ -391,6 +391,11 @@
;address =
;prefix = prod.grafana.%(instance_name)s.
#################################### Distributed tracing ############
[tracing.jaeger]
# Enable by setting the address sending traces to jaeger (ex localhost:5775)
;address = localhost:5775
#################################### Grafana.com integration ##########################
# Url used to to import dashboards directly from Grafana.com
[grafana_com]
...
...
pkg/cmd/grafana-server/server.go
View file @
a234e894
...
...
@@ -24,10 +24,7 @@ import (
"github.com/grafana/grafana/pkg/services/search"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/social"
opentracing
"github.com/opentracing/opentracing-go"
jaeger
"github.com/uber/jaeger-client-go"
jaegercfg
"github.com/uber/jaeger-client-go/config"
jaegerlog
"github.com/uber/jaeger-client-go/log"
"github.com/grafana/grafana/pkg/tracing"
)
func
NewGrafanaServer
()
models
.
GrafanaServer
{
...
...
@@ -65,33 +62,12 @@ func (g *GrafanaServerImpl) Start() {
eventpublisher
.
Init
()
plugins
.
Init
()
//localhost:5775
cfg
:=
jaegercfg
.
Configuration
{
Disabled
:
false
,
Sampler
:
&
jaegercfg
.
SamplerConfig
{
Type
:
jaeger
.
SamplerTypeConst
,
Param
:
1
,
},
Reporter
:
&
jaegercfg
.
ReporterConfig
{
LogSpans
:
false
,
LocalAgentHostPort
:
"localhost:5775"
,
},
}
jLogger
:=
jaegerlog
.
StdLogger
tracer
,
closer
,
err
:=
cfg
.
New
(
"grafana"
,
jaegercfg
.
Logger
(
jLogger
),
)
closer
,
err
:=
tracing
.
Init
(
setting
.
Cfg
)
if
err
!=
nil
{
g
.
log
.
Error
(
"
tracing
"
,
"error"
,
err
)
g
.
log
.
Error
(
"
Tracing settings is not valid
"
,
"error"
,
err
)
g
.
Shutdown
(
1
,
"Startup failed"
)
return
}
opentracing
.
InitGlobalTracer
(
tracer
)
defer
closer
.
Close
()
// init alerting
...
...
@@ -104,7 +80,7 @@ func (g *GrafanaServerImpl) Start() {
cleanUpService
:=
cleanup
.
NewCleanUpService
()
g
.
childRoutines
.
Go
(
func
()
error
{
return
cleanUpService
.
Run
(
g
.
context
)
})
if
err
:
=
notifications
.
Init
();
err
!=
nil
{
if
err
=
notifications
.
Init
();
err
!=
nil
{
g
.
log
.
Error
(
"Notification service failed to initialize"
,
"error"
,
err
)
g
.
Shutdown
(
1
,
"Startup failed"
)
return
...
...
pkg/tracing/tracing.go
0 → 100644
View file @
a234e894
package
tracing
import
(
"io"
"io/ioutil"
"github.com/grafana/grafana/pkg/log"
"github.com/grafana/grafana/pkg/setting"
opentracing
"github.com/opentracing/opentracing-go"
jaeger
"github.com/uber/jaeger-client-go"
jaegercfg
"github.com/uber/jaeger-client-go/config"
jaegerlog
"github.com/uber/jaeger-client-go/log"
ini
"gopkg.in/ini.v1"
)
var
(
logger
log
.
Logger
=
log
.
New
(
"tracing"
)
)
type
TracingSettings
struct
{
Enabled
bool
Address
string
}
func
Init
(
file
*
ini
.
File
)
(
io
.
Closer
,
error
)
{
settings
:=
parseSettings
(
file
)
return
internalInit
(
settings
)
}
func
parseSettings
(
file
*
ini
.
File
)
*
TracingSettings
{
settings
:=
&
TracingSettings
{}
var
section
,
err
=
setting
.
Cfg
.
GetSection
(
"tracing.jaeger"
)
if
err
!=
nil
{
return
settings
}
settings
.
Address
=
section
.
Key
(
"address"
)
.
MustString
(
""
)
if
settings
.
Address
!=
""
{
settings
.
Enabled
=
true
}
return
settings
}
func
internalInit
(
settings
*
TracingSettings
)
(
io
.
Closer
,
error
)
{
if
!
settings
.
Enabled
{
return
ioutil
.
NopCloser
(
nil
),
nil
}
cfg
:=
jaegercfg
.
Configuration
{
Disabled
:
!
settings
.
Enabled
,
Sampler
:
&
jaegercfg
.
SamplerConfig
{
Type
:
jaeger
.
SamplerTypeConst
,
Param
:
1
,
},
Reporter
:
&
jaegercfg
.
ReporterConfig
{
LogSpans
:
false
,
LocalAgentHostPort
:
settings
.
Address
,
},
}
jLogger
:=
jaegerlog
.
StdLogger
tracer
,
closer
,
err
:=
cfg
.
New
(
"grafana"
,
jaegercfg
.
Logger
(
jLogger
),
)
if
err
!=
nil
{
return
nil
,
err
}
logger
.
Info
(
"Initialized jaeger tracer"
,
"address"
,
settings
.
Address
)
opentracing
.
InitGlobalTracer
(
tracer
)
return
closer
,
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