Skip to content
This repository has been archived by the owner on Aug 30, 2019. It is now read-only.

obfuscate: use strings.Builder from go1.10 #471

Merged
merged 2 commits into from
Sep 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
resource_class: large

docker:
- image: circleci/golang:1.9.4
- image: circleci/golang:1.10

steps:
- checkout
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ it manually.

## Development

First, make sure Go 1.9+ is installed. You can do this by following the steps on the [official website](https://golang.org/dl/).
First, make sure Go 1.10+ is installed. You can do this by following the steps on the [official website](https://golang.org/dl/).

Then, download (or update) the latest source by running:
```bash
Expand Down
2 changes: 1 addition & 1 deletion config/merge_ini.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func (c *AgentConfig) loadIniConfig(conf *File) {
for key, rate := range rates {
serviceName, operationName, err := parseServiceAndOp(key)
if err != nil {
log.Errorf("Error when parsing names", err)
log.Errorf("Error when parsing names: %v", err)
continue
}
rate, err := strconv.ParseFloat(rate, 64)
Expand Down
3 changes: 1 addition & 2 deletions obfuscate/json.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package obfuscate

import (
"bytes"
"strings"

"github.com/DataDog/datadog-trace-agent/config"
Expand Down Expand Up @@ -55,7 +54,7 @@ func (p *jsonObfuscator) setKey() {
}

func (p *jsonObfuscator) obfuscate(data []byte) (string, error) {
var out bytes.Buffer
var out strings.Builder
buf := make([]byte, 0, 10) // recording key token
p.scan.reset()
for _, c := range data {
Expand Down
7 changes: 3 additions & 4 deletions obfuscate/redis.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package obfuscate

import (
"bytes"
"strings"

"github.com/DataDog/datadog-trace-agent/model"
Expand All @@ -24,7 +23,7 @@ var redisCompoundCommandSet = map[string]bool{
func (*Obfuscator) quantizeRedis(span *model.Span) {
query := compactWhitespaces(span.Resource)

var resource bytes.Buffer
var resource strings.Builder
truncated := false
nbCmds := 0

Expand Down Expand Up @@ -91,7 +90,7 @@ func (*Obfuscator) obfuscateRedis(span *model.Span) {
}
t := newRedisTokenizer([]byte(span.Meta[redisRawCommand]))
var (
str bytes.Buffer
str strings.Builder
cmd string
args []string
)
Expand Down Expand Up @@ -119,7 +118,7 @@ func (*Obfuscator) obfuscateRedis(span *model.Span) {
span.Meta[redisRawCommand] = str.String()
}

func obfuscateRedisCmd(out *bytes.Buffer, cmd string, args ...string) {
func obfuscateRedisCmd(out *strings.Builder, cmd string, args ...string) {
out.WriteString(cmd)
if len(args) == 0 {
return
Expand Down
5 changes: 3 additions & 2 deletions obfuscate/redis_tokenizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package obfuscate

import (
"bytes"
"strings"
)

// redisTokenType specifies the token type returned by the tokenizer.
Expand Down Expand Up @@ -82,7 +83,7 @@ func (t *redisTokenizer) next() {
// scanCommand scans a command from the buffer.
func (t *redisTokenizer) scanCommand() (tok string, typ redisTokenType, done bool) {
var (
str bytes.Buffer
str strings.Builder
started bool
)
for {
Expand Down Expand Up @@ -113,7 +114,7 @@ func (t *redisTokenizer) scanCommand() (tok string, typ redisTokenType, done boo
// scanArg scans an argument from the buffer.
func (t *redisTokenizer) scanArg() (tok string, typ redisTokenType, done bool) {
var (
str bytes.Buffer
str strings.Builder
quoted bool // in quoted string
escape bool // escape sequence
)
Expand Down