You've already forked opentelemetry-go
							
							
				mirror of
				https://github.com/open-telemetry/opentelemetry-go.git
				synced 2025-10-31 00:07:40 +02:00 
			
		
		
		
	Update SpanSnapshot to use parent SpanContext (#1748)
* Update SpanSnapshot to use parent SpanContext Having only the parent span ID and a separate field to communicate if the parent was remote does not provide a comprehensive view of the parent span nor is it an efficient way to transmit this information. Update the SpanSnapshot to have a `Parent` field that contains the parent span context. This field replaces the ParentSpanID and HasRemoteParent fields. * Revert SamplingParameters span change * Update CHANGELOG with PR number
This commit is contained in:
		| @@ -16,6 +16,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm | ||||
| - The storage of a local or remote Span in a `context.Context` using its SpanContext is unified to store just the current Span. | ||||
|   The Span's SpanContext can now self-identify as being remote or not. | ||||
|   This means that `"go.opentelemetry.io/otel/trace".ContextWithRemoteSpanContext` will now overwrite any existing current Span, not just existing remote Spans, and make it the current Span in a `context.Context`. (#1731) | ||||
| - Information about a parent span context in a `"go.opentelemetry.io/otel/export/trace".SpanSnapshot` is unified in a new `Parent` field. | ||||
|   The existing `ParentSpanID` and `HasRemoteParent` fields are removed in favor of this. (#1748) | ||||
|  | ||||
| ### Removed | ||||
|  | ||||
|   | ||||
| @@ -87,7 +87,11 @@ func SingleSpanSnapshot() []*exporttrace.SpanSnapshot { | ||||
| 			SpanID:     trace.SpanID{3, 4, 5, 6, 7, 8, 9, 0}, | ||||
| 			TraceFlags: trace.FlagsSampled, | ||||
| 		}), | ||||
| 		ParentSpanID:             trace.SpanID{1, 2, 3, 4, 5, 6, 7, 8}, | ||||
| 		Parent: trace.NewSpanContext(trace.SpanContextConfig{ | ||||
| 			TraceID:    trace.TraceID{2, 3, 4, 5, 6, 7, 8, 9, 2, 3, 4, 5, 6, 7, 8, 9}, | ||||
| 			SpanID:     trace.SpanID{1, 2, 3, 4, 5, 6, 7, 8}, | ||||
| 			TraceFlags: trace.FlagsSampled, | ||||
| 		}), | ||||
| 		SpanKind:                 trace.SpanKindInternal, | ||||
| 		Name:                     "foo", | ||||
| 		StartTime:                time.Date(2020, time.December, 8, 20, 23, 0, 0, time.UTC), | ||||
| @@ -97,7 +101,6 @@ func SingleSpanSnapshot() []*exporttrace.SpanSnapshot { | ||||
| 		Links:                    []trace.Link{}, | ||||
| 		StatusCode:               codes.Ok, | ||||
| 		StatusMessage:            "", | ||||
| 		HasRemoteParent:          false, | ||||
| 		DroppedAttributeCount:    0, | ||||
| 		DroppedMessageEventCount: 0, | ||||
| 		DroppedLinkCount:         0, | ||||
|   | ||||
| @@ -121,8 +121,8 @@ func span(sd *export.SpanSnapshot) *tracepb.Span { | ||||
| 		DroppedLinksCount:      uint32(sd.DroppedLinkCount), | ||||
| 	} | ||||
|  | ||||
| 	if sd.ParentSpanID.IsValid() { | ||||
| 		s.ParentSpanId = sd.ParentSpanID[:] | ||||
| 	if psid := sd.Parent.SpanID(); psid.IsValid() { | ||||
| 		s.ParentSpanId = psid[:] | ||||
| 	} | ||||
|  | ||||
| 	return s | ||||
|   | ||||
| @@ -205,8 +205,13 @@ func TestSpanData(t *testing.T) { | ||||
| 			SpanID:     trace.SpanID{0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8}, | ||||
| 			TraceState: traceState, | ||||
| 		}), | ||||
| 		Parent: trace.NewSpanContext(trace.SpanContextConfig{ | ||||
| 			TraceID:    trace.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F}, | ||||
| 			SpanID:     trace.SpanID{0xEF, 0xEE, 0xED, 0xEC, 0xEB, 0xEA, 0xE9, 0xE8}, | ||||
| 			TraceState: traceState, | ||||
| 			Remote:     true, | ||||
| 		}), | ||||
| 		SpanKind:  trace.SpanKindServer, | ||||
| 		ParentSpanID: trace.SpanID{0xEF, 0xEE, 0xED, 0xEC, 0xEB, 0xEA, 0xE9, 0xE8}, | ||||
| 		Name:      "span data to span data", | ||||
| 		StartTime: startTime, | ||||
| 		EndTime:   endTime, | ||||
| @@ -246,7 +251,6 @@ func TestSpanData(t *testing.T) { | ||||
| 		}, | ||||
| 		StatusCode:    codes.Error, | ||||
| 		StatusMessage: "utterly unrecognized", | ||||
| 		HasRemoteParent: true, | ||||
| 		Attributes: []attribute.KeyValue{ | ||||
| 			attribute.Int64("timeout_ns", 12e9), | ||||
| 		}, | ||||
|   | ||||
| @@ -104,7 +104,11 @@ func TestExportSpans(t *testing.T) { | ||||
| 						SpanID:     trace.SpanID([8]byte{0, 0, 0, 0, 0, 0, 0, 2}), | ||||
| 						TraceFlags: byte(1), | ||||
| 					}), | ||||
| 					ParentSpanID: trace.SpanID([8]byte{0, 0, 0, 0, 0, 0, 0, 1}), | ||||
| 					Parent: trace.NewSpanContext(trace.SpanContextConfig{ | ||||
| 						TraceID:    trace.TraceID([16]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}), | ||||
| 						SpanID:     trace.SpanID([8]byte{0, 0, 0, 0, 0, 0, 0, 1}), | ||||
| 						TraceFlags: byte(1), | ||||
| 					}), | ||||
| 					SpanKind:  trace.SpanKindInternal, | ||||
| 					Name:      "internal process", | ||||
| 					StartTime: startTime, | ||||
|   | ||||
| @@ -84,7 +84,13 @@ func TestExporter_ExportSpan(t *testing.T) { | ||||
| 		`"Key":"key",` + | ||||
| 		`"Value":{"Type":"STRING","Value":"val"}` + | ||||
| 		`}],"Remote":false},` + | ||||
| 		`"ParentSpanID":"0000000000000000",` + | ||||
| 		`"Parent":{` + | ||||
| 		`"TraceID":"00000000000000000000000000000000",` + | ||||
| 		`"SpanID":"0000000000000000",` + | ||||
| 		`"TraceFlags":0,` + | ||||
| 		`"TraceState":null,` + | ||||
| 		`"Remote":false` + | ||||
| 		`},` + | ||||
| 		`"SpanKind":1,` + | ||||
| 		`"Name":"/foo",` + | ||||
| 		`"StartTime":` + string(expectedSerializedNow) + "," + | ||||
| @@ -123,7 +129,6 @@ func TestExporter_ExportSpan(t *testing.T) { | ||||
| 		`"Links":null,` + | ||||
| 		`"StatusCode":"Error",` + | ||||
| 		`"StatusMessage":"interesting",` + | ||||
| 		`"HasRemoteParent":false,` + | ||||
| 		`"DroppedAttributeCount":0,` + | ||||
| 		`"DroppedMessageEventCount":0,` + | ||||
| 		`"DroppedLinkCount":0,` + | ||||
|   | ||||
| @@ -314,11 +314,12 @@ func spanSnapshotToThrift(ss *export.SpanSnapshot) *gen.Span { | ||||
|  | ||||
| 	tid := ss.SpanContext.TraceID() | ||||
| 	sid := ss.SpanContext.SpanID() | ||||
| 	psid := ss.Parent.SpanID() | ||||
| 	return &gen.Span{ | ||||
| 		TraceIdHigh:   int64(binary.BigEndian.Uint64(tid[0:8])), | ||||
| 		TraceIdLow:    int64(binary.BigEndian.Uint64(tid[8:16])), | ||||
| 		SpanId:        int64(binary.BigEndian.Uint64(sid[:])), | ||||
| 		ParentSpanId:  int64(binary.BigEndian.Uint64(ss.ParentSpanID[:])), | ||||
| 		ParentSpanId:  int64(binary.BigEndian.Uint64(psid[:])), | ||||
| 		OperationName: ss.Name, // TODO: if span kind is added then add prefix "Sent"/"Recv" | ||||
| 		Flags:         int32(ss.SpanContext.TraceFlags()), | ||||
| 		StartTime:     ss.StartTime.UnixNano() / 1000, | ||||
|   | ||||
| @@ -445,11 +445,14 @@ func Test_spanSnapshotToThrift(t *testing.T) { | ||||
| 		{ | ||||
| 			name: "with parent", | ||||
| 			data: &export.SpanSnapshot{ | ||||
| 				ParentSpanID: parentSpanID, | ||||
| 				SpanContext: trace.NewSpanContext(trace.SpanContextConfig{ | ||||
| 					TraceID: traceID, | ||||
| 					SpanID:  spanID, | ||||
| 				}), | ||||
| 				Parent: trace.NewSpanContext(trace.SpanContextConfig{ | ||||
| 					TraceID: traceID, | ||||
| 					SpanID:  parentSpanID, | ||||
| 				}), | ||||
| 				Links: []trace.Link{ | ||||
| 					{ | ||||
| 						SpanContext: trace.NewSpanContext(trace.SpanContextConfig{ | ||||
| @@ -499,11 +502,14 @@ func Test_spanSnapshotToThrift(t *testing.T) { | ||||
| 		{ | ||||
| 			name: "resources do not affect the tags", | ||||
| 			data: &export.SpanSnapshot{ | ||||
| 				ParentSpanID: parentSpanID, | ||||
| 				SpanContext: trace.NewSpanContext(trace.SpanContextConfig{ | ||||
| 					TraceID: traceID, | ||||
| 					SpanID:  spanID, | ||||
| 				}), | ||||
| 				Parent: trace.NewSpanContext(trace.SpanContextConfig{ | ||||
| 					TraceID: traceID, | ||||
| 					SpanID:  parentSpanID, | ||||
| 				}), | ||||
| 				Name:      "/foo", | ||||
| 				StartTime: now, | ||||
| 				EndTime:   now, | ||||
|   | ||||
| @@ -72,7 +72,7 @@ func toZipkinSpanContext(data *export.SpanSnapshot) zkmodel.SpanContext { | ||||
| 	return zkmodel.SpanContext{ | ||||
| 		TraceID:  toZipkinTraceID(data.SpanContext.TraceID()), | ||||
| 		ID:       toZipkinID(data.SpanContext.SpanID()), | ||||
| 		ParentID: toZipkinParentID(data.ParentSpanID), | ||||
| 		ParentID: toZipkinParentID(data.Parent.SpanID()), | ||||
| 		Debug:    false, | ||||
| 		Sampled:  nil, | ||||
| 		Err:      nil, | ||||
|   | ||||
| @@ -46,7 +46,10 @@ func TestModelConversion(t *testing.T) { | ||||
| 				TraceID: trace.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F}, | ||||
| 				SpanID:  trace.SpanID{0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8}, | ||||
| 			}), | ||||
| 			ParentSpanID: trace.SpanID{0x3F, 0x3E, 0x3D, 0x3C, 0x3B, 0x3A, 0x39, 0x38}, | ||||
| 			Parent: trace.NewSpanContext(trace.SpanContextConfig{ | ||||
| 				TraceID: trace.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F}, | ||||
| 				SpanID:  trace.SpanID{0x3F, 0x3E, 0x3D, 0x3C, 0x3B, 0x3A, 0x39, 0x38}, | ||||
| 			}), | ||||
| 			SpanKind:  trace.SpanKindServer, | ||||
| 			Name:      "foo", | ||||
| 			StartTime: time.Date(2020, time.March, 11, 19, 24, 0, 0, time.UTC), | ||||
| @@ -80,7 +83,6 @@ func TestModelConversion(t *testing.T) { | ||||
| 				TraceID: trace.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F}, | ||||
| 				SpanID:  trace.SpanID{0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8}, | ||||
| 			}), | ||||
| 			ParentSpanID: trace.SpanID{}, | ||||
| 			SpanKind:  trace.SpanKindServer, | ||||
| 			Name:      "foo", | ||||
| 			StartTime: time.Date(2020, time.March, 11, 19, 24, 0, 0, time.UTC), | ||||
| @@ -113,7 +115,10 @@ func TestModelConversion(t *testing.T) { | ||||
| 				TraceID: trace.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F}, | ||||
| 				SpanID:  trace.SpanID{0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8}, | ||||
| 			}), | ||||
| 			ParentSpanID: trace.SpanID{0x3F, 0x3E, 0x3D, 0x3C, 0x3B, 0x3A, 0x39, 0x38}, | ||||
| 			Parent: trace.NewSpanContext(trace.SpanContextConfig{ | ||||
| 				TraceID: trace.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F}, | ||||
| 				SpanID:  trace.SpanID{0x3F, 0x3E, 0x3D, 0x3C, 0x3B, 0x3A, 0x39, 0x38}, | ||||
| 			}), | ||||
| 			SpanKind:  trace.SpanKindUnspecified, | ||||
| 			Name:      "foo", | ||||
| 			StartTime: time.Date(2020, time.March, 11, 19, 24, 0, 0, time.UTC), | ||||
| @@ -146,7 +151,10 @@ func TestModelConversion(t *testing.T) { | ||||
| 				TraceID: trace.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F}, | ||||
| 				SpanID:  trace.SpanID{0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8}, | ||||
| 			}), | ||||
| 			ParentSpanID: trace.SpanID{0x3F, 0x3E, 0x3D, 0x3C, 0x3B, 0x3A, 0x39, 0x38}, | ||||
| 			Parent: trace.NewSpanContext(trace.SpanContextConfig{ | ||||
| 				TraceID: trace.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F}, | ||||
| 				SpanID:  trace.SpanID{0x3F, 0x3E, 0x3D, 0x3C, 0x3B, 0x3A, 0x39, 0x38}, | ||||
| 			}), | ||||
| 			SpanKind:  trace.SpanKindInternal, | ||||
| 			Name:      "foo", | ||||
| 			StartTime: time.Date(2020, time.March, 11, 19, 24, 0, 0, time.UTC), | ||||
| @@ -179,7 +187,10 @@ func TestModelConversion(t *testing.T) { | ||||
| 				TraceID: trace.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F}, | ||||
| 				SpanID:  trace.SpanID{0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8}, | ||||
| 			}), | ||||
| 			ParentSpanID: trace.SpanID{0x3F, 0x3E, 0x3D, 0x3C, 0x3B, 0x3A, 0x39, 0x38}, | ||||
| 			Parent: trace.NewSpanContext(trace.SpanContextConfig{ | ||||
| 				TraceID: trace.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F}, | ||||
| 				SpanID:  trace.SpanID{0x3F, 0x3E, 0x3D, 0x3C, 0x3B, 0x3A, 0x39, 0x38}, | ||||
| 			}), | ||||
| 			SpanKind:  trace.SpanKindClient, | ||||
| 			Name:      "foo", | ||||
| 			StartTime: time.Date(2020, time.March, 11, 19, 24, 0, 0, time.UTC), | ||||
| @@ -212,7 +223,10 @@ func TestModelConversion(t *testing.T) { | ||||
| 				TraceID: trace.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F}, | ||||
| 				SpanID:  trace.SpanID{0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8}, | ||||
| 			}), | ||||
| 			ParentSpanID: trace.SpanID{0x3F, 0x3E, 0x3D, 0x3C, 0x3B, 0x3A, 0x39, 0x38}, | ||||
| 			Parent: trace.NewSpanContext(trace.SpanContextConfig{ | ||||
| 				TraceID: trace.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F}, | ||||
| 				SpanID:  trace.SpanID{0x3F, 0x3E, 0x3D, 0x3C, 0x3B, 0x3A, 0x39, 0x38}, | ||||
| 			}), | ||||
| 			SpanKind:  trace.SpanKindProducer, | ||||
| 			Name:      "foo", | ||||
| 			StartTime: time.Date(2020, time.March, 11, 19, 24, 0, 0, time.UTC), | ||||
| @@ -245,7 +259,10 @@ func TestModelConversion(t *testing.T) { | ||||
| 				TraceID: trace.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F}, | ||||
| 				SpanID:  trace.SpanID{0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8}, | ||||
| 			}), | ||||
| 			ParentSpanID: trace.SpanID{0x3F, 0x3E, 0x3D, 0x3C, 0x3B, 0x3A, 0x39, 0x38}, | ||||
| 			Parent: trace.NewSpanContext(trace.SpanContextConfig{ | ||||
| 				TraceID: trace.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F}, | ||||
| 				SpanID:  trace.SpanID{0x3F, 0x3E, 0x3D, 0x3C, 0x3B, 0x3A, 0x39, 0x38}, | ||||
| 			}), | ||||
| 			SpanKind:  trace.SpanKindConsumer, | ||||
| 			Name:      "foo", | ||||
| 			StartTime: time.Date(2020, time.March, 11, 19, 24, 0, 0, time.UTC), | ||||
| @@ -278,7 +295,10 @@ func TestModelConversion(t *testing.T) { | ||||
| 				TraceID: trace.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F}, | ||||
| 				SpanID:  trace.SpanID{0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8}, | ||||
| 			}), | ||||
| 			ParentSpanID: trace.SpanID{0x3F, 0x3E, 0x3D, 0x3C, 0x3B, 0x3A, 0x39, 0x38}, | ||||
| 			Parent: trace.NewSpanContext(trace.SpanContextConfig{ | ||||
| 				TraceID: trace.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F}, | ||||
| 				SpanID:  trace.SpanID{0x3F, 0x3E, 0x3D, 0x3C, 0x3B, 0x3A, 0x39, 0x38}, | ||||
| 			}), | ||||
| 			SpanKind:  trace.SpanKindServer, | ||||
| 			Name:      "foo", | ||||
| 			StartTime: time.Date(2020, time.March, 11, 19, 24, 0, 0, time.UTC), | ||||
| @@ -298,7 +318,10 @@ func TestModelConversion(t *testing.T) { | ||||
| 				TraceID: trace.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F}, | ||||
| 				SpanID:  trace.SpanID{0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8}, | ||||
| 			}), | ||||
| 			ParentSpanID: trace.SpanID{0x3F, 0x3E, 0x3D, 0x3C, 0x3B, 0x3A, 0x39, 0x38}, | ||||
| 			Parent: trace.NewSpanContext(trace.SpanContextConfig{ | ||||
| 				TraceID: trace.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F}, | ||||
| 				SpanID:  trace.SpanID{0x3F, 0x3E, 0x3D, 0x3C, 0x3B, 0x3A, 0x39, 0x38}, | ||||
| 			}), | ||||
| 			SpanKind:  trace.SpanKindServer, | ||||
| 			Name:      "foo", | ||||
| 			StartTime: time.Date(2020, time.March, 11, 19, 24, 0, 0, time.UTC), | ||||
|   | ||||
| @@ -241,7 +241,6 @@ func TestExportSpans(t *testing.T) { | ||||
| 				TraceID: trace.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F}, | ||||
| 				SpanID:  trace.SpanID{0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8}, | ||||
| 			}), | ||||
| 			ParentSpanID:  trace.SpanID{}, | ||||
| 			SpanKind:      trace.SpanKindServer, | ||||
| 			Name:          "foo", | ||||
| 			StartTime:     time.Date(2020, time.March, 11, 19, 24, 0, 0, time.UTC), | ||||
| @@ -258,7 +257,10 @@ func TestExportSpans(t *testing.T) { | ||||
| 				TraceID: trace.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F}, | ||||
| 				SpanID:  trace.SpanID{0xDF, 0xDE, 0xDD, 0xDC, 0xDB, 0xDA, 0xD9, 0xD8}, | ||||
| 			}), | ||||
| 			ParentSpanID:  trace.SpanID{0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8}, | ||||
| 			Parent: trace.NewSpanContext(trace.SpanContextConfig{ | ||||
| 				TraceID: trace.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F}, | ||||
| 				SpanID:  trace.SpanID{0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8}, | ||||
| 			}), | ||||
| 			SpanKind:      trace.SpanKindServer, | ||||
| 			Name:          "bar", | ||||
| 			StartTime:     time.Date(2020, time.March, 11, 19, 24, 15, 0, time.UTC), | ||||
|   | ||||
| @@ -55,7 +55,7 @@ type SpanExporter interface { | ||||
| // the SpanSnapshot was created are NOT reflected in the SpanSnapshot. | ||||
| type SpanSnapshot struct { | ||||
| 	SpanContext trace.SpanContext | ||||
| 	ParentSpanID trace.SpanID | ||||
| 	Parent      trace.SpanContext | ||||
| 	SpanKind    trace.SpanKind | ||||
| 	Name        string | ||||
| 	StartTime   time.Time | ||||
| @@ -67,7 +67,6 @@ type SpanSnapshot struct { | ||||
| 	Links         []trace.Link | ||||
| 	StatusCode    codes.Code | ||||
| 	StatusMessage string | ||||
| 	HasRemoteParent bool | ||||
|  | ||||
| 	// DroppedAttributeCount contains dropped attributes for the span itself, events and links. | ||||
| 	DroppedAttributeCount    int | ||||
|   | ||||
| @@ -443,10 +443,9 @@ func (s *span) Snapshot() *export.SpanSnapshot { | ||||
|  | ||||
| 	sd.ChildSpanCount = s.childSpanCount | ||||
| 	sd.EndTime = s.endTime | ||||
| 	sd.HasRemoteParent = s.parent.IsRemote() | ||||
| 	sd.InstrumentationLibrary = s.instrumentationLibrary | ||||
| 	sd.Name = s.name | ||||
| 	sd.ParentSpanID = s.parent.SpanID() | ||||
| 	sd.Parent = s.parent | ||||
| 	sd.Resource = s.resource | ||||
| 	sd.SpanContext = s.spanContext | ||||
| 	sd.SpanKind = s.spanKind | ||||
|   | ||||
| @@ -58,6 +58,7 @@ func (s *storingHandler) Reset() { | ||||
| var ( | ||||
| 	tid trace.TraceID | ||||
| 	sid trace.SpanID | ||||
| 	sc  trace.SpanContext | ||||
|  | ||||
| 	handler *storingHandler = &storingHandler{} | ||||
|  | ||||
| @@ -68,6 +69,11 @@ var ( | ||||
| func init() { | ||||
| 	tid, _ = trace.TraceIDFromHex("01020304050607080102040810203040") | ||||
| 	sid, _ = trace.SpanIDFromHex("0102040810203040") | ||||
| 	sc = trace.NewSpanContext(trace.SpanContextConfig{ | ||||
| 		TraceID:    tid, | ||||
| 		SpanID:     sid, | ||||
| 		TraceFlags: 0x1, | ||||
| 	}) | ||||
|  | ||||
| 	k1 = attribute.Key("k1") | ||||
| 	kv1 = k1.String("v1") | ||||
| @@ -314,18 +320,13 @@ func TestStartSpanWithParent(t *testing.T) { | ||||
| 	tr := tp.Tracer("SpanWithParent") | ||||
| 	ctx := context.Background() | ||||
|  | ||||
| 	sc1 := trace.NewSpanContext(trace.SpanContextConfig{ | ||||
| 		TraceID:    tid, | ||||
| 		SpanID:     sid, | ||||
| 		TraceFlags: 0x1, | ||||
| 	}) | ||||
| 	_, s1 := tr.Start(trace.ContextWithRemoteSpanContext(ctx, sc1), "span1-unsampled-parent1") | ||||
| 	if err := checkChild(t, sc1, s1); err != nil { | ||||
| 	_, s1 := tr.Start(trace.ContextWithRemoteSpanContext(ctx, sc), "span1-unsampled-parent1") | ||||
| 	if err := checkChild(t, sc, s1); err != nil { | ||||
| 		t.Error(err) | ||||
| 	} | ||||
|  | ||||
| 	_, s2 := tr.Start(trace.ContextWithRemoteSpanContext(ctx, sc1), "span2-unsampled-parent1") | ||||
| 	if err := checkChild(t, sc1, s2); err != nil { | ||||
| 	_, s2 := tr.Start(trace.ContextWithRemoteSpanContext(ctx, sc), "span2-unsampled-parent1") | ||||
| 	if err := checkChild(t, sc, s2); err != nil { | ||||
| 		t.Error(err) | ||||
| 	} | ||||
|  | ||||
| @@ -333,12 +334,7 @@ func TestStartSpanWithParent(t *testing.T) { | ||||
| 	if err != nil { | ||||
| 		t.Error(err) | ||||
| 	} | ||||
| 	sc2 := trace.NewSpanContext(trace.SpanContextConfig{ | ||||
| 		TraceID:    tid, | ||||
| 		SpanID:     sid, | ||||
| 		TraceFlags: 0x1, | ||||
| 		TraceState: ts, | ||||
| 	}) | ||||
| 	sc2 := sc.WithTraceState(ts) | ||||
| 	_, s3 := tr.Start(trace.ContextWithRemoteSpanContext(ctx, sc2), "span3-sampled-parent2") | ||||
| 	if err := checkChild(t, sc2, s3); err != nil { | ||||
| 		t.Error(err) | ||||
| @@ -374,14 +370,13 @@ func TestSetSpanAttributesOnStart(t *testing.T) { | ||||
| 			TraceID:    tid, | ||||
| 			TraceFlags: 0x1, | ||||
| 		}), | ||||
| 		ParentSpanID: sid, | ||||
| 		Parent: sc.WithRemote(true), | ||||
| 		Name:   "span0", | ||||
| 		Attributes: []attribute.KeyValue{ | ||||
| 			attribute.String("key1", "value1"), | ||||
| 			attribute.String("key2", "value2"), | ||||
| 		}, | ||||
| 		SpanKind:               trace.SpanKindInternal, | ||||
| 		HasRemoteParent:        true, | ||||
| 		InstrumentationLibrary: instrumentation.Library{Name: "StartSpanAttribute"}, | ||||
| 	} | ||||
| 	if diff := cmpDiff(got, want); diff != "" { | ||||
| @@ -404,13 +399,12 @@ func TestSetSpanAttributes(t *testing.T) { | ||||
| 			TraceID:    tid, | ||||
| 			TraceFlags: 0x1, | ||||
| 		}), | ||||
| 		ParentSpanID: sid, | ||||
| 		Parent: sc.WithRemote(true), | ||||
| 		Name:   "span0", | ||||
| 		Attributes: []attribute.KeyValue{ | ||||
| 			attribute.String("key1", "value1"), | ||||
| 		}, | ||||
| 		SpanKind:               trace.SpanKindInternal, | ||||
| 		HasRemoteParent:        true, | ||||
| 		InstrumentationLibrary: instrumentation.Library{Name: "SpanAttribute"}, | ||||
| 	} | ||||
| 	if diff := cmpDiff(got, want); diff != "" { | ||||
| @@ -418,8 +412,6 @@ func TestSetSpanAttributes(t *testing.T) { | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Test that the sampler is called for local child spans. This is verified by checking | ||||
| // that the attributes set in the sampler are set on the child span. | ||||
| func TestSamplerAttributesLocalChildSpan(t *testing.T) { | ||||
| 	sampler := &testSampler{prefix: "span", t: t} | ||||
| 	te := NewTestExporter() | ||||
| @@ -433,55 +425,13 @@ func TestSamplerAttributesLocalChildSpan(t *testing.T) { | ||||
| 	span.End() | ||||
|  | ||||
| 	got := te.Spans() | ||||
|  | ||||
| 	// endSpan expects only a single span in the test exporter, so manually clear the | ||||
| 	// fields that can't be tested for easily (times, span and trace ids). | ||||
| 	pid := got[0].SpanContext.SpanID() | ||||
| 	got[0].SpanContext = got[0].SpanContext.WithTraceID(tid) | ||||
| 	got[0].ParentSpanID = sid | ||||
|  | ||||
| 	checkTime(&got[0].StartTime) | ||||
| 	checkTime(&got[0].EndTime) | ||||
|  | ||||
| 	got[1].SpanContext = got[1].SpanContext.WithSpanID(trace.SpanID{}) | ||||
| 	got[1].SpanContext = got[1].SpanContext.WithTraceID(tid) | ||||
| 	got[1].ParentSpanID = pid | ||||
| 	got[0].SpanContext = got[0].SpanContext.WithSpanID(trace.SpanID{}) | ||||
|  | ||||
| 	checkTime(&got[1].StartTime) | ||||
| 	checkTime(&got[1].EndTime) | ||||
|  | ||||
| 	want := []*export.SpanSnapshot{ | ||||
| 		{ | ||||
| 			SpanContext: trace.NewSpanContext(trace.SpanContextConfig{ | ||||
| 				TraceID:    tid, | ||||
| 				TraceFlags: 0x1, | ||||
| 			}), | ||||
| 			ParentSpanID:           sid, | ||||
| 			Name:                   "span1", | ||||
| 			Attributes:             []attribute.KeyValue{attribute.Int("callCount", 2)}, | ||||
| 			SpanKind:               trace.SpanKindInternal, | ||||
| 			HasRemoteParent:        false, | ||||
| 			InstrumentationLibrary: instrumentation.Library{Name: "SpanTwo"}, | ||||
| 		}, | ||||
| 		{ | ||||
| 			SpanContext: trace.NewSpanContext(trace.SpanContextConfig{ | ||||
| 				TraceID:    tid, | ||||
| 				TraceFlags: 0x1, | ||||
| 			}), | ||||
| 			ParentSpanID:           pid, | ||||
| 			Name:                   "span0", | ||||
| 			Attributes:             []attribute.KeyValue{attribute.Int("callCount", 1)}, | ||||
| 			SpanKind:               trace.SpanKindInternal, | ||||
| 			HasRemoteParent:        false, | ||||
| 			ChildSpanCount:         1, | ||||
| 			InstrumentationLibrary: instrumentation.Library{Name: "SpanOne"}, | ||||
| 		}, | ||||
| 	} | ||||
|  | ||||
| 	if diff := cmpDiff(got, want); diff != "" { | ||||
| 		t.Errorf("SetSpanAttributesLocalChildSpan: -got +want %s", diff) | ||||
| 	} | ||||
| 	require.Len(t, got, 2) | ||||
| 	// FILO order above means spanTwo <-> gotSpan0 and span <-> gotSpan1. | ||||
| 	gotSpan0, gotSpan1 := got[0], got[1] | ||||
| 	// Ensure sampler is called for local child spans by verifying the | ||||
| 	// attributes set by the sampler are set on the child span. | ||||
| 	assert.Equal(t, []attribute.KeyValue{attribute.Int("callCount", 2)}, gotSpan0.Attributes) | ||||
| 	assert.Equal(t, []attribute.KeyValue{attribute.Int("callCount", 1)}, gotSpan1.Attributes) | ||||
| } | ||||
|  | ||||
| func TestSetSpanAttributesOverLimit(t *testing.T) { | ||||
| @@ -505,14 +455,13 @@ func TestSetSpanAttributesOverLimit(t *testing.T) { | ||||
| 			TraceID:    tid, | ||||
| 			TraceFlags: 0x1, | ||||
| 		}), | ||||
| 		ParentSpanID: sid, | ||||
| 		Parent: sc.WithRemote(true), | ||||
| 		Name:   "span0", | ||||
| 		Attributes: []attribute.KeyValue{ | ||||
| 			attribute.Bool("key1", false), | ||||
| 			attribute.Int64("key4", 4), | ||||
| 		}, | ||||
| 		SpanKind:               trace.SpanKindInternal, | ||||
| 		HasRemoteParent:        true, | ||||
| 		DroppedAttributeCount:  1, | ||||
| 		InstrumentationLibrary: instrumentation.Library{Name: "SpanAttributesOverLimit"}, | ||||
| 	} | ||||
| @@ -540,13 +489,12 @@ func TestSetSpanAttributesWithInvalidKey(t *testing.T) { | ||||
| 			TraceID:    tid, | ||||
| 			TraceFlags: 0x1, | ||||
| 		}), | ||||
| 		ParentSpanID: sid, | ||||
| 		Parent: sc.WithRemote(true), | ||||
| 		Name:   "span0", | ||||
| 		Attributes: []attribute.KeyValue{ | ||||
| 			attribute.Bool("key1", false), | ||||
| 		}, | ||||
| 		SpanKind:               trace.SpanKindInternal, | ||||
| 		HasRemoteParent:        true, | ||||
| 		DroppedAttributeCount:  0, | ||||
| 		InstrumentationLibrary: instrumentation.Library{Name: "SpanToSetInvalidKeyOrValue"}, | ||||
| 	} | ||||
| @@ -585,9 +533,8 @@ func TestEvents(t *testing.T) { | ||||
| 			TraceID:    tid, | ||||
| 			TraceFlags: 0x1, | ||||
| 		}), | ||||
| 		ParentSpanID:    sid, | ||||
| 		Parent: sc.WithRemote(true), | ||||
| 		Name:   "span0", | ||||
| 		HasRemoteParent: true, | ||||
| 		MessageEvents: []trace.Event{ | ||||
| 			{Name: "foo", Attributes: []attribute.KeyValue{k1v1}}, | ||||
| 			{Name: "bar", Attributes: []attribute.KeyValue{k2v2, k3v3}}, | ||||
| @@ -635,14 +582,13 @@ func TestEventsOverLimit(t *testing.T) { | ||||
| 			TraceID:    tid, | ||||
| 			TraceFlags: 0x1, | ||||
| 		}), | ||||
| 		ParentSpanID: sid, | ||||
| 		Parent: sc.WithRemote(true), | ||||
| 		Name:   "span0", | ||||
| 		MessageEvents: []trace.Event{ | ||||
| 			{Name: "foo", Attributes: []attribute.KeyValue{k1v1}}, | ||||
| 			{Name: "bar", Attributes: []attribute.KeyValue{k2v2, k3v3}}, | ||||
| 		}, | ||||
| 		DroppedMessageEventCount: 2, | ||||
| 		HasRemoteParent:          true, | ||||
| 		SpanKind:                 trace.SpanKindInternal, | ||||
| 		InstrumentationLibrary:   instrumentation.Library{Name: "EventsOverLimit"}, | ||||
| 	} | ||||
| @@ -678,9 +624,8 @@ func TestLinks(t *testing.T) { | ||||
| 			TraceID:    tid, | ||||
| 			TraceFlags: 0x1, | ||||
| 		}), | ||||
| 		ParentSpanID:           sid, | ||||
| 		Parent:                 sc.WithRemote(true), | ||||
| 		Name:                   "span0", | ||||
| 		HasRemoteParent:        true, | ||||
| 		Links:                  links, | ||||
| 		SpanKind:               trace.SpanKindInternal, | ||||
| 		InstrumentationLibrary: instrumentation.Library{Name: "Links"}, | ||||
| @@ -720,14 +665,13 @@ func TestLinksOverLimit(t *testing.T) { | ||||
| 			TraceID:    tid, | ||||
| 			TraceFlags: 0x1, | ||||
| 		}), | ||||
| 		ParentSpanID: sid, | ||||
| 		Parent: sc.WithRemote(true), | ||||
| 		Name:   "span0", | ||||
| 		Links: []trace.Link{ | ||||
| 			{SpanContext: sc2, Attributes: []attribute.KeyValue{k2v2}}, | ||||
| 			{SpanContext: sc3, Attributes: []attribute.KeyValue{k3v3}}, | ||||
| 		}, | ||||
| 		DroppedLinkCount:       1, | ||||
| 		HasRemoteParent:        true, | ||||
| 		SpanKind:               trace.SpanKindInternal, | ||||
| 		InstrumentationLibrary: instrumentation.Library{Name: "LinksOverLimit"}, | ||||
| 	} | ||||
| @@ -742,11 +686,7 @@ func TestSetSpanName(t *testing.T) { | ||||
| 	ctx := context.Background() | ||||
|  | ||||
| 	want := "SpanName-1" | ||||
| 	ctx = trace.ContextWithRemoteSpanContext(ctx, trace.NewSpanContext(trace.SpanContextConfig{ | ||||
| 		TraceID:    tid, | ||||
| 		SpanID:     sid, | ||||
| 		TraceFlags: 1, | ||||
| 	})) | ||||
| 	ctx = trace.ContextWithRemoteSpanContext(ctx, sc) | ||||
| 	_, span := tp.Tracer("SetSpanName").Start(ctx, "SpanName-1") | ||||
| 	got, err := endSpan(te, span) | ||||
| 	if err != nil { | ||||
| @@ -774,12 +714,11 @@ func TestSetSpanStatus(t *testing.T) { | ||||
| 			TraceID:    tid, | ||||
| 			TraceFlags: 0x1, | ||||
| 		}), | ||||
| 		ParentSpanID:           sid, | ||||
| 		Parent:                 sc.WithRemote(true), | ||||
| 		Name:                   "span0", | ||||
| 		SpanKind:               trace.SpanKindInternal, | ||||
| 		StatusCode:             codes.Error, | ||||
| 		StatusMessage:          "Error", | ||||
| 		HasRemoteParent:        true, | ||||
| 		InstrumentationLibrary: instrumentation.Library{Name: "SpanStatus"}, | ||||
| 	} | ||||
| 	if diff := cmpDiff(got, want); diff != "" { | ||||
| @@ -803,12 +742,11 @@ func TestSetSpanStatusWithoutMessageWhenStatusIsNotError(t *testing.T) { | ||||
| 			TraceID:    tid, | ||||
| 			TraceFlags: 0x1, | ||||
| 		}), | ||||
| 		ParentSpanID:           sid, | ||||
| 		Parent:                 sc.WithRemote(true), | ||||
| 		Name:                   "span0", | ||||
| 		SpanKind:               trace.SpanKindInternal, | ||||
| 		StatusCode:             codes.Ok, | ||||
| 		StatusMessage:          "", | ||||
| 		HasRemoteParent:        true, | ||||
| 		InstrumentationLibrary: instrumentation.Library{Name: "SpanStatus"}, | ||||
| 	} | ||||
| 	if diff := cmpDiff(got, want); diff != "" { | ||||
| @@ -823,14 +761,6 @@ func cmpDiff(x, y interface{}) string { | ||||
| 		cmp.AllowUnexported(trace.TraceState{})) | ||||
| } | ||||
|  | ||||
| func remoteSpanContext() trace.SpanContext { | ||||
| 	return trace.NewSpanContext(trace.SpanContextConfig{ | ||||
| 		TraceID:    tid, | ||||
| 		SpanID:     sid, | ||||
| 		TraceFlags: 1, | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // checkChild is test utility function that tests that c has fields set appropriately, | ||||
| // given that it is a child span of p. | ||||
| func checkChild(t *testing.T, p trace.SpanContext, apiSpan trace.Span) error { | ||||
| @@ -863,10 +793,8 @@ func startSpan(tp *TracerProvider, trName string, args ...trace.SpanOption) trac | ||||
| // context contains TraceFlags with sampled bit set. This allows the | ||||
| // span to be automatically sampled. | ||||
| func startNamedSpan(tp *TracerProvider, trName, name string, args ...trace.SpanOption) trace.Span { | ||||
| 	ctx := context.Background() | ||||
| 	ctx = trace.ContextWithRemoteSpanContext(ctx, remoteSpanContext()) | ||||
| 	_, span := tp.Tracer(trName).Start( | ||||
| 		ctx, | ||||
| 		trace.ContextWithRemoteSpanContext(context.Background(), sc), | ||||
| 		name, | ||||
| 		args..., | ||||
| 	) | ||||
| @@ -958,7 +886,7 @@ func TestStartSpanAfterEnd(t *testing.T) { | ||||
| 	ctx := context.Background() | ||||
|  | ||||
| 	tr := tp.Tracer("SpanAfterEnd") | ||||
| 	ctx, span0 := tr.Start(trace.ContextWithRemoteSpanContext(ctx, remoteSpanContext()), "parent") | ||||
| 	ctx, span0 := tr.Start(trace.ContextWithRemoteSpanContext(ctx, sc), "parent") | ||||
| 	ctx1, span1 := tr.Start(ctx, "span-1") | ||||
| 	span1.End() | ||||
| 	// Start a new span with the context containing span-1 | ||||
| @@ -989,10 +917,10 @@ func TestStartSpanAfterEnd(t *testing.T) { | ||||
| 	if got, want := gotSpan2.SpanContext.TraceID(), gotParent.SpanContext.TraceID(); got != want { | ||||
| 		t.Errorf("span-2.TraceID=%q; want %q", got, want) | ||||
| 	} | ||||
| 	if got, want := gotSpan1.ParentSpanID, gotParent.SpanContext.SpanID(); got != want { | ||||
| 	if got, want := gotSpan1.Parent.SpanID(), gotParent.SpanContext.SpanID(); got != want { | ||||
| 		t.Errorf("span-1.ParentSpanID=%q; want %q (parent.SpanID)", got, want) | ||||
| 	} | ||||
| 	if got, want := gotSpan2.ParentSpanID, gotSpan1.SpanContext.SpanID(); got != want { | ||||
| 	if got, want := gotSpan2.Parent.SpanID(), gotSpan1.SpanContext.SpanID(); got != want { | ||||
| 		t.Errorf("span-2.ParentSpanID=%q; want %q (span1.SpanID)", got, want) | ||||
| 	} | ||||
| } | ||||
| @@ -1160,11 +1088,10 @@ func TestRecordError(t *testing.T) { | ||||
| 				TraceID:    tid, | ||||
| 				TraceFlags: 0x1, | ||||
| 			}), | ||||
| 			ParentSpanID:    sid, | ||||
| 			Parent:     sc.WithRemote(true), | ||||
| 			Name:       "span0", | ||||
| 			StatusCode: codes.Unset, | ||||
| 			SpanKind:   trace.SpanKindInternal, | ||||
| 			HasRemoteParent: true, | ||||
| 			MessageEvents: []trace.Event{ | ||||
| 				{ | ||||
| 					Name: errorEventName, | ||||
| @@ -1200,10 +1127,9 @@ func TestRecordErrorNil(t *testing.T) { | ||||
| 			TraceID:    tid, | ||||
| 			TraceFlags: 0x1, | ||||
| 		}), | ||||
| 		ParentSpanID:           sid, | ||||
| 		Parent:                 sc.WithRemote(true), | ||||
| 		Name:                   "span0", | ||||
| 		SpanKind:               trace.SpanKindInternal, | ||||
| 		HasRemoteParent:        true, | ||||
| 		StatusCode:             codes.Unset, | ||||
| 		StatusMessage:          "", | ||||
| 		InstrumentationLibrary: instrumentation.Library{Name: "RecordErrorNil"}, | ||||
| @@ -1298,13 +1224,12 @@ func TestWithResource(t *testing.T) { | ||||
| 					TraceID:    tid, | ||||
| 					TraceFlags: 0x1, | ||||
| 				}), | ||||
| 				ParentSpanID: sid, | ||||
| 				Parent: sc.WithRemote(true), | ||||
| 				Name:   "span0", | ||||
| 				Attributes: []attribute.KeyValue{ | ||||
| 					attribute.String("key1", "value1"), | ||||
| 				}, | ||||
| 				SpanKind:               trace.SpanKindInternal, | ||||
| 				HasRemoteParent:        true, | ||||
| 				Resource:               tc.want, | ||||
| 				InstrumentationLibrary: instrumentation.Library{Name: "WithResource"}, | ||||
| 			} | ||||
| @@ -1320,7 +1245,7 @@ func TestWithInstrumentationVersion(t *testing.T) { | ||||
| 	tp := NewTracerProvider(WithSyncer(te), WithResource(resource.Empty())) | ||||
|  | ||||
| 	ctx := context.Background() | ||||
| 	ctx = trace.ContextWithRemoteSpanContext(ctx, remoteSpanContext()) | ||||
| 	ctx = trace.ContextWithRemoteSpanContext(ctx, sc) | ||||
| 	_, span := tp.Tracer( | ||||
| 		"WithInstrumentationVersion", | ||||
| 		trace.WithInstrumentationVersion("v0.1.0"), | ||||
| @@ -1335,10 +1260,9 @@ func TestWithInstrumentationVersion(t *testing.T) { | ||||
| 			TraceID:    tid, | ||||
| 			TraceFlags: 0x1, | ||||
| 		}), | ||||
| 		ParentSpanID:    sid, | ||||
| 		Parent:   sc.WithRemote(true), | ||||
| 		Name:     "span0", | ||||
| 		SpanKind: trace.SpanKindInternal, | ||||
| 		HasRemoteParent: true, | ||||
| 		InstrumentationLibrary: instrumentation.Library{ | ||||
| 			Name:    "WithInstrumentationVersion", | ||||
| 			Version: "v0.1.0", | ||||
| @@ -1524,7 +1448,7 @@ func TestAddEventsWithMoreAttributesThanLimit(t *testing.T) { | ||||
| 			TraceID:    tid, | ||||
| 			TraceFlags: 0x1, | ||||
| 		}), | ||||
| 		ParentSpanID: sid, | ||||
| 		Parent:     sc.WithRemote(true), | ||||
| 		Name:       "span0", | ||||
| 		Attributes: nil, | ||||
| 		MessageEvents: []trace.Event{ | ||||
| @@ -1544,7 +1468,6 @@ func TestAddEventsWithMoreAttributesThanLimit(t *testing.T) { | ||||
| 			}, | ||||
| 		}, | ||||
| 		SpanKind:               trace.SpanKindInternal, | ||||
| 		HasRemoteParent:        true, | ||||
| 		DroppedAttributeCount:  2, | ||||
| 		InstrumentationLibrary: instrumentation.Library{Name: "AddSpanEventWithOverLimitedAttributes"}, | ||||
| 	} | ||||
| @@ -1584,9 +1507,8 @@ func TestAddLinksWithMoreAttributesThanLimit(t *testing.T) { | ||||
| 			TraceID:    tid, | ||||
| 			TraceFlags: 0x1, | ||||
| 		}), | ||||
| 		ParentSpanID:    sid, | ||||
| 		Parent: sc.WithRemote(true), | ||||
| 		Name:   "span0", | ||||
| 		HasRemoteParent: true, | ||||
| 		Links: []trace.Link{ | ||||
| 			{SpanContext: sc1, Attributes: []attribute.KeyValue{k1v1}}, | ||||
| 			{SpanContext: sc2, Attributes: []attribute.KeyValue{k2v2}}, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user