-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Initial tracing implementation
This adds the StartSpan function and related APIs to the SDK. The initial support focuses on manual instrumentation and HTTP servers based on net/http. Tracing is opt-in. Use one of the new options, TracesSampleRate or TracesSampler, when initializing the SDK to enable sending transactions and spans to Sentry. The tracing APIs rely heavily on the standard Context type from Go, and integrate with the SDKs notion of scopes. See example/http/main.go for an example of how the new APIs are meant to be used in practice. While the basic functionality should be in place, more features are planned for later.
- Loading branch information
1 parent
18aaf7e
commit 83afedf
Showing
16 changed files
with
1,005 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package randutil | ||
|
||
import ( | ||
"crypto/rand" | ||
"encoding/binary" | ||
) | ||
|
||
const ( | ||
floatMax = 1 << 53 | ||
floatMask = floatMax - 1 | ||
) | ||
|
||
// Float64 returns a cryptographically secure random number in [0.0, 1.0). | ||
func Float64() float64 { | ||
// The implementation is, in essence: | ||
// return float64(rand.Int63n(1<<53)) / (1<<53) | ||
b := make([]byte, 8) | ||
_, err := rand.Read(b) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return float64(binary.LittleEndian.Uint64(b)&floatMask) / floatMax | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package randutil | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestFloat64(t *testing.T) { | ||
const total = 1 << 24 | ||
for i := 0; i < total; i++ { | ||
n := Float64() | ||
if !(n >= 0 && n < 1) { | ||
t.Fatalf("out of range [0.0, 1.0): %f", n) | ||
} | ||
} | ||
// TODO: verify that distribution is uniform | ||
} |
Oops, something went wrong.