(traceID []byte, count int, startTime uint64, endTime uint64)
| 82 | } |
| 83 | |
| 84 | func makeSpanWithAttributeCount(traceID []byte, count int, startTime uint64, endTime uint64) *v1_trace.Span { |
| 85 | attributes := make([]*v1_common.KeyValue, 0, count) |
| 86 | for range count { |
| 87 | attributes = append(attributes, &v1_common.KeyValue{ |
| 88 | Key: RandomString(), |
| 89 | Value: &v1_common.AnyValue{Value: &v1_common.AnyValue_StringValue{StringValue: RandomString()}}, |
| 90 | }) |
| 91 | } |
| 92 | s := &v1_trace.Span{ |
| 93 | Name: "test", |
| 94 | TraceId: traceID, |
| 95 | SpanId: make([]byte, 8), |
| 96 | ParentSpanId: make([]byte, 8), |
| 97 | Kind: v1_trace.Span_SPAN_KIND_CLIENT, |
| 98 | Status: &v1_trace.Status{ |
| 99 | Code: 1, |
| 100 | Message: "OK", |
| 101 | }, |
| 102 | StartTimeUnixNano: startTime, |
| 103 | EndTimeUnixNano: endTime, |
| 104 | Attributes: attributes, |
| 105 | DroppedLinksCount: rand.Uint32(), // nolint:gosec // G404: Use of weak random number generator |
| 106 | DroppedAttributesCount: rand.Uint32(), // nolint:gosec // G404: Use of weak random number generator |
| 107 | } |
| 108 | _, err := crand.Read(s.SpanId) |
| 109 | if err != nil { |
| 110 | panic(err) |
| 111 | } |
| 112 | |
| 113 | // add link |
| 114 | if rand.Intn(5) == 0 { // nolint:gosec // G404: Use of weak random number generator |
| 115 | s.Links = append(s.Links, &v1_trace.Span_Link{ |
| 116 | TraceId: traceID, |
| 117 | SpanId: make([]byte, 8), |
| 118 | TraceState: "state", |
| 119 | Attributes: []*v1_common.KeyValue{ |
| 120 | { |
| 121 | Key: "linkkey", |
| 122 | Value: &v1_common.AnyValue{ |
| 123 | Value: &v1_common.AnyValue_StringValue{ |
| 124 | StringValue: "linkvalue", |
| 125 | }, |
| 126 | }, |
| 127 | }, |
| 128 | }, |
| 129 | }) |
| 130 | } |
| 131 | |
| 132 | // add attr |
| 133 | if rand.Intn(2) == 0 { // nolint:gosec // G404: Use of weak random number generator |
| 134 | s.Attributes = append(s.Attributes, &v1_common.KeyValue{ |
| 135 | Key: "key", |
| 136 | Value: &v1_common.AnyValue{ |
| 137 | Value: &v1_common.AnyValue_StringValue{ |
| 138 | StringValue: "value", |
| 139 | }, |
| 140 | }, |
| 141 | }) |
no test coverage detected