File tree Expand file tree Collapse file tree 3 files changed +36
-3
lines changed Expand file tree Collapse file tree 3 files changed +36
-3
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ import (
36
36
"github.com/coder/coder/provisionerd"
37
37
"github.com/coder/coder/provisionersdk"
38
38
"github.com/coder/coder/provisionersdk/proto"
39
- "gopkg.in/DataDog/dd-trace-go.v1/ddtrace /tracer"
39
+ "github.com/coder/coder /tracer"
40
40
)
41
41
42
42
func start () * cobra.Command {
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ import (
14
14
"github.com/coder/coder/httpapi"
15
15
"github.com/coder/coder/httpmw"
16
16
"github.com/coder/coder/site"
17
- chitrace "gopkg.in/DataDog/dd-trace-go.v1/contrib/go-chi/chi.v5 "
17
+ "github.com/coder/coder/tracer "
18
18
)
19
19
20
20
// Options are requires parameters for Coder to start.
@@ -42,7 +42,7 @@ func New(options *Options) (http.Handler, func()) {
42
42
43
43
r := chi .NewRouter ()
44
44
r .Route ("/api/v2" , func (r chi.Router ) {
45
- r .Use (chitrace .Middleware ())
45
+ r .Use (tracer .Middleware ())
46
46
r .Get ("/" , func (w http.ResponseWriter , r * http.Request ) {
47
47
httpapi .Write (w , http .StatusOK , httpapi.Response {
48
48
Message : "👋" ,
Original file line number Diff line number Diff line change
1
+ // Package tracer provides application tracing and performance monitoring utilities.
2
+ package tracer
3
+
4
+ import (
5
+ "net/http"
6
+
7
+ chitrace "gopkg.in/DataDog/dd-trace-go.v1/contrib/go-chi/chi.v5"
8
+ ddtracer "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"
9
+ )
10
+
11
+ // Starts the global tracer.
12
+ // Call as early as possible in the application to capture the most data.
13
+ // You must call Stop() to ensure all spans are properly flushed before exit.
14
+ //
15
+ // Common Usage:
16
+ //
17
+ // tracer.Start()
18
+ // defer tracer.Stop()
19
+ //
20
+ func Start () {
21
+ ddtracer .Start ()
22
+ }
23
+
24
+ // Stops the global tracer.
25
+ // Should be called at the end of the program to flush the remaining traces.
26
+ func Stop () {
27
+ ddtracer .Stop ()
28
+ }
29
+
30
+ // Middleware will wrap a trace span around the next http.Handler.
31
+ func Middleware () func (next http.Handler ) http.Handler {
32
+ return chitrace .Middleware ()
33
+ }
You can’t perform that action at this time.
0 commit comments