Skip to content

Commit 986666f

Browse files
author
Emmanuel T Odeke
authored
interceptor: make endToEnd test an example test (#91)
Previously: TestNewInterceptor_endToEnd served the purpose of demoing how to make an "agent" with the OpenCensus interceptor. It just spams stdout with output and doesn't perform any assertions nor serve any other purpose other than demoing. As we add other interceptors, we'll put them in here. Instead make it an example test that compiles and will serve as the blueprint towards making cmd/ocagent modifications.
1 parent 00ec5c7 commit 986666f

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

interceptor/end_to_end_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"context"
1919
"encoding/json"
2020
"log"
21-
"testing"
2221
"time"
2322

2423
"contrib.go.opencensus.io/exporter/ocagent"
@@ -31,7 +30,7 @@ import (
3130
"github.com/census-instrumentation/opencensus-service/spanreceiver"
3231
)
3332

34-
func TestNewInterceptor_endToEnd(t *testing.T) {
33+
func Example_endToEnd() {
3534
// This is what the cmd/ocagent code would look like this.
3635
// A trace interceptor as per the trace interceptor
3736
// configs that have been parsed.
@@ -58,7 +57,7 @@ func TestNewInterceptor_endToEnd(t *testing.T) {
5857
_ = ti.StopTraceInterception(context.Background())
5958
}
6059
}()
61-
t.Log("Done starting the trace interceptor")
60+
log.Println("Done starting the trace interceptor")
6261
// We are done with the agent-core
6362

6463
// Now this code would exist in the client application e.g. client code.
@@ -74,7 +73,7 @@ func TestNewInterceptor_endToEnd(t *testing.T) {
7473
// For demo purposes we are always sampling
7574
trace.ApplyConfig(trace.Config{DefaultSampler: trace.AlwaysSample()})
7675

77-
t.Log("Starting loop")
76+
log.Println("Starting loop")
7877
ctx, span := trace.StartSpan(context.Background(), "ClientLibrarySpan")
7978
for i := 0; i < 10; i++ {
8079
_, span := trace.StartSpan(ctx, "ChildSpan")

0 commit comments

Comments
 (0)