Skip to content

Commit

Permalink
Change trace_sample field to bool
Browse files Browse the repository at this point in the history
  • Loading branch information
Casper Kolkman authored and JeanMertz committed Nov 8, 2019
1 parent 6a3c767 commit 40e509e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package zapdriver

import (
"fmt"

"go.uber.org/zap"
"strconv"
)

const (
traceKey = "logging.googleapis.com/trace"
spanKey = "logging.googleapis.com/spanId"
traceKey = "logging.googleapis.com/trace"
spanKey = "logging.googleapis.com/spanId"
traceSampledKey = "logging.googleapis.com/trace_sampled"
)

Expand All @@ -19,6 +19,6 @@ func TraceContext(trace string, spanId string, sampled bool, projectName string)
return []zap.Field{
zap.String(traceKey, fmt.Sprintf("projects/%s/traces/%s", projectName, trace)),
zap.String(spanKey, spanId),
zap.String(traceSampledKey, strconv.FormatBool(sampled)),
zap.Bool(traceSampledKey, sampled),
}
}
5 changes: 3 additions & 2 deletions trace_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package zapdriver

import (
"testing"

"github.com/stretchr/testify/assert"
"go.uber.org/zap"
"testing"
)

func TestTraceContext(t *testing.T) {
Expand All @@ -13,6 +14,6 @@ func TestTraceContext(t *testing.T) {
assert.Equal(t, fields, []zap.Field{
zap.String(traceKey, "projects/my-project-name/traces/105445aa7843bc8bf206b120001000"),
zap.String(spanKey, "0"),
zap.String(traceSampledKey, "true"),
zap.Bool(traceSampledKey, true),
})
}

0 comments on commit 40e509e

Please sign in to comment.