-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix missing requestID due to empty traceID
- Loading branch information
Kleonikos Kyriakis
committed
May 17, 2024
1 parent
8b583f5
commit 39323bf
Showing
5 changed files
with
68 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (C) 2024, Chain4Travel AG. All rights reserved. | ||
* See the file LICENSE for licensing terms. | ||
*/ | ||
|
||
package tracing | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"go.opentelemetry.io/otel/trace" | ||
) | ||
|
||
func TestNoopTraceIDForSpan(t *testing.T) { | ||
tracer, err := NewNoOpTracer() | ||
require.NoError(t, err) | ||
_, span := tracer.Start(context.Background(), "test") | ||
got := tracer.TraceIDForSpan(span) | ||
emptyTraceID := trace.TraceID{} | ||
require.NotEqual(t, emptyTraceID, got) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright (C) 2024, Chain4Travel AG. All rights reserved. | ||
* See the file LICENSE for licensing terms. | ||
*/ | ||
|
||
package tracing | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestTraceIDForSpan(t *testing.T) { | ||
tracer, err := NewNoOpTracer() | ||
require.NoError(t, err) | ||
_, span := tracer.Start(context.Background(), "test") | ||
got := tracer.TraceIDForSpan(span) | ||
require.NotEqual(t, span.SpanContext().TraceID(), got) | ||
} |