Skip to content

Commit

Permalink
merge in master
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Day committed Jun 18, 2017
2 parents 6c727c8 + 24d30da commit 6e15c28
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
5 changes: 5 additions & 0 deletions core/span_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package core_test

import (
"encoding/json"
"os"

"github.com/Nordstrom/ctrace-go/core"
. "github.com/onsi/ginkgo"
Expand All @@ -20,6 +21,10 @@ var _ = Describe("Span", func() {
out map[string]interface{}
)

BeforeEach(func() {
os.Setenv("CTRACE_SERVICE_NAME", "")
})

Context("with Single-Event Mode", func() {
BeforeEach(func() {
buf.Reset()
Expand Down
30 changes: 30 additions & 0 deletions core/tracer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,36 @@ var _ = Describe("Tracer", func() {
})
})

Context("with ServiceName option", func() {
JustBeforeEach(func() {
buf.Reset()
trc = core.NewWithOptions(core.TracerOptions{Writer: &buf, MultiEvent: true, ServiceName: "tservice"})
})
It("outputs service tag", func() {
_ = trc.StartSpan("x")
if err := json.Unmarshal([]byte(buf.String()), &out); err != nil {
Fail("Cannot unmarshal JSON")
}
tags := out["tags"].(map[string]interface{})
Ω(tags["service"]).Should(Equal("tservice"))
})
})

Context("with ServiceName env variable", func() {
JustBeforeEach(func() {
buf.Reset()
os.Setenv("CTRACE_SERVICE_NAME", "eservice")
trc = core.NewWithOptions(core.TracerOptions{Writer: &buf, MultiEvent: true})
})
It("outputs service tag", func() {
_ = trc.StartSpan("x")
if err := json.Unmarshal([]byte(buf.String()), &out); err != nil {
Fail("Cannot unmarshal JSON")
}
tags := out["tags"].(map[string]interface{})
Ω(tags["service"]).Should(Equal("eservice"))
})
})
})

Context("with ServiceName option", func() {
Expand Down

0 comments on commit 6e15c28

Please sign in to comment.