From d155c507192976ae41b6fb17b1d9c6a09418f3f0 Mon Sep 17 00:00:00 2001 From: schristoff <28318173+schristoff@users.noreply.github.com> Date: Mon, 18 Sep 2023 13:25:13 -0600 Subject: [PATCH 1/9] playing w/ the timeout Signed-off-by: schristoff <28318173+schristoff@users.noreply.github.com> --- tests/integration/telemetry_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/telemetry_test.go b/tests/integration/telemetry_test.go index f6afaf124..98d900551 100644 --- a/tests/integration/telemetry_test.go +++ b/tests/integration/telemetry_test.go @@ -8,7 +8,6 @@ import ( "os" "path/filepath" "testing" - "time" "get.porter.sh/porter/pkg/porter" "get.porter.sh/porter/tests" @@ -30,10 +29,11 @@ func TestTelemetrySetup(t *testing.T) { defer test.RunPorter("uninstall", "otel-jaeger", "--allow-docker-host-access") // Wait until the collection should be up - time.Sleep(10 * time.Second) + // time.Sleep(10 * time.Second) // Try to run porter with telemetry enabled p := porter.New() + defer p.Close() os.Setenv("PORTER_EXPERIMENTAL", "structured-logs") os.Setenv("PORTER_TELEMETRY_ENABLED", "true") From 3c4ca76c872b75fba4ae16c958407e51e75b55bb Mon Sep 17 00:00:00 2001 From: schristoff <28318173+schristoff@users.noreply.github.com> Date: Tue, 19 Sep 2023 11:21:58 -0600 Subject: [PATCH 2/9] hmm Signed-off-by: schristoff <28318173+schristoff@users.noreply.github.com> --- cmd/porter/main.go | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/cmd/porter/main.go b/cmd/porter/main.go index 795778b3d..f7e06ff5e 100644 --- a/cmd/porter/main.go +++ b/cmd/porter/main.go @@ -16,7 +16,6 @@ import ( "github.com/spf13/cobra" "github.com/spf13/pflag" "go.opentelemetry.io/otel/attribute" - "go.opentelemetry.io/otel/trace" ) var includeDocsCommand = false @@ -188,16 +187,7 @@ Try our QuickStart https://getporter.org/quickstart to learn how to use Porter. // Reload configuration with the now parsed cli flags p.DataLoader = cli.LoadHierarchicalConfig(cmd) - ctx, err := p.Connect(cmd.Context()) - - // Extract the parent span from the main command - parentSpan := trace.SpanFromContext(cmd.Context()) - - // Create a context with the main command's span - ctxWithRootCmdSpan := trace.ContextWithSpan(ctx, parentSpan) - - // Set the new context to the command - cmd.SetContext(ctxWithRootCmdSpan) + _, err := p.Connect(cmd.Context()) return err }, RunE: func(cmd *cobra.Command, args []string) error { From 2c08d68a5a6b645bf4fdd10d1df33b5194f64117 Mon Sep 17 00:00:00 2001 From: schristoff <28318173+schristoff@users.noreply.github.com> Date: Tue, 19 Sep 2023 11:53:05 -0600 Subject: [PATCH 3/9] hmm try two Signed-off-by: schristoff <28318173+schristoff@users.noreply.github.com> --- cmd/porter/main.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmd/porter/main.go b/cmd/porter/main.go index f7e06ff5e..11aa70852 100644 --- a/cmd/porter/main.go +++ b/cmd/porter/main.go @@ -187,8 +187,7 @@ Try our QuickStart https://getporter.org/quickstart to learn how to use Porter. // Reload configuration with the now parsed cli flags p.DataLoader = cli.LoadHierarchicalConfig(cmd) - _, err := p.Connect(cmd.Context()) - return err + return nil }, RunE: func(cmd *cobra.Command, args []string) error { if printVersion { From a498eb3ac60bce43edd22d0282c6df417ac383f8 Mon Sep 17 00:00:00 2001 From: schristoff <28318173+schristoff@users.noreply.github.com> Date: Tue, 19 Sep 2023 14:56:12 -0600 Subject: [PATCH 4/9] increase timeout? Signed-off-by: schristoff <28318173+schristoff@users.noreply.github.com> --- pkg/config/logs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/logs.go b/pkg/config/logs.go index 9c86aa06e..2da98d28e 100644 --- a/pkg/config/logs.go +++ b/pkg/config/logs.go @@ -48,7 +48,7 @@ func (c TelemetryConfig) GetStartTimeout() time.Duration { if timeout, err := time.ParseDuration(c.StartTimeout); err == nil { return timeout } - return 100 * time.Millisecond + return 300 * time.Millisecond } type LogLevel string From f8e9d123ee4cc2ab9b91f5def706fed8137ee7b1 Mon Sep 17 00:00:00 2001 From: schristoff <28318173+schristoff@users.noreply.github.com> Date: Tue, 19 Sep 2023 15:15:10 -0600 Subject: [PATCH 5/9] revert but keep increased time Signed-off-by: schristoff <28318173+schristoff@users.noreply.github.com> --- cmd/porter/main.go | 13 ++++++++++++- tests/integration/telemetry_test.go | 3 ++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/cmd/porter/main.go b/cmd/porter/main.go index 11aa70852..795778b3d 100644 --- a/cmd/porter/main.go +++ b/cmd/porter/main.go @@ -16,6 +16,7 @@ import ( "github.com/spf13/cobra" "github.com/spf13/pflag" "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/trace" ) var includeDocsCommand = false @@ -187,7 +188,17 @@ Try our QuickStart https://getporter.org/quickstart to learn how to use Porter. // Reload configuration with the now parsed cli flags p.DataLoader = cli.LoadHierarchicalConfig(cmd) - return nil + ctx, err := p.Connect(cmd.Context()) + + // Extract the parent span from the main command + parentSpan := trace.SpanFromContext(cmd.Context()) + + // Create a context with the main command's span + ctxWithRootCmdSpan := trace.ContextWithSpan(ctx, parentSpan) + + // Set the new context to the command + cmd.SetContext(ctxWithRootCmdSpan) + return err }, RunE: func(cmd *cobra.Command, args []string) error { if printVersion { diff --git a/tests/integration/telemetry_test.go b/tests/integration/telemetry_test.go index 98d900551..f9a97b8b8 100644 --- a/tests/integration/telemetry_test.go +++ b/tests/integration/telemetry_test.go @@ -8,6 +8,7 @@ import ( "os" "path/filepath" "testing" + "time" "get.porter.sh/porter/pkg/porter" "get.porter.sh/porter/tests" @@ -29,7 +30,7 @@ func TestTelemetrySetup(t *testing.T) { defer test.RunPorter("uninstall", "otel-jaeger", "--allow-docker-host-access") // Wait until the collection should be up - // time.Sleep(10 * time.Second) + time.Sleep(10 * time.Second) // Try to run porter with telemetry enabled p := porter.New() From 560298f7c53e1262a990f084baabac634118a13b Mon Sep 17 00:00:00 2001 From: schristoff <28318173+schristoff@users.noreply.github.com> Date: Tue, 19 Sep 2023 18:20:32 -0600 Subject: [PATCH 6/9] =?UTF-8?q?=F0=9F=A4=B7=E2=80=8D=E2=99=80=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: schristoff <28318173+schristoff@users.noreply.github.com> --- cmd/porter/main.go | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/cmd/porter/main.go b/cmd/porter/main.go index 795778b3d..f7c4b4fa5 100644 --- a/cmd/porter/main.go +++ b/cmd/porter/main.go @@ -16,7 +16,6 @@ import ( "github.com/spf13/cobra" "github.com/spf13/pflag" "go.opentelemetry.io/otel/attribute" - "go.opentelemetry.io/otel/trace" ) var includeDocsCommand = false @@ -189,15 +188,8 @@ Try our QuickStart https://getporter.org/quickstart to learn how to use Porter. // Reload configuration with the now parsed cli flags p.DataLoader = cli.LoadHierarchicalConfig(cmd) ctx, err := p.Connect(cmd.Context()) + cmd.SetContext(ctx) - // Extract the parent span from the main command - parentSpan := trace.SpanFromContext(cmd.Context()) - - // Create a context with the main command's span - ctxWithRootCmdSpan := trace.ContextWithSpan(ctx, parentSpan) - - // Set the new context to the command - cmd.SetContext(ctxWithRootCmdSpan) return err }, RunE: func(cmd *cobra.Command, args []string) error { From a8f5b77514511044799d2a2b41cda3920563d3aa Mon Sep 17 00:00:00 2001 From: schristoff <28318173+schristoff@users.noreply.github.com> Date: Wed, 20 Sep 2023 15:04:51 -0600 Subject: [PATCH 7/9] try harder Signed-off-by: schristoff <28318173+schristoff@users.noreply.github.com> --- pkg/config/logs.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/config/logs.go b/pkg/config/logs.go index 2da98d28e..134d24dd4 100644 --- a/pkg/config/logs.go +++ b/pkg/config/logs.go @@ -45,10 +45,10 @@ type TelemetryConfig struct { // GetStartTimeout returns the amount of time to wait for the collector to start // if a value was not configured, return the default timeout. func (c TelemetryConfig) GetStartTimeout() time.Duration { - if timeout, err := time.ParseDuration(c.StartTimeout); err == nil { - return timeout - } - return 300 * time.Millisecond + // if timeout, err := time.ParseDuration(c.StartTimeout); err == nil { + // return timeout + // } + return 900 * time.Millisecond } type LogLevel string From ffbc8df8ebc0aecb7df03eb9c2258cac7e180aba Mon Sep 17 00:00:00 2001 From: schristoff <28318173+schristoff@users.noreply.github.com> Date: Wed, 20 Sep 2023 17:08:02 -0600 Subject: [PATCH 8/9] this took way too long Signed-off-by: schristoff <28318173+schristoff@users.noreply.github.com> --- pkg/config/logs.go | 2 +- tests/integration/telemetry_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/config/logs.go b/pkg/config/logs.go index 134d24dd4..7dbad8891 100644 --- a/pkg/config/logs.go +++ b/pkg/config/logs.go @@ -48,7 +48,7 @@ func (c TelemetryConfig) GetStartTimeout() time.Duration { // if timeout, err := time.ParseDuration(c.StartTimeout); err == nil { // return timeout // } - return 900 * time.Millisecond + return 100 * time.Millisecond } type LogLevel string diff --git a/tests/integration/telemetry_test.go b/tests/integration/telemetry_test.go index f9a97b8b8..cfc5d4675 100644 --- a/tests/integration/telemetry_test.go +++ b/tests/integration/telemetry_test.go @@ -25,7 +25,7 @@ func TestTelemetrySetup(t *testing.T) { require.NoError(t, err, "test setup failed") ctx := context.Background() - _, _, err = test.RunPorter("install", "otel-jaeger", "-r=ghcr.io/getporter/examples/otel-jaeger:v0.1.0", "--allow-docker-host-access") + _, _, err = test.RunPorter("install", "otel-jaeger", "-r=ghcr.io/getporter/examples/otel-jaeger:v0.1.1", "--allow-docker-host-access") require.NoError(t, err) defer test.RunPorter("uninstall", "otel-jaeger", "--allow-docker-host-access") From 38f749139f0ee604f3efcf09e8195eec8b4361cd Mon Sep 17 00:00:00 2001 From: schristoff <28318173+schristoff@users.noreply.github.com> Date: Wed, 20 Sep 2023 17:10:26 -0600 Subject: [PATCH 9/9] revert all debugging steps Signed-off-by: schristoff <28318173+schristoff@users.noreply.github.com> --- cmd/porter/main.go | 9 ++++++++- pkg/config/logs.go | 6 +++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/cmd/porter/main.go b/cmd/porter/main.go index f7c4b4fa5..db1335636 100644 --- a/cmd/porter/main.go +++ b/cmd/porter/main.go @@ -16,6 +16,7 @@ import ( "github.com/spf13/cobra" "github.com/spf13/pflag" "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/trace" ) var includeDocsCommand = false @@ -188,8 +189,14 @@ Try our QuickStart https://getporter.org/quickstart to learn how to use Porter. // Reload configuration with the now parsed cli flags p.DataLoader = cli.LoadHierarchicalConfig(cmd) ctx, err := p.Connect(cmd.Context()) - cmd.SetContext(ctx) + // Extract the parent span from the main command + parentSpan := trace.SpanFromContext(cmd.Context()) + // Create a context with the main command's span + ctxWithRootCmdSpan := trace.ContextWithSpan(ctx, parentSpan) + + // Set the new context to the command + cmd.SetContext(ctxWithRootCmdSpan) return err }, RunE: func(cmd *cobra.Command, args []string) error { diff --git a/pkg/config/logs.go b/pkg/config/logs.go index 7dbad8891..9c86aa06e 100644 --- a/pkg/config/logs.go +++ b/pkg/config/logs.go @@ -45,9 +45,9 @@ type TelemetryConfig struct { // GetStartTimeout returns the amount of time to wait for the collector to start // if a value was not configured, return the default timeout. func (c TelemetryConfig) GetStartTimeout() time.Duration { - // if timeout, err := time.ParseDuration(c.StartTimeout); err == nil { - // return timeout - // } + if timeout, err := time.ParseDuration(c.StartTimeout); err == nil { + return timeout + } return 100 * time.Millisecond }