From 7f5d9555bc02187a64083c23f8bf179f62dfea2d Mon Sep 17 00:00:00 2001 From: Adam Shaw Date: Fri, 21 Oct 2022 16:14:41 -0700 Subject: [PATCH 1/2] Setting Default ErrorStrategy to Log --- xray/config.go | 2 +- xray/config_test.go | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/xray/config.go b/xray/config.go index 86a38323..e2506992 100644 --- a/xray/config.go +++ b/xray/config.go @@ -93,7 +93,7 @@ func newGlobalConfig() *globalConfig { ret.contextMissingStrategy = cm } } else { - cm := ctxmissing.NewDefaultRuntimeErrorStrategy() + cm := ctxmissing.NewDefaultLogErrorStrategy() ret.contextMissingStrategy = cm } diff --git a/xray/config_test.go b/xray/config_test.go index 65110f26..f792e9ca 100644 --- a/xray/config_test.go +++ b/xray/config_test.go @@ -134,7 +134,7 @@ func TestDefaultConfigureParameters(t *testing.T) { daemonAddr := &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 2000} efs, _ := exception.NewDefaultFormattingStrategy() sms, _ := NewDefaultStreamingStrategy() - cms := ctxmissing.NewDefaultRuntimeErrorStrategy() + cms := ctxmissing.NewDefaultLogErrorStrategy() assert.Equal(t, daemonAddr, globalCfg.daemonAddr) assert.Equal(t, efs, globalCfg.exceptionFormattingStrategy) @@ -271,13 +271,13 @@ func BenchmarkConfigure(b *testing.B) { cms := &TestContextMissingStrategy{} configure := Config{ - ServiceVersion: serviceVersion, - SamplingStrategy: ss, + ServiceVersion: serviceVersion, + SamplingStrategy: ss, ExceptionFormattingStrategy: efs, - StreamingStrategy: sms, - ContextMissingStrategy: cms, - LogLevel: logLevel, - LogFormat: logFormat, + StreamingStrategy: sms, + ContextMissingStrategy: cms, + LogLevel: logLevel, + LogFormat: logFormat, } for i := 0; i < b.N; i++ { Configure(configure) From bfa8e05a7ceaf07a9f8d18fb9167c4f8ff2ffd41 Mon Sep 17 00:00:00 2001 From: Adam Shaw Date: Tue, 25 Oct 2022 12:54:59 -0700 Subject: [PATCH 2/2] Fixing bug --- xray/capture_test.go | 21 +++++---------------- xray/segment.go | 5 +++++ 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/xray/capture_test.go b/xray/capture_test.go index a59298dd..ace44dec 100644 --- a/xray/capture_test.go +++ b/xray/capture_test.go @@ -113,20 +113,9 @@ func TestPanicCapture(t *testing.T) { } func TestNoSegmentCapture(t *testing.T) { - var err error - func() { - defer func() { - if p := recover(); p != nil { - err = errors.New(p.(string)) - } - }() - _ = Capture(context.Background(), "PanicService", func(context.Context) error { - panic("MyPanic") - }) - }() - - assert.NotNil(t, err) - assert.Equal(t, "failed to begin subsegment named 'PanicService': segment cannot be found.", err.Error()) + ctx, _ := NewTestDaemon() + _, seg := BeginSubsegment(ctx, "Name") + seg.Close(nil) } func TestCaptureAsync(t *testing.T) { @@ -162,8 +151,8 @@ func TestCaptureAsync(t *testing.T) { // Benchmarks func BenchmarkCapture(b *testing.B) { - ctx, seg:= BeginSegment(context.Background(), "TestCaptureSeg") - for i:=0; i