Skip to content

Commit

Permalink
Merge pull request #981 from newrelic/master
Browse files Browse the repository at this point in the history
Update develop to be in sync with master
  • Loading branch information
nr-swilloughby authored Oct 25, 2024
2 parents aa932cf + 82c8f84 commit 4e0598e
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 3.35.1
### Fixed
- Security Agent Bug Hotfix: Do not update the security agent unti the go agent has completed its connect process [PR](https://github.com/newrelic/go-agent/pull/978)
- Faster Trace ID generation
- Community Member @ankon contributed [this change](https://github.com/newrelic/go-agent/pull/977)

### Support statement
We use the latest version of the Go language. At minimum, you should be using no version of Go older than what is supported by the Go team themselves.
See the [Go agent EOL Policy](/docs/apm/agents/go-agent/get-started/go-agent-eol-policy) for details about supported versions of the Go agent and third-party components.

## 3.35.0
### Added
- Enhanced security features (adds support for secure cookie even reporting)
Expand Down
15 changes: 12 additions & 3 deletions v3/internal/trace_id_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package internal

import (
"encoding/hex"
"math/rand"
"sync"
)
Expand Down Expand Up @@ -39,6 +38,10 @@ const (
maxIDByteLen = 16
)

const (
hextable = "0123456789abcdef"
)

// GenerateTraceID creates a new trace identifier, which is a 32 character hex string.
func (tg *TraceIDGenerator) GenerateTraceID() string {
return tg.generateID(traceIDByteLen)
Expand All @@ -50,9 +53,15 @@ func (tg *TraceIDGenerator) GenerateSpanID() string {
}

func (tg *TraceIDGenerator) generateID(len int) string {
var bits [maxIDByteLen]byte
var bits [maxIDByteLen * 2]byte
tg.Lock()
defer tg.Unlock()
tg.rnd.Read(bits[:len])
return hex.EncodeToString(bits[:len])

// In-place encode
for i := len - 1; i >= 0; i-- {
bits[i*2+1] = hextable[bits[i]&0x0f]
bits[i*2] = hextable[bits[i]>>4]
}
return string(bits[:len*2])
}
15 changes: 15 additions & 0 deletions v3/internal/trace_id_generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,18 @@ func BenchmarkTraceIDGenerator(b *testing.B) {
}
}
}

func BenchmarkTraceIDGeneratorParallel(b *testing.B) {
tg := NewTraceIDGenerator(12345)

b.ResetTimer()
b.ReportAllocs()

b.RunParallel(func(p *testing.PB) {
for p.Next() {
if id := tg.GenerateSpanID(); id == "" {
b.Fatal(id)
}
}
})
}
2 changes: 1 addition & 1 deletion v3/newrelic/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

const (
// Version is the full string version of this Go Agent.
Version = "3.35.0"
Version = "3.35.1"
)

var (
Expand Down

0 comments on commit 4e0598e

Please sign in to comment.