1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-08-10 22:31:50 +02:00

Add TraceState to SpanContext in API (#1340)

* Add TraceState to API

* Add tests for TraceState

* Update related tests

- stdout exporter test
- SDK test

* Update OTLP span transform

* Update CHANGELOG

* Change TraceState to struct instead of pointer

- Adjust tests for trace API
- Adjust adjacent parts of codebase (test utils, SDK etc.)

* Add methods to assert equality

- for type SpanContext, if SpanID, TraceID, TraceFlag and TraceState are
equal
- for type TraceState, if entries of both respective trace states are
equal

Signed-off-by: Matej Gera <matejgera@gmail.com>

* Copy values for new TraceState, adjust tests

* Use IsEqualWith in remaining tests instead of assertion func

* Further feedback, minor improvements

- Move IsEqualWith method to be only in test package
- Minor improvements, typos etc.

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
This commit is contained in:
Matej Gera
2020-12-21 22:11:48 +01:00
committed by GitHub
parent 35215264dc
commit 439cd31389
14 changed files with 573 additions and 64 deletions

View File

@@ -113,7 +113,7 @@ func TestExtractValidTraceContextFromHTTPReq(t *testing.T) {
ctx := context.Background()
ctx = prop.Extract(ctx, req.Header)
gotSc := trace.RemoteSpanContextFromContext(ctx)
if diff := cmp.Diff(gotSc, tt.wantSc); diff != "" {
if diff := cmp.Diff(gotSc, tt.wantSc, cmp.AllowUnexported(trace.TraceState{})); diff != "" {
t.Errorf("Extract Tracecontext: %s: -got +want %s", tt.name, diff)
}
})
@@ -201,7 +201,7 @@ func TestExtractInvalidTraceContextFromHTTPReq(t *testing.T) {
ctx := context.Background()
ctx = prop.Extract(ctx, req.Header)
gotSc := trace.RemoteSpanContextFromContext(ctx)
if diff := cmp.Diff(gotSc, wantSc); diff != "" {
if diff := cmp.Diff(gotSc, wantSc, cmp.AllowUnexported(trace.TraceState{})); diff != "" {
t.Errorf("Extract Tracecontext: %s: -got +want %s", tt.name, diff)
}
})