Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add separators for large numbers #35100

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 pkg/trace/agent/truncator.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const (
// MaxMetaKeyLen the maximum length of metadata key
MaxMetaKeyLen = 200
// MaxMetaValLen the maximum length of metadata value
MaxMetaValLen = 25000
MaxMetaValLen = 25_000
// MaxMetricsKeyLen the maximum length of a metric name key
MaxMetricsKeyLen = MaxMetaKeyLen
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/trace/api/debug_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (ds *DebugServer) setupMux() *http.ServeMux {
ds.mux.HandleFunc("/debug/blockrate", func(w http.ResponseWriter, r *http.Request) {
// this endpoint calls runtime.SetBlockProfileRate(v), where v is an optional
// query string parameter defaulting to 10000 (1 sample per 10μs blocked).
rate := 10000
rate := 10_000
v := r.URL.Query().Get("v")
if v != "" {
n, err := strconv.Atoi(v)
Expand Down
2 changes: 1 addition & 1 deletion pkg/trace/api/otlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func (o *OTLPReceiver) processRequest(ctx context.Context, header http.Header, i
// Warning: do not change this number. It is shared with other probabilistic samplers
// in the agent, the Datadog libraries, and in OpenTelemetry. This ensures consistency
// in a distributed system.
const knuthFactor = uint64(1111111111111111111)
const knuthFactor = uint64(1_111_111_111_111_111_111)

// samplingRate returns the rate as defined by the probabilistic sampler.
func (o *OTLPReceiver) samplingRate() float64 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/trace/sampler/sampler.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const (
maxTraceID = ^uint64(0)
maxTraceIDFloat = float64(maxTraceID)
// Good number for Knuth hashing (large, prime, fit in int64 for languages without uint64)
samplerHasher = uint64(1111111111111111111)
samplerHasher = uint64(1_111_111_111_111_111_111)
)

// IsKeep returns whether the priority is "keep".
Expand Down
4 changes: 2 additions & 2 deletions pkg/trace/sampler/signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ func computeSpanHash(span *pb.Span, env string, withResource bool) spanHash {
type sum32a uint32

const (
offset32 = 2166136261
prime32 = 16777619
offset32 = 2_166_136_261
prime32 = 16_777_619
)

func new32a() sum32a {
Expand Down
2 changes: 1 addition & 1 deletion pkg/trace/testutil/otlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func setOTLPSpan(span ptrace.Span, s *OTLPSpan) {
span.SetStartTimestamp(pcommon.Timestamp(s.Start))
}
if s.End == 0 {
span.SetEndTimestamp(span.StartTimestamp() + 200000000)
span.SetEndTimestamp(span.StartTimestamp() + 200_000_000)
} else {
span.SetEndTimestamp(pcommon.Timestamp(s.End))
}
Expand Down
27 changes: 2 additions & 25 deletions pkg/trace/testutil/span.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,8 @@ func GetTestSpan() *pb.Span {
Service: "fennel_IS amazing!",
Name: "something &&<@# that should be a metric!",
Resource: "NOT touched because it is going to be hashed",
Start: 9223372036854775807,
Duration: 9223372036854775807,
Start: 9_223_372_036_854_775_807,
Duration: 9_223_372_036_854_775_807,
Meta: map[string]string{"http.host": "192.168.0.1"},
Metrics: map[string]float64{"http.monitor": 41.99},
SpanLinks: []*pb.SpanLink{
Expand All @@ -393,26 +393,3 @@ func GetTestSpan() *pb.Span {
traceutil.ComputeTopLevel(trace)
return trace[0]
}

// TestSpan returns a fix span with hardcoded info, useful for reproducible tests
func TestSpan() *pb.Span {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to remove this? Unused?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I'll update the description - yeah in modifying this code I noticed that this function was unused so removed it.

return &pb.Span{
Duration: 10000000,
Error: 0,
Resource: "GET /some/raclette",
Service: "django",
Name: "django.controller",
SpanID: 42,
Start: 1472732573337575936,
TraceID: 424242,
Meta: map[string]string{
"user": "leo",
"pool": "fondue",
},
Metrics: map[string]float64{
"cheese_weight": 100000.0,
},
ParentID: 1111,
Type: "http",
}
}
2 changes: 1 addition & 1 deletion pkg/trace/writer/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const defaultConnectionLimit = 5

// MaxPayloadSize specifies the maximum accumulated payload size that is allowed before
// a flush is triggered; replaced in tests.
var MaxPayloadSize = 3200000 // 3.2MB is the maximum allowed by the Datadog API
var MaxPayloadSize = 3_200_000 // 3.2MB is the maximum allowed by the Datadog API

type samplerTPSReader interface {
GetTargetTPS() float64
Expand Down