| 1 |
// Copyright The OpenTelemetry Authors |
| 2 |
// SPDX-License-Identifier: Apache-2.0 |
| 3 |
|
| 4 |
package opentracing |
| 5 |
|
| 6 |
import ( |
| 7 |
"context" |
| 8 |
"fmt" |
| 9 |
"net/http" |
| 10 |
"reflect" |
| 11 |
"strconv" |
| 12 |
"strings" |
| 13 |
"testing" |
| 14 |
|
| 15 |
ot "github.com/opentracing/opentracing-go" |
| 16 |
"github.com/opentracing/opentracing-go/ext" |
| 17 |
otlog "github.com/opentracing/opentracing-go/log" |
| 18 |
"github.com/stretchr/testify/assert" |
| 19 |
"github.com/stretchr/testify/require" |
| 20 |
|
| 21 |
"go.opentelemetry.io/otel" |
| 22 |
"go.opentelemetry.io/otel/attribute" |
| 23 |
"go.opentelemetry.io/otel/propagation" |
| 24 |
"go.opentelemetry.io/otel/trace" |
| 25 |
) |
| 26 |
|
| 27 |
type testOnlyTextMapReader struct{} |
| 28 |
|
| 29 |
func newTestOnlyTextMapReader() *testOnlyTextMapReader { |
| 30 |
return &testOnlyTextMapReader{} |
| 31 |
} |
| 32 |
|
| 33 |
func (*testOnlyTextMapReader) ForeachKey(handler func(key, val string) error) error { |
| 34 |
_ = handler("key1", "val1") |
| 35 |
_ = handler("key2", "val2") |
| 36 |
|
| 37 |
return nil |
| 38 |
} |
| 39 |
|
| 40 |
type testOnlyTextMapWriter struct { |
| 41 |
m map[string]string |
| 42 |
} |
| 43 |
|
| 44 |
func newTestOnlyTextMapWriter() *testOnlyTextMapWriter { |
| 45 |
return &testOnlyTextMapWriter{m: map[string]string{}} |
| 46 |
} |
| 47 |
|
| 48 |
func (t *testOnlyTextMapWriter) Set(key, val string) { |
| 49 |
t.m[key] = val |
| 50 |
} |
| 51 |
|
| 52 |
type testTextMapReaderAndWriter struct { |
| 53 |
*testOnlyTextMapReader |
| 54 |
*testOnlyTextMapWriter |
| 55 |
} |
| 56 |
|
| 57 |
func newTestTextMapReaderAndWriter() *testTextMapReaderAndWriter { |
| 58 |
return &testTextMapReaderAndWriter{ |
| 59 |
testOnlyTextMapReader: newTestOnlyTextMapReader(), |
| 60 |
testOnlyTextMapWriter: newTestOnlyTextMapWriter(), |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
func TestTextMapWrapper_New(t *testing.T) { |
| 65 |
_, err := newTextMapWrapperForExtract(newTestOnlyTextMapReader()) |
| 66 |
assert.NoError(t, err) |
| 67 |
|
| 68 |
_, err = newTextMapWrapperForExtract(newTestOnlyTextMapWriter()) |
| 69 |
assert.ErrorIs(t, err, ot.ErrInvalidCarrier) |
| 70 |
|
| 71 |
_, err = newTextMapWrapperForExtract(newTestTextMapReaderAndWriter()) |
| 72 |
assert.NoError(t, err) |
| 73 |
|
| 74 |
_, err = newTextMapWrapperForInject(newTestOnlyTextMapWriter()) |
| 75 |
assert.NoError(t, err) |
| 76 |
|
| 77 |
_, err = newTextMapWrapperForInject(newTestOnlyTextMapReader()) |
| 78 |
assert.ErrorIs(t, err, ot.ErrInvalidCarrier) |
| 79 |
|
| 80 |
_, err = newTextMapWrapperForInject(newTestTextMapReaderAndWriter()) |
| 81 |
assert.NoError(t, err) |
| 82 |
} |
| 83 |
|
| 84 |
func TestTextMapWrapper_action(t *testing.T) { |
| 85 |
testExtractFunc := func(carrier propagation.TextMapCarrier) { |
| 86 |
str := carrier.Keys() |
| 87 |
assert.Len(t, str, 2) |
| 88 |
assert.Contains(t, str, "key1", "key2") |
| 89 |
|
| 90 |
assert.Equal(t, "val1", carrier.Get("key1")) |
| 91 |
assert.Equal(t, "val2", carrier.Get("key2")) |
| 92 |
} |
| 93 |
|
| 94 |
testInjectFunc := func(carrier propagation.TextMapCarrier) { |
| 95 |
carrier.Set("key1", "val1") |
| 96 |
carrier.Set("key2", "val2") |
| 97 |
|
| 98 |
wrap, ok := carrier.(*textMapWrapper) |
| 99 |
assert.True(t, ok) |
| 100 |
|
| 101 |
writer, ok := wrap.TextMapWriter.(*testOnlyTextMapWriter) |
| 102 |
if ok { |
| 103 |
assert.Contains(t, writer.m, "key1", "key2", "val1", "val2") |
| 104 |
return |
| 105 |
} |
| 106 |
|
| 107 |
writer2, ok := wrap.TextMapWriter.(*testTextMapReaderAndWriter) |
| 108 |
assert.True(t, ok) |
| 109 |
assert.Contains(t, writer2.m, "key1", "key2", "val1", "val2") |
| 110 |
} |
| 111 |
|
| 112 |
onlyWriter, err := newTextMapWrapperForExtract(newTestOnlyTextMapReader()) |
| 113 |
assert.NoError(t, err) |
| 114 |
testExtractFunc(onlyWriter) |
| 115 |
|
| 116 |
onlyReader, err := newTextMapWrapperForInject(&testOnlyTextMapWriter{m: map[string]string{}}) |
| 117 |
assert.NoError(t, err) |
| 118 |
testInjectFunc(onlyReader) |
| 119 |
|
| 120 |
both, err := newTextMapWrapperForExtract(newTestTextMapReaderAndWriter()) |
| 121 |
assert.NoError(t, err) |
| 122 |
testExtractFunc(both) |
| 123 |
|
| 124 |
both, err = newTextMapWrapperForInject(newTestTextMapReaderAndWriter()) |
| 125 |
assert.NoError(t, err) |
| 126 |
testInjectFunc(both) |
| 127 |
} |
| 128 |
|
| 129 |
var ( |
| 130 |
testHeader = "test-trace-id" |
| 131 |
traceID trace.TraceID = [16]byte{byte(10)} |
| 132 |
spanID trace.SpanID = [8]byte{byte(11)} |
| 133 |
) |
| 134 |
|
| 135 |
type testTextMapPropagator struct{} |
| 136 |
|
| 137 |
func (testTextMapPropagator) Inject(_ context.Context, carrier propagation.TextMapCarrier) { |
| 138 |
carrier.Set(testHeader, traceID.String()+":"+spanID.String()) |
| 139 |
|
| 140 |
// Test for panic |
| 141 |
_ = carrier.Get("test") |
| 142 |
_ = carrier.Keys() |
| 143 |
} |
| 144 |
|
| 145 |
func (testTextMapPropagator) Extract(ctx context.Context, carrier propagation.TextMapCarrier) context.Context { |
| 146 |
traces := carrier.Get(testHeader) |
| 147 |
|
| 148 |
str := strings.Split(traces, ":") |
| 149 |
if len(str) != 2 { |
| 150 |
return ctx |
| 151 |
} |
| 152 |
|
| 153 |
exist := false |
| 154 |
|
| 155 |
for _, key := range carrier.Keys() { |
| 156 |
if strings.EqualFold(testHeader, key) { |
| 157 |
exist = true |
| 158 |
|
| 159 |
break |
| 160 |
} |
| 161 |
} |
| 162 |
|
| 163 |
if !exist { |
| 164 |
return ctx |
| 165 |
} |
| 166 |
|
| 167 |
var ( |
| 168 |
traceID, _ = trace.TraceIDFromHex(str[0]) |
| 169 |
spanID, _ = trace.SpanIDFromHex(str[1]) |
| 170 |
sc = trace.NewSpanContext(trace.SpanContextConfig{ |
| 171 |
TraceID: traceID, |
| 172 |
SpanID: spanID, |
| 173 |
}) |
| 174 |
) |
| 175 |
|
| 176 |
// Test for panic |
| 177 |
carrier.Set("key", "val") |
| 178 |
|
| 179 |
return trace.ContextWithRemoteSpanContext(ctx, sc) |
| 180 |
} |
| 181 |
|
| 182 |
func (testTextMapPropagator) Fields() []string { |
| 183 |
return []string{"test"} |
| 184 |
} |
| 185 |
|
| 186 |
// textMapCarrier Implemented propagation.TextMapCarrier interface. |
| 187 |
type textMapCarrier struct { |
| 188 |
m map[string]string |
| 189 |
} |
| 190 |
|
| 191 |
var _ propagation.TextMapCarrier = (*textMapCarrier)(nil) |
| 192 |
|
| 193 |
func newTextCarrier() *textMapCarrier { |
| 194 |
return &textMapCarrier{m: map[string]string{}} |
| 195 |
} |
| 196 |
|
| 197 |
func (t *textMapCarrier) Get(key string) string { |
| 198 |
return t.m[key] |
| 199 |
} |
| 200 |
|
| 201 |
func (t *textMapCarrier) Set(key, value string) { |
| 202 |
t.m[key] = value |
| 203 |
} |
| 204 |
|
| 205 |
func (t *textMapCarrier) Keys() []string { |
| 206 |
str := make([]string, 0, len(t.m)) |
| 207 |
|
| 208 |
for key := range t.m { |
| 209 |
str = append(str, key) |
| 210 |
} |
| 211 |
|
| 212 |
return str |
| 213 |
} |
| 214 |
|
| 215 |
// testTextMapReader only implemented opentracing.TextMapReader interface. |
| 216 |
type testTextMapReader struct { |
| 217 |
m map[string]string |
| 218 |
} |
| 219 |
|
| 220 |
func newTestTextMapReader(m map[string]string) *testTextMapReader { |
| 221 |
return &testTextMapReader{m: m} |
| 222 |
} |
| 223 |
|
| 224 |
func (t *testTextMapReader) ForeachKey(handler func(key, val string) error) error { |
| 225 |
for key, val := range t.m { |
| 226 |
if err := handler(key, val); err != nil { |
| 227 |
return err |
| 228 |
} |
| 229 |
} |
| 230 |
|
| 231 |
return nil |
| 232 |
} |
| 233 |
|
| 234 |
// testTextMapWriter only implemented opentracing.TextMapWriter interface. |
| 235 |
type testTextMapWriter struct { |
| 236 |
m map[string]string |
| 237 |
} |
| 238 |
|
| 239 |
func newTestTextMapWriter(m map[string]string) *testTextMapWriter { |
| 240 |
return &testTextMapWriter{m: m} |
| 241 |
} |
| 242 |
|
| 243 |
func (t *testTextMapWriter) Set(key, val string) { |
| 244 |
t.m[key] = val |
| 245 |
} |
| 246 |
|
| 247 |
type samplable interface { |
| 248 |
IsSampled() bool |
| 249 |
} |
| 250 |
|
| 251 |
func TestBridgeTracer_ExtractAndInject(t *testing.T) { |
| 252 |
bridge := NewBridgeTracer() |
| 253 |
bridge.SetTextMapPropagator(new(testTextMapPropagator)) |
| 254 |
|
| 255 |
tmc := newTextCarrier() |
| 256 |
shareMap := map[string]string{} |
| 257 |
otTextMap := ot.TextMapCarrier{} |
| 258 |
httpHeader := ot.HTTPHeadersCarrier(http.Header{}) |
| 259 |
|
| 260 |
testCases := []struct { |
| 261 |
name string |
| 262 |
injectCarrierType ot.BuiltinFormat |
| 263 |
extractCarrierType ot.BuiltinFormat |
| 264 |
extractCarrier any |
| 265 |
injectCarrier any |
| 266 |
extractErr error |
| 267 |
injectErr error |
| 268 |
}{ |
| 269 |
{ |
| 270 |
name: "support for propagation.TextMapCarrier", |
| 271 |
injectCarrierType: ot.TextMap, |
| 272 |
injectCarrier: tmc, |
| 273 |
extractCarrierType: ot.TextMap, |
| 274 |
extractCarrier: tmc, |
| 275 |
}, |
| 276 |
{ |
| 277 |
name: "support for opentracing.TextMapReader and opentracing.TextMapWriter", |
| 278 |
injectCarrierType: ot.TextMap, |
| 279 |
injectCarrier: otTextMap, |
| 280 |
extractCarrierType: ot.TextMap, |
| 281 |
extractCarrier: otTextMap, |
| 282 |
}, |
| 283 |
{ |
| 284 |
name: "support for HTTPHeaders", |
| 285 |
injectCarrierType: ot.HTTPHeaders, |
| 286 |
injectCarrier: httpHeader, |
| 287 |
extractCarrierType: ot.HTTPHeaders, |
| 288 |
extractCarrier: httpHeader, |
| 289 |
}, |
| 290 |
{ |
| 291 |
name: "support for opentracing.TextMapReader and opentracing.TextMapWriter,non-same instance", |
| 292 |
injectCarrierType: ot.TextMap, |
| 293 |
injectCarrier: newTestTextMapWriter(shareMap), |
| 294 |
extractCarrierType: ot.TextMap, |
| 295 |
extractCarrier: newTestTextMapReader(shareMap), |
| 296 |
}, |
| 297 |
{ |
| 298 |
name: "inject: format type is HTTPHeaders, but carrier is not HTTPHeadersCarrier", |
| 299 |
injectCarrierType: ot.HTTPHeaders, |
| 300 |
injectCarrier: struct{}{}, |
| 301 |
injectErr: ot.ErrInvalidCarrier, |
| 302 |
}, |
| 303 |
{ |
| 304 |
name: "extract: format type is HTTPHeaders, but carrier is not HTTPHeadersCarrier", |
| 305 |
injectCarrierType: ot.HTTPHeaders, |
| 306 |
injectCarrier: httpHeader, |
| 307 |
extractCarrierType: ot.HTTPHeaders, |
| 308 |
extractCarrier: struct{}{}, |
| 309 |
extractErr: ot.ErrInvalidCarrier, |
| 310 |
}, |
| 311 |
{ |
| 312 |
name: "inject: format type is TextMap, but carrier is cannot be wrapped into propagation.TextMapCarrier", |
| 313 |
injectCarrierType: ot.TextMap, |
| 314 |
injectCarrier: struct{}{}, |
| 315 |
injectErr: ot.ErrInvalidCarrier, |
| 316 |
}, |
| 317 |
{ |
| 318 |
name: "extract: format type is TextMap, but carrier is cannot be wrapped into propagation.TextMapCarrier", |
| 319 |
injectCarrierType: ot.TextMap, |
| 320 |
injectCarrier: otTextMap, |
| 321 |
extractCarrierType: ot.TextMap, |
| 322 |
extractCarrier: struct{}{}, |
| 323 |
extractErr: ot.ErrInvalidCarrier, |
| 324 |
}, |
| 325 |
{ |
| 326 |
name: "inject: unsupported format type", |
| 327 |
injectCarrierType: ot.Binary, |
| 328 |
injectErr: ot.ErrUnsupportedFormat, |
| 329 |
}, |
| 330 |
{ |
| 331 |
name: "extract: unsupported format type", |
| 332 |
injectCarrierType: ot.TextMap, |
| 333 |
injectCarrier: otTextMap, |
| 334 |
extractCarrierType: ot.Binary, |
| 335 |
extractCarrier: struct{}{}, |
| 336 |
extractErr: ot.ErrUnsupportedFormat, |
| 337 |
}, |
| 338 |
} |
| 339 |
|
| 340 |
for _, tc := range testCases { |
| 341 |
t.Run(tc.name, func(t *testing.T) { |
| 342 |
err := bridge.Inject(newBridgeSpanContext(trace.NewSpanContext(trace.SpanContextConfig{ |
| 343 |
TraceID: [16]byte{byte(1)}, |
| 344 |
SpanID: [8]byte{byte(2)}, |
| 345 |
}), nil), tc.injectCarrierType, tc.injectCarrier) |
| 346 |
assert.Equal(t, tc.injectErr, err) |
| 347 |
|
| 348 |
if tc.injectErr == nil { |
| 349 |
spanContext, err := bridge.Extract(tc.extractCarrierType, tc.extractCarrier) |
| 350 |
assert.Equal(t, tc.extractErr, err) |
| 351 |
|
| 352 |
if tc.extractErr == nil { |
| 353 |
bsc, ok := spanContext.(*bridgeSpanContext) |
| 354 |
assert.True(t, ok) |
| 355 |
require.NotNil(t, bsc) |
| 356 |
require.NotNil(t, bsc.SpanContext) |
| 357 |
require.NotNil(t, bsc.SpanID()) |
| 358 |
require.NotNil(t, bsc.TraceID()) |
| 359 |
|
| 360 |
assert.Equal(t, spanID.String(), bsc.SpanID().String()) |
| 361 |
assert.Equal(t, traceID.String(), bsc.TraceID().String()) |
| 362 |
} |
| 363 |
} |
| 364 |
}) |
| 365 |
} |
| 366 |
} |
| 367 |
|
| 368 |
type nonDeferWrapperTracer struct { |
| 369 |
*WrapperTracer |
| 370 |
} |
| 371 |
|
| 372 |
func (t *nonDeferWrapperTracer) Start( |
| 373 |
_ context.Context, |
| 374 |
name string, |
| 375 |
opts ...trace.SpanStartOption, |
| 376 |
) (context.Context, trace.Span) { |
| 377 |
// Run start on the parent wrapper with a brand new context |
| 378 |
// so `WithDeferredSetup` hasn't been called, and the OpenTracing context is injected. |
| 379 |
return t.WrapperTracer.Start(context.Background(), name, opts...) |
| 380 |
} |
| 381 |
|
| 382 |
func TestBridgeTracer_StartSpan(t *testing.T) { |
| 383 |
testCases := []struct { |
| 384 |
name string |
| 385 |
before func(*testing.T, *BridgeTracer) |
| 386 |
expectWarnings []string |
| 387 |
}{ |
| 388 |
{ |
| 389 |
name: "with no option set", |
| 390 |
expectWarnings: []string{ |
| 391 |
"The OpenTelemetry tracer is not set, default no-op tracer is used! Call SetOpenTelemetryTracer to set it up.\n", |
| 392 |
}, |
| 393 |
}, |
| 394 |
{ |
| 395 |
name: "with wrapper tracer set", |
| 396 |
before: func(_ *testing.T, bridge *BridgeTracer) { |
| 397 |
wTracer := NewWrapperTracer(bridge, otel.Tracer("test")) |
| 398 |
bridge.SetOpenTelemetryTracer(wTracer) |
| 399 |
}, |
| 400 |
expectWarnings: []string(nil), |
| 401 |
}, |
| 402 |
{ |
| 403 |
name: "with a non-deferred wrapper tracer", |
| 404 |
before: func(_ *testing.T, bridge *BridgeTracer) { |
| 405 |
wTracer := &nonDeferWrapperTracer{ |
| 406 |
NewWrapperTracer(bridge, otel.Tracer("test")), |
| 407 |
} |
| 408 |
bridge.SetOpenTelemetryTracer(wTracer) |
| 409 |
}, |
| 410 |
expectWarnings: []string{ |
| 411 |
"SDK should have deferred the context setup, see the documentation of go.opentelemetry.io/otel/bridge/opentracing/migration\n", |
| 412 |
}, |
| 413 |
}, |
| 414 |
} |
| 415 |
|
| 416 |
for _, tc := range testCases { |
| 417 |
t.Run(tc.name, func(t *testing.T) { |
| 418 |
var warningMessages []string |
| 419 |
bridge := NewBridgeTracer() |
| 420 |
bridge.SetWarningHandler(func(msg string) { |
| 421 |
warningMessages = append(warningMessages, msg) |
| 422 |
}) |
| 423 |
|
| 424 |
if tc.before != nil { |
| 425 |
tc.before(t, bridge) |
| 426 |
} |
| 427 |
|
| 428 |
span := bridge.StartSpan("test") |
| 429 |
assert.NotNil(t, span) |
| 430 |
|
| 431 |
assert.Equal(t, tc.expectWarnings, warningMessages) |
| 432 |
}) |
| 433 |
} |
| 434 |
} |
| 435 |
|
| 436 |
func Test_otTagToOTelAttr(t *testing.T) { |
| 437 |
key := attribute.Key("test") |
| 438 |
testCases := []struct { |
| 439 |
value any |
| 440 |
expected attribute.KeyValue |
| 441 |
}{ |
| 442 |
{ |
| 443 |
value: int8(12), |
| 444 |
expected: key.Int64(int64(12)), |
| 445 |
}, |
| 446 |
{ |
| 447 |
value: uint8(12), |
| 448 |
expected: key.Int64(int64(12)), |
| 449 |
}, |
| 450 |
{ |
| 451 |
value: int16(12), |
| 452 |
expected: key.Int64(int64(12)), |
| 453 |
}, |
| 454 |
{ |
| 455 |
value: uint16(12), |
| 456 |
expected: key.Int64(int64(12)), |
| 457 |
}, |
| 458 |
} |
| 459 |
|
| 460 |
for _, tc := range testCases { |
| 461 |
t.Run(fmt.Sprintf("%s %v", reflect.TypeOf(tc.value), tc.value), func(t *testing.T) { |
| 462 |
att := otTagToOTelAttr(string(key), tc.value) |
| 463 |
assert.Equal(t, tc.expected, att) |
| 464 |
}) |
| 465 |
} |
| 466 |
} |
| 467 |
|
| 468 |
func TestBridgeSpan_SetTag(t *testing.T) { |
| 469 |
tracer := newMockTracer() |
| 470 |
b, _ := NewTracerPair(tracer) |
| 471 |
|
| 472 |
testCases := []struct { |
| 473 |
name string |
| 474 |
tagKey string |
| 475 |
tagValue any |
| 476 |
expected any |
| 477 |
}{ |
| 478 |
{ |
| 479 |
name: "basic string key / value", |
| 480 |
tagKey: "key", |
| 481 |
tagValue: "value", |
| 482 |
expected: attribute.String("key", "value"), |
| 483 |
}, |
| 484 |
{ |
| 485 |
name: "tag SpanKind no attribute", |
| 486 |
tagKey: "span.kind", |
| 487 |
tagValue: "value", |
| 488 |
expected: nil, |
| 489 |
}, |
| 490 |
{ |
| 491 |
name: "Error with bool value and set status code 1", |
| 492 |
tagKey: "error", |
| 493 |
tagValue: true, |
| 494 |
expected: attribute.Int64("status.code", 1), |
| 495 |
}, |
| 496 |
{ |
| 497 |
name: "Error with bool but we don't set status code", |
| 498 |
tagKey: "error", |
| 499 |
tagValue: false, |
| 500 |
expected: nil, |
| 501 |
}, |
| 502 |
{ |
| 503 |
name: "Error with non-bool type but we don't set status code", |
| 504 |
tagKey: "error", |
| 505 |
tagValue: "false", |
| 506 |
expected: nil, |
| 507 |
}, |
| 508 |
} |
| 509 |
|
| 510 |
for _, tc := range testCases { |
| 511 |
t.Run(tc.name, func(t *testing.T) { |
| 512 |
span := b.StartSpan("test") |
| 513 |
|
| 514 |
span.SetTag(tc.tagKey, tc.tagValue) |
| 515 |
mockSpan := span.(*bridgeSpan).otelSpan.(*mockSpan) |
| 516 |
if tc.expected != nil { |
| 517 |
assert.Contains(t, mockSpan.Attributes, tc.expected) |
| 518 |
} else { |
| 519 |
assert.Nil(t, mockSpan.Attributes) |
| 520 |
} |
| 521 |
}) |
| 522 |
} |
| 523 |
} |
| 524 |
|
| 525 |
func Test_otTagsToOTelAttributesKindAndError(t *testing.T) { |
| 526 |
tracer := newMockTracer() |
| 527 |
sc := &bridgeSpanContext{} |
| 528 |
|
| 529 |
testCases := []struct { |
| 530 |
name string |
| 531 |
opt []ot.StartSpanOption |
| 532 |
expected trace.SpanKind |
| 533 |
}{ |
| 534 |
{ |
| 535 |
name: "client", |
| 536 |
opt: []ot.StartSpanOption{ext.SpanKindRPCClient}, |
| 537 |
expected: trace.SpanKindClient, |
| 538 |
}, |
| 539 |
{ |
| 540 |
name: "server", |
| 541 |
opt: []ot.StartSpanOption{ext.RPCServerOption(sc)}, |
| 542 |
expected: trace.SpanKindServer, |
| 543 |
}, |
| 544 |
{ |
| 545 |
name: "client string", |
| 546 |
opt: []ot.StartSpanOption{ot.Tag{Key: "span.kind", Value: "client"}}, |
| 547 |
expected: trace.SpanKindClient, |
| 548 |
}, |
| 549 |
{ |
| 550 |
name: "server string", |
| 551 |
opt: []ot.StartSpanOption{ot.Tag{Key: "span.kind", Value: "server"}}, |
| 552 |
expected: trace.SpanKindServer, |
| 553 |
}, |
| 554 |
} |
| 555 |
|
| 556 |
for _, tc := range testCases { |
| 557 |
t.Run(tc.name, func(t *testing.T) { |
| 558 |
b, _ := NewTracerPair(tracer) |
| 559 |
|
| 560 |
s := b.StartSpan(tc.name, tc.opt...) |
| 561 |
assert.Equal(t, tc.expected, s.(*bridgeSpan).otelSpan.(*mockSpan).SpanKind) |
| 562 |
}) |
| 563 |
} |
| 564 |
} |
| 565 |
|
| 566 |
func TestBridge_SpanContext_IsSampled(t *testing.T) { |
| 567 |
testCases := []struct { |
| 568 |
name string |
| 569 |
flags trace.TraceFlags |
| 570 |
expected bool |
| 571 |
}{ |
| 572 |
{ |
| 573 |
name: "not sampled", |
| 574 |
flags: 0, |
| 575 |
expected: false, |
| 576 |
}, |
| 577 |
{ |
| 578 |
name: "sampled", |
| 579 |
flags: trace.FlagsSampled, |
| 580 |
expected: true, |
| 581 |
}, |
| 582 |
} |
| 583 |
|
| 584 |
for _, tc := range testCases { |
| 585 |
t.Run(tc.name, func(t *testing.T) { |
| 586 |
tracer := newMockTracer() |
| 587 |
tracer.TraceFlags = tc.flags |
| 588 |
|
| 589 |
b, _ := NewTracerPair(tracer) |
| 590 |
s := b.StartSpan("abc") |
| 591 |
sc := s.Context() |
| 592 |
|
| 593 |
assert.Equal(t, tc.expected, sc.(samplable).IsSampled()) |
| 594 |
}) |
| 595 |
} |
| 596 |
} |
| 597 |
|
| 598 |
func TestBridgeSpanContextPromotedMethods(t *testing.T) { |
| 599 |
bridge := NewBridgeTracer() |
| 600 |
bridge.SetTextMapPropagator(new(testTextMapPropagator)) |
| 601 |
|
| 602 |
tmc := newTextCarrier() |
| 603 |
|
| 604 |
type spanContextProvider interface { |
| 605 |
HasTraceID() bool |
| 606 |
TraceID() trace.TraceID |
| 607 |
HasSpanID() bool |
| 608 |
SpanID() trace.SpanID |
| 609 |
} |
| 610 |
|
| 611 |
err := bridge.Inject(newBridgeSpanContext(trace.NewSpanContext(trace.SpanContextConfig{ |
| 612 |
TraceID: [16]byte{byte(1)}, |
| 613 |
SpanID: [8]byte{byte(2)}, |
| 614 |
}), nil), ot.TextMap, tmc) |
| 615 |
assert.NoError(t, err) |
| 616 |
|
| 617 |
spanContext, err := bridge.Extract(ot.TextMap, tmc) |
| 618 |
assert.NoError(t, err) |
| 619 |
|
| 620 |
assert.NotPanics(t, func() { |
| 621 |
assert.Equal(t, spanID.String(), spanContext.(spanContextProvider).SpanID().String()) |
| 622 |
assert.Equal(t, traceID.String(), spanContext.(spanContextProvider).TraceID().String()) |
| 623 |
assert.True(t, spanContext.(spanContextProvider).HasSpanID()) |
| 624 |
assert.True(t, spanContext.(spanContextProvider).HasTraceID()) |
| 625 |
}) |
| 626 |
} |
| 627 |
|
| 628 |
func TestBridgeCarrierBaggagePropagation(t *testing.T) { |
| 629 |
carriers := []struct { |
| 630 |
name string |
| 631 |
factory func() any |
| 632 |
format ot.BuiltinFormat |
| 633 |
}{ |
| 634 |
{ |
| 635 |
name: "TextMapCarrier", |
| 636 |
factory: func() any { return ot.TextMapCarrier{} }, |
| 637 |
format: ot.TextMap, |
| 638 |
}, |
| 639 |
{ |
| 640 |
name: "HTTPHeadersCarrier", |
| 641 |
factory: func() any { return ot.HTTPHeadersCarrier{} }, |
| 642 |
format: ot.HTTPHeaders, |
| 643 |
}, |
| 644 |
} |
| 645 |
|
| 646 |
testCases := []struct { |
| 647 |
name string |
| 648 |
baggageItems []bipBaggage |
| 649 |
}{ |
| 650 |
{ |
| 651 |
name: "single baggage item", |
| 652 |
baggageItems: []bipBaggage{ |
| 653 |
{ |
| 654 |
key: "foo", |
| 655 |
value: "bar", |
| 656 |
}, |
| 657 |
}, |
| 658 |
}, |
| 659 |
{ |
| 660 |
name: "multiple baggage items", |
| 661 |
baggageItems: []bipBaggage{ |
| 662 |
{ |
| 663 |
key: "foo", |
| 664 |
value: "bar", |
| 665 |
}, |
| 666 |
{ |
| 667 |
key: "foo2", |
| 668 |
value: "bar2", |
| 669 |
}, |
| 670 |
}, |
| 671 |
}, |
| 672 |
{ |
| 673 |
name: "with characters escaped by baggage propagator", |
| 674 |
baggageItems: []bipBaggage{ |
| 675 |
{ |
| 676 |
key: "space", |
| 677 |
value: "Hello world!", |
| 678 |
}, |
| 679 |
{ |
| 680 |
key: "utf8", |
| 681 |
value: "Świat", |
| 682 |
}, |
| 683 |
}, |
| 684 |
}, |
| 685 |
} |
| 686 |
|
| 687 |
for _, c := range carriers { |
| 688 |
for _, tc := range testCases { |
| 689 |
t.Run(fmt.Sprintf("%s %s", c.name, tc.name), func(t *testing.T) { |
| 690 |
mockOtelTracer := newMockTracer() |
| 691 |
b, _ := NewTracerPair(mockOtelTracer) |
| 692 |
b.SetTextMapPropagator(propagation.NewCompositeTextMapPropagator( |
| 693 |
propagation.TraceContext{}, |
| 694 |
propagation.Baggage{}), // Required for baggage propagation. |
| 695 |
) |
| 696 |
|
| 697 |
// Set baggage items. |
| 698 |
span := b.StartSpan("test") |
| 699 |
for _, bi := range tc.baggageItems { |
| 700 |
span.SetBaggageItem(bi.key, bi.value) |
| 701 |
} |
| 702 |
defer span.Finish() |
| 703 |
|
| 704 |
carrier := c.factory() |
| 705 |
err := b.Inject(span.Context(), c.format, carrier) |
| 706 |
assert.NoError(t, err) |
| 707 |
|
| 708 |
spanContext, err := b.Extract(c.format, carrier) |
| 709 |
assert.NoError(t, err) |
| 710 |
|
| 711 |
// Check baggage items. |
| 712 |
bsc, ok := spanContext.(*bridgeSpanContext) |
| 713 |
assert.True(t, ok) |
| 714 |
|
| 715 |
var got []bipBaggage |
| 716 |
for _, m := range bsc.bag.Members() { |
| 717 |
got = append(got, bipBaggage{m.Key(), m.Value()}) |
| 718 |
} |
| 719 |
|
| 720 |
assert.ElementsMatch(t, tc.baggageItems, got) |
| 721 |
}) |
| 722 |
} |
| 723 |
} |
| 724 |
} |
| 725 |
|
| 726 |
func TestBridgeFiledEncoder(t *testing.T) { |
| 727 |
t.Run("emit string", func(t *testing.T) { |
| 728 |
encoder := &bridgeFieldEncoder{} |
| 729 |
encoder.EmitString("stringKey", "bar") |
| 730 |
assert.Equal(t, attribute.String("stringKey", "bar"), encoder.pairs[0]) |
| 731 |
}) |
| 732 |
|
| 733 |
t.Run("emit bool", func(t *testing.T) { |
| 734 |
encoder := &bridgeFieldEncoder{} |
| 735 |
encoder.EmitBool("boolKey", true) |
| 736 |
assert.Equal(t, attribute.Bool("boolKey", true), encoder.pairs[0]) |
| 737 |
}) |
| 738 |
|
| 739 |
t.Run("emit int", func(t *testing.T) { |
| 740 |
encoder := &bridgeFieldEncoder{} |
| 741 |
encoder.EmitInt("intKey", 123) |
| 742 |
assert.Equal(t, attribute.Int("intKey", 123), encoder.pairs[0]) |
| 743 |
}) |
| 744 |
|
| 745 |
t.Run("emit int32", func(t *testing.T) { |
| 746 |
encoder := &bridgeFieldEncoder{} |
| 747 |
encoder.EmitInt32("int32Key", int32(123)) |
| 748 |
assert.Equal(t, attribute.Int("int32Key", 123), encoder.pairs[0]) |
| 749 |
}) |
| 750 |
|
| 751 |
t.Run("emit int64", func(t *testing.T) { |
| 752 |
encoder := &bridgeFieldEncoder{} |
| 753 |
encoder.EmitInt64("int64Key", int64(123)) |
| 754 |
assert.Equal(t, attribute.Int("int64Key", 123), encoder.pairs[0]) |
| 755 |
}) |
| 756 |
|
| 757 |
t.Run("emit uint32", func(t *testing.T) { |
| 758 |
encoder := &bridgeFieldEncoder{} |
| 759 |
encoder.EmitUint32("uint32Key", uint32(123)) |
| 760 |
assert.Equal(t, attribute.Int64("uint32Key", 123), encoder.pairs[0]) |
| 761 |
}) |
| 762 |
|
| 763 |
t.Run("emit uint64", func(t *testing.T) { |
| 764 |
encoder := &bridgeFieldEncoder{} |
| 765 |
encoder.EmitUint64("uint64Key", uint64(123)) |
| 766 |
assert.Equal(t, attribute.String("uint64Key", strconv.FormatUint(123, 10)), encoder.pairs[0]) |
| 767 |
}) |
| 768 |
|
| 769 |
t.Run("emit float32", func(t *testing.T) { |
| 770 |
encoder := &bridgeFieldEncoder{} |
| 771 |
encoder.EmitFloat32("float32Key", float32(1.1)) |
| 772 |
attr := encoder.pairs[0] |
| 773 |
assert.InDelta(t, float32(1.1), attr.Value.AsFloat64(), 0.0001) |
| 774 |
}) |
| 775 |
|
| 776 |
t.Run("emit float64", func(t *testing.T) { |
| 777 |
encoder := &bridgeFieldEncoder{} |
| 778 |
encoder.EmitFloat64("float64Key", 1.1) |
| 779 |
assert.Equal(t, attribute.Float64("float64Key", 1.1), encoder.pairs[0]) |
| 780 |
}) |
| 781 |
|
| 782 |
t.Run("emit object", func(t *testing.T) { |
| 783 |
encoder := &bridgeFieldEncoder{} |
| 784 |
encoder.EmitObject("objectKey", struct{}{}) |
| 785 |
assert.Equal(t, attribute.String("objectKey", "{}"), encoder.pairs[0]) |
| 786 |
}) |
| 787 |
|
| 788 |
t.Run("emit logger", func(t *testing.T) { |
| 789 |
encoder := &bridgeFieldEncoder{} |
| 790 |
called := false |
| 791 |
encoder.EmitLazyLogger(func(oe otlog.Encoder) { |
| 792 |
called = true |
| 793 |
oe.EmitString("lazy", "value") |
| 794 |
}) |
| 795 |
assert.True(t, called) |
| 796 |
assert.Equal(t, attribute.String("lazy", "value"), encoder.pairs[0]) |
| 797 |
}) |
| 798 |
} |
| 799 |
|
| 800 |
func TestBridgeSpan_LogFields(t *testing.T) { |
| 801 |
testCases := []struct { |
| 802 |
name string |
| 803 |
field otlog.Field |
| 804 |
expected attribute.KeyValue |
| 805 |
}{ |
| 806 |
{ |
| 807 |
name: "string", |
| 808 |
field: otlog.String("stringKey", "bar"), |
| 809 |
expected: attribute.String("stringKey", "bar"), |
| 810 |
}, |
| 811 |
{ |
| 812 |
name: "bool", |
| 813 |
field: otlog.Bool("boolKey", true), |
| 814 |
expected: attribute.Bool("boolKey", true), |
| 815 |
}, |
| 816 |
{ |
| 817 |
name: "int", |
| 818 |
field: otlog.Int("intKey", 12), |
| 819 |
expected: attribute.Int("intKey", 12), |
| 820 |
}, |
| 821 |
{ |
| 822 |
name: "int32", |
| 823 |
field: otlog.Int32("int32Key", int32(12)), |
| 824 |
expected: attribute.Int64("int32Key", 12), |
| 825 |
}, |
| 826 |
{ |
| 827 |
name: "int64", |
| 828 |
field: otlog.Int64("int64Key", int64(12)), |
| 829 |
expected: attribute.Int64("int64Key", 12), |
| 830 |
}, |
| 831 |
|
| 832 |
{ |
| 833 |
name: "uint32", |
| 834 |
field: otlog.Uint32("uint32Key", uint32(12)), |
| 835 |
expected: attribute.Int64("uint32Key", 12), |
| 836 |
}, |
| 837 |
{ |
| 838 |
name: "uint64", |
| 839 |
field: otlog.Uint64("uint64Key", uint64(12)), |
| 840 |
expected: attribute.String("uint64Key", strconv.FormatUint(12, 10)), |
| 841 |
}, |
| 842 |
{ |
| 843 |
name: "float32", |
| 844 |
field: otlog.Float32("float32", float32(1)), |
| 845 |
expected: attribute.Float64("float32", float64(1)), |
| 846 |
}, |
| 847 |
{ |
| 848 |
name: "float64", |
| 849 |
field: otlog.Float64("float64", 1.1), |
| 850 |
expected: attribute.Float64("float64", 1.1), |
| 851 |
}, |
| 852 |
{ |
| 853 |
name: "error", |
| 854 |
field: otlog.Error(fmt.Errorf("error")), |
| 855 |
expected: attribute.String("error.object", "error"), |
| 856 |
}, |
| 857 |
{ |
| 858 |
name: "object", |
| 859 |
field: otlog.Object("object", struct{}{}), |
| 860 |
expected: attribute.String("object", "{}"), |
| 861 |
}, |
| 862 |
{ |
| 863 |
name: "event", |
| 864 |
field: otlog.Event("eventValue"), |
| 865 |
expected: attribute.String("event", "eventValue"), |
| 866 |
}, |
| 867 |
{ |
| 868 |
name: "message", |
| 869 |
field: otlog.Message("messageValue"), |
| 870 |
expected: attribute.String("message", "messageValue"), |
| 871 |
}, |
| 872 |
{ |
| 873 |
name: "lazyLog", |
| 874 |
field: otlog.Lazy(func(fv otlog.Encoder) { |
| 875 |
fv.EmitBool("bool", true) |
| 876 |
}), |
| 877 |
expected: attribute.Bool("bool", true), |
| 878 |
}, |
| 879 |
} |
| 880 |
|
| 881 |
for _, tc := range testCases { |
| 882 |
t.Run(tc.name, func(t *testing.T) { |
| 883 |
tracer := newMockTracer() |
| 884 |
b, _ := NewTracerPair(tracer) |
| 885 |
span := b.StartSpan("test") |
| 886 |
|
| 887 |
span.LogFields(tc.field) |
| 888 |
mockSpan := span.(*bridgeSpan).otelSpan.(*mockSpan) |
| 889 |
event := mockSpan.Events[0] |
| 890 |
assert.Contains(t, event.Attributes, tc.expected) |
| 891 |
}) |
| 892 |
} |
| 893 |
} |
| 894 |
|
| 895 |
func TestBridgeSpan_LogKV(t *testing.T) { |
| 896 |
testCases := []struct { |
| 897 |
name string |
| 898 |
kv [2]any |
| 899 |
expected attribute.KeyValue |
| 900 |
}{ |
| 901 |
{ |
| 902 |
name: "string", |
| 903 |
kv: [2]any{"string", "value"}, |
| 904 |
expected: attribute.String("string", "value"), |
| 905 |
}, |
| 906 |
{ |
| 907 |
name: "bool", |
| 908 |
kv: [2]any{"boolKey", true}, |
| 909 |
expected: attribute.Bool("boolKey", true), |
| 910 |
}, |
| 911 |
{ |
| 912 |
name: "int", |
| 913 |
kv: [2]any{"intKey", int(12)}, |
| 914 |
expected: attribute.Int("intKey", 12), |
| 915 |
}, |
| 916 |
{ |
| 917 |
name: "int8", |
| 918 |
kv: [2]any{"int8Key", int8(12)}, |
| 919 |
expected: attribute.Int64("int8Key", 12), |
| 920 |
}, |
| 921 |
{ |
| 922 |
name: "int16", |
| 923 |
kv: [2]any{"int16Key", int16(12)}, |
| 924 |
expected: attribute.Int64("int16Key", 12), |
| 925 |
}, |
| 926 |
{ |
| 927 |
name: "int32", |
| 928 |
kv: [2]any{"int32", int32(12)}, |
| 929 |
expected: attribute.Int64("int32", 12), |
| 930 |
}, |
| 931 |
{ |
| 932 |
name: "int64", |
| 933 |
kv: [2]any{"int64Key", int64(12)}, |
| 934 |
expected: attribute.Int64("int64Key", 12), |
| 935 |
}, |
| 936 |
{ |
| 937 |
name: "uint", |
| 938 |
kv: [2]any{"uintKey", uint(12)}, |
| 939 |
expected: attribute.String("uintKey", strconv.FormatUint(12, 10)), |
| 940 |
}, |
| 941 |
{ |
| 942 |
name: "uint8", |
| 943 |
kv: [2]any{"uint8Key", uint8(12)}, |
| 944 |
expected: attribute.Int64("uint8Key", 12), |
| 945 |
}, |
| 946 |
{ |
| 947 |
name: "uint16", |
| 948 |
kv: [2]any{"uint16Key", uint16(12)}, |
| 949 |
expected: attribute.Int64("uint16Key", 12), |
| 950 |
}, |
| 951 |
{ |
| 952 |
name: "uint32", |
| 953 |
kv: [2]any{"uint32Key", uint32(12)}, |
| 954 |
expected: attribute.Int64("uint32Key", 12), |
| 955 |
}, |
| 956 |
{ |
| 957 |
name: "uint64", |
| 958 |
kv: [2]any{"uint64Key", uint64(12)}, |
| 959 |
expected: attribute.String("uint64Key", strconv.FormatUint(12, 10)), |
| 960 |
}, |
| 961 |
{ |
| 962 |
name: "float32", |
| 963 |
kv: [2]any{"float32Key", float32(12)}, |
| 964 |
expected: attribute.Float64("float32Key", float64(12)), |
| 965 |
}, |
| 966 |
{ |
| 967 |
name: "float64", |
| 968 |
kv: [2]any{"float64Key", 1.1}, |
| 969 |
expected: attribute.Float64("float64Key", 1.1), |
| 970 |
}, |
| 971 |
{ |
| 972 |
name: "error", |
| 973 |
kv: [2]any{"errorKey", fmt.Errorf("error")}, |
| 974 |
expected: attribute.String("errorKey", "error"), |
| 975 |
}, |
| 976 |
{ |
| 977 |
name: "objectKey", |
| 978 |
kv: [2]any{"objectKey", struct{}{}}, |
| 979 |
expected: attribute.String("objectKey", "{}"), |
| 980 |
}, |
| 981 |
} |
| 982 |
|
| 983 |
for _, tc := range testCases { |
| 984 |
t.Run(tc.name, func(t *testing.T) { |
| 985 |
tracer := newMockTracer() |
| 986 |
b, _ := NewTracerPair(tracer) |
| 987 |
span := b.StartSpan("test") |
| 988 |
span.LogKV(tc.kv[0], tc.kv[1]) |
| 989 |
mockSpan := span.(*bridgeSpan).otelSpan.(*mockSpan) |
| 990 |
event := mockSpan.Events[0] |
| 991 |
assert.Contains(t, event.Attributes, tc.expected) |
| 992 |
}) |
| 993 |
} |
| 994 |
} |
| 995 |
|
| 996 |
func TestBridgeSpan_BaggageItem(t *testing.T) { |
| 997 |
tracer := NewBridgeTracer() |
| 998 |
|
| 999 |
span := tracer.StartSpan("span") |
| 1000 |
|
| 1001 |
assert.Empty(t, span.BaggageItem("invalid-key")) |
| 1002 |
|
| 1003 |
span.SetBaggageItem("key", "val") |
| 1004 |
|
| 1005 |
assert.Equal(t, "val", span.BaggageItem("key")) |
| 1006 |
assert.Equal(t, 1, span.Context().(*bridgeSpanContext).bag.Len()) |
| 1007 |
assert.Equal(t, "key=val", span.Context().(*bridgeSpanContext).bag.String()) |
| 1008 |
|
| 1009 |
span.Context().ForeachBaggageItem(func(k, v string) bool { |
| 1010 |
assert.Equal(t, "key", k) |
| 1011 |
assert.Equal(t, "val", v) |
| 1012 |
return true |
| 1013 |
}) |
| 1014 |
} |
| 1015 |
|
| 1016 |
func TestBridgeSpan_LogEventMethods(t *testing.T) { |
| 1017 |
tracer := newMockTracer() |
| 1018 |
b, _ := NewTracerPair(tracer) |
| 1019 |
span := b.StartSpan("test").(*bridgeSpan) |
| 1020 |
|
| 1021 |
t.Run("LogEvent", func(t *testing.T) { |
| 1022 |
span.LogEvent("event1") |
| 1023 |
mockSpan := span.otelSpan.(*mockSpan) |
| 1024 |
if len(mockSpan.Events) == 0 { |
| 1025 |
t.Fatalf("expected at least one event, got none") |
| 1026 |
} |
| 1027 |
found := false |
| 1028 |
for _, e := range mockSpan.Events { |
| 1029 |
for _, attr := range e.Attributes { |
| 1030 |
if attr.Key == "event" && attr.Value.AsString() == "event1" { |
| 1031 |
found = true |
| 1032 |
} |
| 1033 |
} |
| 1034 |
} |
| 1035 |
if !found { |
| 1036 |
t.Errorf("LogEvent did not log expected event attribute") |
| 1037 |
} |
| 1038 |
}) |
| 1039 |
|
| 1040 |
t.Run("LogEventWithPayload", func(t *testing.T) { |
| 1041 |
span2 := b.StartSpan("test2").(*bridgeSpan) |
| 1042 |
span2.LogEventWithPayload("event2", "payload2") |
| 1043 |
mockSpan := span2.otelSpan.(*mockSpan) |
| 1044 |
foundEvent, foundPayload := false, false |
| 1045 |
for _, e := range mockSpan.Events { |
| 1046 |
for _, attr := range e.Attributes { |
| 1047 |
if attr.Key == "event" && attr.Value.AsString() == "event2" { |
| 1048 |
foundEvent = true |
| 1049 |
} |
| 1050 |
if attr.Key == "payload" && attr.Value.AsString() == "payload2" { |
| 1051 |
foundPayload = true |
| 1052 |
} |
| 1053 |
} |
| 1054 |
} |
| 1055 |
if !foundEvent { |
| 1056 |
t.Errorf("LogEventWithPayload did not log expected event attribute") |
| 1057 |
} |
| 1058 |
if !foundPayload { |
| 1059 |
t.Errorf("LogEventWithPayload did not log expected payload attribute") |
| 1060 |
} |
| 1061 |
}) |
| 1062 |
|
| 1063 |
t.Run("Log", func(t *testing.T) { |
| 1064 |
span3 := b.StartSpan("test3").(*bridgeSpan) |
| 1065 |
logData := ot.LogData{Event: "event3", Payload: "payload3"} |
| 1066 |
span3.Log(logData) |
| 1067 |
mockSpan := span3.otelSpan.(*mockSpan) |
| 1068 |
foundEvent, foundPayload := false, false |
| 1069 |
for _, e := range mockSpan.Events { |
| 1070 |
for _, attr := range e.Attributes { |
| 1071 |
if attr.Key == "event" && attr.Value.AsString() == "event3" { |
| 1072 |
foundEvent = true |
| 1073 |
} |
| 1074 |
if attr.Key == "payload" && attr.Value.AsString() == "payload3" { |
| 1075 |
foundPayload = true |
| 1076 |
} |
| 1077 |
} |
| 1078 |
} |
| 1079 |
if !foundEvent { |
| 1080 |
t.Errorf("Log did not log expected event attribute") |
| 1081 |
} |
| 1082 |
if !foundPayload { |
| 1083 |
t.Errorf("Log did not log expected payload attribute") |
| 1084 |
} |
| 1085 |
}) |
| 1086 |
} |