From 8aaa60db735e6699b0726bb2e883ecdab554f069 Mon Sep 17 00:00:00 2001 From: csuzhang Date: Thu, 24 Feb 2022 20:02:13 +0800 Subject: [PATCH 01/20] unify otlp path parsing/default logic --- exporters/otlp/internal/config.go | 21 +++++++++++++++++++ .../otlpmetric/internal/otlpconfig/options.go | 15 ++----------- .../otlptrace/internal/otlpconfig/options.go | 15 ++----------- 3 files changed, 25 insertions(+), 26 deletions(-) create mode 100644 exporters/otlp/internal/config.go diff --git a/exporters/otlp/internal/config.go b/exporters/otlp/internal/config.go new file mode 100644 index 00000000000..5203a62651c --- /dev/null +++ b/exporters/otlp/internal/config.go @@ -0,0 +1,21 @@ +package internal + +import ( + "fmt" + "path" + "strings" +) + +// CleanPath returns cleaned URL path. Replace with default path if path is nil +func CleanPath(URLPath string, defaultPath string) string { + tmp := strings.TrimSpace(URLPath) + if tmp == "" { + return defaultPath + } else { + tmp = path.Clean(tmp) + if !path.IsAbs(tmp) { + tmp = fmt.Sprintf("/%s", tmp) + } + } + return tmp +} diff --git a/exporters/otlp/otlpmetric/internal/otlpconfig/options.go b/exporters/otlp/otlpmetric/internal/otlpconfig/options.go index c2f442f998f..f2c8ee5d21a 100644 --- a/exporters/otlp/otlpmetric/internal/otlpconfig/options.go +++ b/exporters/otlp/otlpmetric/internal/otlpconfig/options.go @@ -17,8 +17,6 @@ package otlpconfig // import "go.opentelemetry.io/otel/exporters/otlp/otlpmetric import ( "crypto/tls" "fmt" - "path" - "strings" "time" "google.golang.org/grpc" @@ -27,6 +25,7 @@ import ( "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/encoding/gzip" + "go.opentelemetry.io/otel/exporters/otlp/internal" "go.opentelemetry.io/otel/exporters/otlp/internal/retry" ) @@ -90,17 +89,7 @@ func NewHTTPConfig(opts ...HTTPOption) Config { for _, opt := range opts { cfg = opt.ApplyHTTPOption(cfg) } - - tmp := strings.TrimSpace(cfg.Metrics.URLPath) - if tmp == "" { - tmp = DefaultMetricsPath - } else { - tmp = path.Clean(tmp) - if !path.IsAbs(tmp) { - tmp = fmt.Sprintf("/%s", tmp) - } - } - cfg.Metrics.URLPath = tmp + cfg.Metrics.URLPath = internal.CleanPath(cfg.Metrics.URLPath, DefaultMetricsPath) return cfg } diff --git a/exporters/otlp/otlptrace/internal/otlpconfig/options.go b/exporters/otlp/otlptrace/internal/otlpconfig/options.go index f874c146e25..56e83b85334 100644 --- a/exporters/otlp/otlptrace/internal/otlpconfig/options.go +++ b/exporters/otlp/otlptrace/internal/otlpconfig/options.go @@ -17,8 +17,6 @@ package otlpconfig // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/ import ( "crypto/tls" "fmt" - "path" - "strings" "time" "google.golang.org/grpc" @@ -27,6 +25,7 @@ import ( "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/encoding/gzip" + "go.opentelemetry.io/otel/exporters/otlp/internal" "go.opentelemetry.io/otel/exporters/otlp/internal/retry" ) @@ -83,17 +82,7 @@ func NewHTTPConfig(opts ...HTTPOption) Config { for _, opt := range opts { cfg = opt.ApplyHTTPOption(cfg) } - - tmp := strings.TrimSpace(cfg.Traces.URLPath) - if tmp == "" { - tmp = DefaultTracesPath - } else { - tmp = path.Clean(tmp) - if !path.IsAbs(tmp) { - tmp = fmt.Sprintf("/%s", tmp) - } - } - cfg.Traces.URLPath = tmp + cfg.Traces.URLPath = internal.CleanPath(cfg.Traces.URLPath, DefaultTracesPath) return cfg } From db2a08d0e0fc309491c4da50e78156833ac5d167 Mon Sep 17 00:00:00 2001 From: csuzhang Date: Thu, 24 Feb 2022 20:08:35 +0800 Subject: [PATCH 02/20] add changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c68d06b7d30..d49b42c6d4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - For tracestate's members, prepend the new element and remove the oldest one, which is over capacity (#2592) - Add event and link drop counts to the exported data from the `oltptrace` exporter. (#2601) +- Unify of path parsing functionally in `otlpmetric` and `otlptrace` config. (#2639) ### Fixed From 6d6cf9e1633ea884c9bac9ede0685e5f7f8f1b23 Mon Sep 17 00:00:00 2001 From: csuzhang Date: Thu, 24 Feb 2022 20:22:01 +0800 Subject: [PATCH 03/20] add license and unit test --- exporters/otlp/internal/config.go | 17 +++++++++ exporters/otlp/internal/config_test.go | 53 ++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 exporters/otlp/internal/config_test.go diff --git a/exporters/otlp/internal/config.go b/exporters/otlp/internal/config.go index 5203a62651c..12b8778f785 100644 --- a/exporters/otlp/internal/config.go +++ b/exporters/otlp/internal/config.go @@ -1,3 +1,20 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package retry provides request retry functionality that can perform +// configurable exponential backoff for transient errors and honor any +// explicit throttle responses received. package internal import ( diff --git a/exporters/otlp/internal/config_test.go b/exporters/otlp/internal/config_test.go new file mode 100644 index 00000000000..7f80401a8eb --- /dev/null +++ b/exporters/otlp/internal/config_test.go @@ -0,0 +1,53 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package internal + +import "testing" + +func TestCleanPath(t *testing.T) { + type args struct { + URLPath string + defaultPath string + } + tests := []struct { + name string + args args + want string + }{ + { + name: "test-clean-nil-path", + args: args{ + URLPath: "", + defaultPath: "DefaultPath", + }, + want: "DefaultPath", + }, + { + name: "test-clean-trace-path", + args: args{ + URLPath: "/prefix/v1/metrics", + defaultPath: "DefaultMetricsPath", + }, + want: "/prefix/v1/metrics", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := CleanPath(tt.args.URLPath, tt.args.defaultPath); got != tt.want { + t.Errorf("CleanPath() = %v, want %v", got, tt.want) + } + }) + } +} From 16be419545419f76f95cf740764bf5b2b58f2037 Mon Sep 17 00:00:00 2001 From: csuzhang Date: Thu, 24 Feb 2022 20:26:33 +0800 Subject: [PATCH 04/20] remove else branch --- exporters/otlp/internal/config.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/exporters/otlp/internal/config.go b/exporters/otlp/internal/config.go index 12b8778f785..ca89cb2df4b 100644 --- a/exporters/otlp/internal/config.go +++ b/exporters/otlp/internal/config.go @@ -28,11 +28,10 @@ func CleanPath(URLPath string, defaultPath string) string { tmp := strings.TrimSpace(URLPath) if tmp == "" { return defaultPath - } else { - tmp = path.Clean(tmp) - if !path.IsAbs(tmp) { - tmp = fmt.Sprintf("/%s", tmp) - } + } + tmp = path.Clean(tmp) + if !path.IsAbs(tmp) { + tmp = fmt.Sprintf("/%s", tmp) } return tmp } From d6c705959ccee3534c93b79cafe3419adc33947a Mon Sep 17 00:00:00 2001 From: csuzhang Date: Thu, 24 Feb 2022 20:33:45 +0800 Subject: [PATCH 05/20] increase unitt test coverage --- exporters/otlp/internal/config_test.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/exporters/otlp/internal/config_test.go b/exporters/otlp/internal/config_test.go index 7f80401a8eb..fc5bb1d9ab8 100644 --- a/exporters/otlp/internal/config_test.go +++ b/exporters/otlp/internal/config_test.go @@ -35,13 +35,21 @@ func TestCleanPath(t *testing.T) { want: "DefaultPath", }, { - name: "test-clean-trace-path", + name: "test-clean-metrics-path", args: args{ URLPath: "/prefix/v1/metrics", defaultPath: "DefaultMetricsPath", }, want: "/prefix/v1/metrics", }, + { + name: "test-clean-traces-path", + args: args{ + URLPath: "https://env_endpoint", + defaultPath: "DefaultTracesPath", + }, + want: "/https:/env_endpoint", + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { From bd48ca60c85bb15b1db58bd821c43f4f2e3f18c5 Mon Sep 17 00:00:00 2001 From: csuzhang Date: Thu, 24 Feb 2022 20:41:25 +0800 Subject: [PATCH 06/20] add vanity import --- exporters/otlp/internal/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exporters/otlp/internal/config.go b/exporters/otlp/internal/config.go index ca89cb2df4b..204b4d7bfa4 100644 --- a/exporters/otlp/internal/config.go +++ b/exporters/otlp/internal/config.go @@ -15,7 +15,7 @@ // Package retry provides request retry functionality that can perform // configurable exponential backoff for transient errors and honor any // explicit throttle responses received. -package internal +package internal // import "go.opentelemetry.io/otel/exporters/otlp/internal" import ( "fmt" From 270153436142abe3b2e7a4e7ac3f362200bbc541 Mon Sep 17 00:00:00 2001 From: Chester Cheung Date: Fri, 25 Feb 2022 11:17:32 +0800 Subject: [PATCH 07/20] Update exporters/otlp/internal/config.go Co-authored-by: Tyler Yahn --- exporters/otlp/internal/config.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/exporters/otlp/internal/config.go b/exporters/otlp/internal/config.go index 204b4d7bfa4..c5c5dc32f2d 100644 --- a/exporters/otlp/internal/config.go +++ b/exporters/otlp/internal/config.go @@ -12,9 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Package retry provides request retry functionality that can perform -// configurable exponential backoff for transient errors and honor any -// explicit throttle responses received. +// Package internal contains common functionality for all OTLP exporters. package internal // import "go.opentelemetry.io/otel/exporters/otlp/internal" import ( From 8a998449da9750cf751ce1a3939df8296805fea8 Mon Sep 17 00:00:00 2001 From: Chester Cheung Date: Fri, 25 Feb 2022 11:17:43 +0800 Subject: [PATCH 08/20] Update exporters/otlp/internal/config.go Co-authored-by: Tyler Yahn --- exporters/otlp/internal/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exporters/otlp/internal/config.go b/exporters/otlp/internal/config.go index c5c5dc32f2d..2ed942406ca 100644 --- a/exporters/otlp/internal/config.go +++ b/exporters/otlp/internal/config.go @@ -21,7 +21,7 @@ import ( "strings" ) -// CleanPath returns cleaned URL path. Replace with default path if path is nil +// CleanPath returns URLPath with all spaces trimmed and all redundancies removed. If URLPath is empty or cleaning it results in an empty string, defaultPath is returned instead. func CleanPath(URLPath string, defaultPath string) string { tmp := strings.TrimSpace(URLPath) if tmp == "" { From 9877a21d9bb663d3dc7ff7a0d980ef9e81aff6bc Mon Sep 17 00:00:00 2001 From: Chester Cheung Date: Fri, 25 Feb 2022 11:19:07 +0800 Subject: [PATCH 09/20] Update exporters/otlp/internal/config.go Co-authored-by: Tyler Yahn --- exporters/otlp/internal/config.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/exporters/otlp/internal/config.go b/exporters/otlp/internal/config.go index 2ed942406ca..7f6a63c7a49 100644 --- a/exporters/otlp/internal/config.go +++ b/exporters/otlp/internal/config.go @@ -23,11 +23,10 @@ import ( // CleanPath returns URLPath with all spaces trimmed and all redundancies removed. If URLPath is empty or cleaning it results in an empty string, defaultPath is returned instead. func CleanPath(URLPath string, defaultPath string) string { - tmp := strings.TrimSpace(URLPath) - if tmp == "" { + tmp := path.Clean(strings.TrimSpace(URLPath)) + if tmp == "." { return defaultPath } - tmp = path.Clean(tmp) if !path.IsAbs(tmp) { tmp = fmt.Sprintf("/%s", tmp) } From cdd7d1e41fc401ccf87e98ae578e787901804fea Mon Sep 17 00:00:00 2001 From: Chester Cheung Date: Fri, 25 Feb 2022 11:19:13 +0800 Subject: [PATCH 10/20] Update CHANGELOG.md Co-authored-by: Tyler Yahn --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d49b42c6d4a..38fd0fb6e0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,7 +23,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - For tracestate's members, prepend the new element and remove the oldest one, which is over capacity (#2592) - Add event and link drop counts to the exported data from the `oltptrace` exporter. (#2601) -- Unify of path parsing functionally in `otlpmetric` and `otlptrace` config. (#2639) +- Unify path cleaning functionally in the `otlpmetric` and `otlptrace` config. (#2639) ### Fixed From 0e7b6e8349974b6d99a6eb76e8e900332f1982a5 Mon Sep 17 00:00:00 2001 From: Chester Cheung Date: Fri, 25 Feb 2022 11:19:19 +0800 Subject: [PATCH 11/20] Update exporters/otlp/internal/config_test.go Co-authored-by: Tyler Yahn --- exporters/otlp/internal/config_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exporters/otlp/internal/config_test.go b/exporters/otlp/internal/config_test.go index fc5bb1d9ab8..13eba73c71d 100644 --- a/exporters/otlp/internal/config_test.go +++ b/exporters/otlp/internal/config_test.go @@ -27,7 +27,7 @@ func TestCleanPath(t *testing.T) { want string }{ { - name: "test-clean-nil-path", + name: "test-clean-empty-path", args: args{ URLPath: "", defaultPath: "DefaultPath", From cf86c84dc23f6fc85372fa4f78d3a61eaee28905 Mon Sep 17 00:00:00 2001 From: Chester Cheung Date: Fri, 25 Feb 2022 11:19:26 +0800 Subject: [PATCH 12/20] Update exporters/otlp/internal/config_test.go Co-authored-by: Tyler Yahn --- exporters/otlp/internal/config_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/exporters/otlp/internal/config_test.go b/exporters/otlp/internal/config_test.go index 13eba73c71d..064ce6331cb 100644 --- a/exporters/otlp/internal/config_test.go +++ b/exporters/otlp/internal/config_test.go @@ -50,6 +50,28 @@ func TestCleanPath(t *testing.T) { }, want: "/https:/env_endpoint", }, + { + name: "spaces trimmed", + args: args{ + URLPath: " /dir", + }, + want: "/dir", + }, + { + name: "clean path empty", + args: args{ + URLPath: "dir/..", + defaultPath: "DefaultTracesPath", + }, + want: "DefaultTracesPath", + }, + { + name: "make absolute", + args: args{ + URLPath: "dir/a", + }, + want: "/dir/a", + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { From a0fb2cf680f71cb356caf1cadc4a33f40b8e1c85 Mon Sep 17 00:00:00 2001 From: csuzhang Date: Fri, 25 Feb 2022 11:23:03 +0800 Subject: [PATCH 13/20] format the config_test.go --- exporters/otlp/internal/config_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exporters/otlp/internal/config_test.go b/exporters/otlp/internal/config_test.go index 064ce6331cb..56dd5885255 100644 --- a/exporters/otlp/internal/config_test.go +++ b/exporters/otlp/internal/config_test.go @@ -53,7 +53,7 @@ func TestCleanPath(t *testing.T) { { name: "spaces trimmed", args: args{ - URLPath: " /dir", + URLPath: " /dir", }, want: "/dir", }, @@ -68,7 +68,7 @@ func TestCleanPath(t *testing.T) { { name: "make absolute", args: args{ - URLPath: "dir/a", + URLPath: "dir/a", }, want: "/dir/a", }, From 85a2a2046876350505d9e4e0f0fb993ed1f75cf1 Mon Sep 17 00:00:00 2001 From: Chester Cheung Date: Wed, 2 Mar 2022 18:39:33 +0800 Subject: [PATCH 14/20] Update exporters/otlp/internal/config_test.go Co-authored-by: Sam Xie --- exporters/otlp/internal/config_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exporters/otlp/internal/config_test.go b/exporters/otlp/internal/config_test.go index 56dd5885255..2039134974d 100644 --- a/exporters/otlp/internal/config_test.go +++ b/exporters/otlp/internal/config_test.go @@ -27,7 +27,7 @@ func TestCleanPath(t *testing.T) { want string }{ { - name: "test-clean-empty-path", + name: "clean empty path", args: args{ URLPath: "", defaultPath: "DefaultPath", From d53ed180a52f6416b6523db74067cf4422740a60 Mon Sep 17 00:00:00 2001 From: Chester Cheung Date: Wed, 2 Mar 2022 18:39:39 +0800 Subject: [PATCH 15/20] Update exporters/otlp/internal/config_test.go Co-authored-by: Sam Xie --- exporters/otlp/internal/config_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exporters/otlp/internal/config_test.go b/exporters/otlp/internal/config_test.go index 2039134974d..7576e469869 100644 --- a/exporters/otlp/internal/config_test.go +++ b/exporters/otlp/internal/config_test.go @@ -18,7 +18,7 @@ import "testing" func TestCleanPath(t *testing.T) { type args struct { - URLPath string + urlPath string defaultPath string } tests := []struct { From c781a1ace4bdcc9fcf32a59d3a649bff8fa38306 Mon Sep 17 00:00:00 2001 From: Chester Cheung Date: Wed, 2 Mar 2022 18:39:45 +0800 Subject: [PATCH 16/20] Update exporters/otlp/internal/config_test.go Co-authored-by: Sam Xie --- exporters/otlp/internal/config_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exporters/otlp/internal/config_test.go b/exporters/otlp/internal/config_test.go index 7576e469869..9d590199814 100644 --- a/exporters/otlp/internal/config_test.go +++ b/exporters/otlp/internal/config_test.go @@ -35,7 +35,7 @@ func TestCleanPath(t *testing.T) { want: "DefaultPath", }, { - name: "test-clean-metrics-path", + name: "clean metrics path", args: args{ URLPath: "/prefix/v1/metrics", defaultPath: "DefaultMetricsPath", From 2a191b1edef617ca944e316f88132218a002fd8b Mon Sep 17 00:00:00 2001 From: Chester Cheung Date: Wed, 2 Mar 2022 18:39:51 +0800 Subject: [PATCH 17/20] Update exporters/otlp/internal/config_test.go Co-authored-by: Sam Xie --- exporters/otlp/internal/config_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exporters/otlp/internal/config_test.go b/exporters/otlp/internal/config_test.go index 9d590199814..038c89c149c 100644 --- a/exporters/otlp/internal/config_test.go +++ b/exporters/otlp/internal/config_test.go @@ -43,7 +43,7 @@ func TestCleanPath(t *testing.T) { want: "/prefix/v1/metrics", }, { - name: "test-clean-traces-path", + name: "clean traces path", args: args{ URLPath: "https://env_endpoint", defaultPath: "DefaultTracesPath", From 896889c784889451e98603c69a5b609b05037c7d Mon Sep 17 00:00:00 2001 From: Chester Cheung Date: Wed, 2 Mar 2022 18:39:57 +0800 Subject: [PATCH 18/20] Update exporters/otlp/internal/config.go Co-authored-by: Sam Xie --- exporters/otlp/internal/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exporters/otlp/internal/config.go b/exporters/otlp/internal/config.go index 7f6a63c7a49..e1733ee551a 100644 --- a/exporters/otlp/internal/config.go +++ b/exporters/otlp/internal/config.go @@ -21,7 +21,7 @@ import ( "strings" ) -// CleanPath returns URLPath with all spaces trimmed and all redundancies removed. If URLPath is empty or cleaning it results in an empty string, defaultPath is returned instead. +// CleanPath returns a path with all spaces trimmed and all redundancies removed. If urlPath is empty or cleaning it results in an empty string, defaultPath is returned instead. func CleanPath(URLPath string, defaultPath string) string { tmp := path.Clean(strings.TrimSpace(URLPath)) if tmp == "." { From d59525c51285c02af7e5031e5f8c2b91754180ea Mon Sep 17 00:00:00 2001 From: Chester Cheung Date: Wed, 2 Mar 2022 18:40:03 +0800 Subject: [PATCH 19/20] Update exporters/otlp/internal/config.go Co-authored-by: Sam Xie --- exporters/otlp/internal/config.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exporters/otlp/internal/config.go b/exporters/otlp/internal/config.go index e1733ee551a..b3fd45d9d31 100644 --- a/exporters/otlp/internal/config.go +++ b/exporters/otlp/internal/config.go @@ -22,8 +22,8 @@ import ( ) // CleanPath returns a path with all spaces trimmed and all redundancies removed. If urlPath is empty or cleaning it results in an empty string, defaultPath is returned instead. -func CleanPath(URLPath string, defaultPath string) string { - tmp := path.Clean(strings.TrimSpace(URLPath)) +func CleanPath(urlPath string, defaultPath string) string { + tmp := path.Clean(strings.TrimSpace(urlPath)) if tmp == "." { return defaultPath } From 9d6cb6321d39bca9787fdfbc9b64bdd8fc2b79ad Mon Sep 17 00:00:00 2001 From: csuzhang Date: Wed, 2 Mar 2022 18:44:46 +0800 Subject: [PATCH 20/20] change URLPath to urlPath --- exporters/otlp/internal/config_test.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/exporters/otlp/internal/config_test.go b/exporters/otlp/internal/config_test.go index 038c89c149c..92a819a1f2b 100644 --- a/exporters/otlp/internal/config_test.go +++ b/exporters/otlp/internal/config_test.go @@ -29,7 +29,7 @@ func TestCleanPath(t *testing.T) { { name: "clean empty path", args: args{ - URLPath: "", + urlPath: "", defaultPath: "DefaultPath", }, want: "DefaultPath", @@ -37,7 +37,7 @@ func TestCleanPath(t *testing.T) { { name: "clean metrics path", args: args{ - URLPath: "/prefix/v1/metrics", + urlPath: "/prefix/v1/metrics", defaultPath: "DefaultMetricsPath", }, want: "/prefix/v1/metrics", @@ -45,7 +45,7 @@ func TestCleanPath(t *testing.T) { { name: "clean traces path", args: args{ - URLPath: "https://env_endpoint", + urlPath: "https://env_endpoint", defaultPath: "DefaultTracesPath", }, want: "/https:/env_endpoint", @@ -53,14 +53,14 @@ func TestCleanPath(t *testing.T) { { name: "spaces trimmed", args: args{ - URLPath: " /dir", + urlPath: " /dir", }, want: "/dir", }, { name: "clean path empty", args: args{ - URLPath: "dir/..", + urlPath: "dir/..", defaultPath: "DefaultTracesPath", }, want: "DefaultTracesPath", @@ -68,14 +68,14 @@ func TestCleanPath(t *testing.T) { { name: "make absolute", args: args{ - URLPath: "dir/a", + urlPath: "dir/a", }, want: "/dir/a", }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := CleanPath(tt.args.URLPath, tt.args.defaultPath); got != tt.want { + if got := CleanPath(tt.args.urlPath, tt.args.defaultPath); got != tt.want { t.Errorf("CleanPath() = %v, want %v", got, tt.want) } })