Skip to content

Commit dc40760

Browse files
authored
feat(collector): optimize telemetryapireceiver trace and span id generation (#2084)
1 parent 71b61a9 commit dc40760

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

collector/receiver/telemetryapireceiver/receiver.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ package telemetryapireceiver // import "github.com/open-telemetry/opentelemetry-
1717
import (
1818
"context"
1919
crand "crypto/rand"
20-
"encoding/binary"
2120
"encoding/json"
2221
"fmt"
2322
"io"
24-
"math/rand"
2523
"net/http"
2624
"os"
2725
"strconv"
@@ -104,20 +102,14 @@ func (r *telemetryAPIReceiver) Shutdown(ctx context.Context) error {
104102
}
105103

106104
func newSpanID() pcommon.SpanID {
107-
var rngSeed int64
108-
_ = binary.Read(crand.Reader, binary.LittleEndian, &rngSeed)
109-
randSource := rand.New(rand.NewSource(rngSeed))
110105
sid := pcommon.SpanID{}
111-
_, _ = randSource.Read(sid[:])
106+
_, _ = crand.Read(sid[:])
112107
return sid
113108
}
114109

115110
func newTraceID() pcommon.TraceID {
116-
var rngSeed int64
117-
_ = binary.Read(crand.Reader, binary.LittleEndian, &rngSeed)
118-
randSource := rand.New(rand.NewSource(rngSeed))
119111
tid := pcommon.TraceID{}
120-
_, _ = randSource.Read(tid[:])
112+
_, _ = crand.Read(tid[:])
121113
return tid
122114
}
123115

0 commit comments

Comments
 (0)