From fd015d835d500490fd662bc937da6f5cd7894aa7 Mon Sep 17 00:00:00 2001 From: Remy Chantenay Date: Fri, 31 Mar 2023 19:53:38 +0200 Subject: [PATCH 1/8] Add Version func to otel/exporters/otlp/otlpmetric --- exporters/otlp/otlpmetric/header.go | 21 ++++++++++++ exporters/otlp/otlpmetric/header_test.go | 27 +++++++++++++++ .../otlp/otlpmetric/internal/oconf/options.go | 3 +- .../otlp/otlpmetric/otlpmetrichttp/client.go | 3 +- exporters/otlp/otlpmetric/version.go | 20 +++++++++++ exporters/otlp/otlpmetric/version_test.go | 34 +++++++++++++++++++ 6 files changed, 106 insertions(+), 2 deletions(-) create mode 100644 exporters/otlp/otlpmetric/header.go create mode 100644 exporters/otlp/otlpmetric/header_test.go create mode 100644 exporters/otlp/otlpmetric/version.go create mode 100644 exporters/otlp/otlpmetric/version_test.go diff --git a/exporters/otlp/otlpmetric/header.go b/exporters/otlp/otlpmetric/header.go new file mode 100644 index 00000000000..a62168c815e --- /dev/null +++ b/exporters/otlp/otlpmetric/header.go @@ -0,0 +1,21 @@ +// 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 otlpmetric // import "go.opentelemetry.io/otel/exporters/otlp/otlpmetric" + +// GetUserAgentHeader returns an OTLP header value form "OTel OTLP Exporter Go/{{ .Version }}" +// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#user-agent +func GetUserAgentHeader() string { + return "OTel OTLP Exporter Go/" + Version() +} diff --git a/exporters/otlp/otlpmetric/header_test.go b/exporters/otlp/otlpmetric/header_test.go new file mode 100644 index 00000000000..acdc87f31fe --- /dev/null +++ b/exporters/otlp/otlpmetric/header_test.go @@ -0,0 +1,27 @@ +// 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 otlpmetric_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "go.opentelemetry.io/otel/exporters/otlp/otlpmetric" +) + +func TestGetUserAgentHeader(t *testing.T) { + require.Regexp(t, "OTel OTLP Exporter Go/1\\..*", otlpmetric.GetUserAgentHeader()) +} diff --git a/exporters/otlp/otlpmetric/internal/oconf/options.go b/exporters/otlp/otlpmetric/internal/oconf/options.go index b5ab4e6f315..eb9abfb324d 100644 --- a/exporters/otlp/otlpmetric/internal/oconf/options.go +++ b/exporters/otlp/otlpmetric/internal/oconf/options.go @@ -27,6 +27,7 @@ import ( "go.opentelemetry.io/otel/exporters/otlp/internal" "go.opentelemetry.io/otel/exporters/otlp/internal/retry" + "go.opentelemetry.io/otel/exporters/otlp/otlpmetric" "go.opentelemetry.io/otel/internal/global" "go.opentelemetry.io/otel/sdk/metric" "go.opentelemetry.io/otel/sdk/metric/aggregation" @@ -116,7 +117,7 @@ func NewGRPCConfig(opts ...GRPCOption) Config { AggregationSelector: metric.DefaultAggregationSelector, }, RetryConfig: retry.DefaultConfig, - DialOptions: []grpc.DialOption{grpc.WithUserAgent(internal.GetUserAgentHeader())}, + DialOptions: []grpc.DialOption{grpc.WithUserAgent(otlpmetric.GetUserAgentHeader())}, } cfg = ApplyGRPCEnvConfigs(cfg) for _, opt := range opts { diff --git a/exporters/otlp/otlpmetric/otlpmetrichttp/client.go b/exporters/otlp/otlpmetric/otlpmetrichttp/client.go index a362b45087e..2ddba595958 100644 --- a/exporters/otlp/otlpmetric/otlpmetrichttp/client.go +++ b/exporters/otlp/otlpmetric/otlpmetrichttp/client.go @@ -32,6 +32,7 @@ import ( "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/exporters/otlp/internal" "go.opentelemetry.io/otel/exporters/otlp/internal/retry" + "go.opentelemetry.io/otel/exporters/otlp/otlpmetric" ominternal "go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal" "go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal/oconf" "go.opentelemetry.io/otel/sdk/metric" @@ -108,7 +109,7 @@ func newClient(opts ...Option) (ominternal.Client, error) { return nil, err } - req.Header.Set("User-Agent", internal.GetUserAgentHeader()) + req.Header.Set("User-Agent", otlpmetric.GetUserAgentHeader()) if n := len(cfg.Metrics.Headers); n > 0 { for k, v := range cfg.Metrics.Headers { diff --git a/exporters/otlp/otlpmetric/version.go b/exporters/otlp/otlpmetric/version.go new file mode 100644 index 00000000000..23b6c27e8fa --- /dev/null +++ b/exporters/otlp/otlpmetric/version.go @@ -0,0 +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 otlpmetric // import "go.opentelemetry.io/otel/exporters/otlp/otlpmetric" + +// Version is the current release version of the OpenTelemetry OTLP metrics client in use. +func Version() string { + return "1.15.0-rc.2" +} diff --git a/exporters/otlp/otlpmetric/version_test.go b/exporters/otlp/otlpmetric/version_test.go new file mode 100644 index 00000000000..e0f3a3ef3b5 --- /dev/null +++ b/exporters/otlp/otlpmetric/version_test.go @@ -0,0 +1,34 @@ +// 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 otlpmetric_test + +import ( + "regexp" + "testing" + + "github.com/stretchr/testify/assert" + + "go.opentelemetry.io/otel/exporters/otlp/otlpmetric" +) + +// regex taken from https://github.com/Masterminds/semver/tree/v3.1.1 +var versionRegex = regexp.MustCompile(`^v?([0-9]+)(\.[0-9]+)?(\.[0-9]+)?` + + `(-([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?` + + `(\+([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?$`) + +func TestVersionSemver(t *testing.T) { + v := otlpmetric.Version() + assert.NotNil(t, versionRegex.FindStringSubmatch(v), "version is not semver: %s", v) +} From 912a44f03c5b5cbf54ba7173eea879b3e0ccc46c Mon Sep 17 00:00:00 2001 From: Remy Chantenay Date: Fri, 31 Mar 2023 19:53:59 +0200 Subject: [PATCH 2/8] Add Version func to otel/exporters/otlp/otlptrace --- exporters/otlp/otlptrace/header.go | 21 ++++++++++++ exporters/otlp/otlptrace/header_test.go | 27 +++++++++++++++ .../otlptrace/internal/otlpconfig/options.go | 3 +- .../otlp/otlptrace/otlptracehttp/client.go | 2 +- exporters/otlp/otlptrace/version.go | 20 +++++++++++ exporters/otlp/otlptrace/version_test.go | 34 +++++++++++++++++++ 6 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 exporters/otlp/otlptrace/header.go create mode 100644 exporters/otlp/otlptrace/header_test.go create mode 100644 exporters/otlp/otlptrace/version.go create mode 100644 exporters/otlp/otlptrace/version_test.go diff --git a/exporters/otlp/otlptrace/header.go b/exporters/otlp/otlptrace/header.go new file mode 100644 index 00000000000..175b78052bb --- /dev/null +++ b/exporters/otlp/otlptrace/header.go @@ -0,0 +1,21 @@ +// 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 otlptrace // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace" + +// GetUserAgentHeader returns an OTLP header value form "OTel OTLP Exporter Go/{{ .Version }}" +// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#user-agent +func GetUserAgentHeader() string { + return "OTel OTLP Exporter Go/" + Version() +} diff --git a/exporters/otlp/otlptrace/header_test.go b/exporters/otlp/otlptrace/header_test.go new file mode 100644 index 00000000000..ec2ba2aa2fd --- /dev/null +++ b/exporters/otlp/otlptrace/header_test.go @@ -0,0 +1,27 @@ +// 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 otlptrace_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "go.opentelemetry.io/otel/exporters/otlp/otlptrace" +) + +func TestGetUserAgentHeader(t *testing.T) { + require.Regexp(t, "OTel OTLP Exporter Go/1\\..*", otlptrace.GetUserAgentHeader()) +} diff --git a/exporters/otlp/otlptrace/internal/otlpconfig/options.go b/exporters/otlp/otlptrace/internal/otlpconfig/options.go index c48ffd53081..71a504e14dd 100644 --- a/exporters/otlp/otlptrace/internal/otlpconfig/options.go +++ b/exporters/otlp/otlptrace/internal/otlpconfig/options.go @@ -27,6 +27,7 @@ import ( "go.opentelemetry.io/otel/exporters/otlp/internal" "go.opentelemetry.io/otel/exporters/otlp/internal/retry" + "go.opentelemetry.io/otel/exporters/otlp/otlptrace" ) const ( @@ -97,7 +98,7 @@ func NewGRPCConfig(opts ...GRPCOption) Config { Timeout: DefaultTimeout, }, RetryConfig: retry.DefaultConfig, - DialOptions: []grpc.DialOption{grpc.WithUserAgent(internal.GetUserAgentHeader())}, + DialOptions: []grpc.DialOption{grpc.WithUserAgent(otlptrace.GetUserAgentHeader())}, } cfg = ApplyGRPCEnvConfigs(cfg) for _, opt := range opts { diff --git a/exporters/otlp/otlptrace/otlptracehttp/client.go b/exporters/otlp/otlptrace/otlptracehttp/client.go index 9fbe861717d..829c5306291 100644 --- a/exporters/otlp/otlptrace/otlptracehttp/client.go +++ b/exporters/otlp/otlptrace/otlptracehttp/client.go @@ -209,7 +209,7 @@ func (d *client) newRequest(body []byte) (request, error) { return request{Request: r}, err } - r.Header.Set("User-Agent", internal.GetUserAgentHeader()) + r.Header.Set("User-Agent", otlptrace.GetUserAgentHeader()) for k, v := range d.cfg.Headers { r.Header.Set(k, v) diff --git a/exporters/otlp/otlptrace/version.go b/exporters/otlp/otlptrace/version.go new file mode 100644 index 00000000000..a55f0ba1f52 --- /dev/null +++ b/exporters/otlp/otlptrace/version.go @@ -0,0 +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 otlptrace // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace" + +// Version is the current release version of the OpenTelemetry OTLP trace client in use. +func Version() string { + return "1.15.0-rc.2" +} diff --git a/exporters/otlp/otlptrace/version_test.go b/exporters/otlp/otlptrace/version_test.go new file mode 100644 index 00000000000..62558d99751 --- /dev/null +++ b/exporters/otlp/otlptrace/version_test.go @@ -0,0 +1,34 @@ +// 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 otlptrace_test + +import ( + "regexp" + "testing" + + "github.com/stretchr/testify/assert" + + "go.opentelemetry.io/otel/exporters/otlp/otlptrace" +) + +// regex taken from https://github.com/Masterminds/semver/tree/v3.1.1 +var versionRegex = regexp.MustCompile(`^v?([0-9]+)(\.[0-9]+)?(\.[0-9]+)?` + + `(-([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?` + + `(\+([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?$`) + +func TestVersionSemver(t *testing.T) { + v := otlptrace.Version() + assert.NotNil(t, versionRegex.FindStringSubmatch(v), "version is not semver: %s", v) +} From abdf9d1d6b3b6ae8d77d73f6cb33a235c285e56c Mon Sep 17 00:00:00 2001 From: Remy Chantenay Date: Fri, 31 Mar 2023 19:54:35 +0200 Subject: [PATCH 3/8] Remove Version func from otel/exporters/otlp/internal --- exporters/otlp/internal/header.go | 24 ------------------------ exporters/otlp/internal/header_test.go | 26 -------------------------- 2 files changed, 50 deletions(-) delete mode 100644 exporters/otlp/internal/header.go delete mode 100644 exporters/otlp/internal/header_test.go diff --git a/exporters/otlp/internal/header.go b/exporters/otlp/internal/header.go deleted file mode 100644 index 9aa62ed9e8e..00000000000 --- a/exporters/otlp/internal/header.go +++ /dev/null @@ -1,24 +0,0 @@ -// 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 contains common functionality for all OTLP exporters. -package internal // import "go.opentelemetry.io/otel/exporters/otlp/internal" - -import "go.opentelemetry.io/otel" - -// GetUserAgentHeader return an OTLP header value form "OTel OTLP Exporter Go/{{ .Version }}" -// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#user-agent -func GetUserAgentHeader() string { - return "OTel OTLP Exporter Go/" + otel.Version() -} diff --git a/exporters/otlp/internal/header_test.go b/exporters/otlp/internal/header_test.go deleted file mode 100644 index ecca1a9490e..00000000000 --- a/exporters/otlp/internal/header_test.go +++ /dev/null @@ -1,26 +0,0 @@ -// 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 contains common functionality for all OTLP exporters. -package internal // import "go.opentelemetry.io/otel/exporters/otlp/internal" - -import ( - "testing" - - "github.com/stretchr/testify/require" -) - -func TestGetUserAgentHeader(t *testing.T) { - require.Regexp(t, "OTel OTLP Exporter Go/1\\..*", GetUserAgentHeader()) -} From 0c438e0f9545e788a9f966aaa52b78844bc5ea20 Mon Sep 17 00:00:00 2001 From: Remy Chantenay Date: Fri, 31 Mar 2023 19:54:57 +0200 Subject: [PATCH 4/8] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9877807a3c3..2fbe626e64a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Added - The `Version` function to `go.opentelemetry.io/otel/sdk` to return the SDK version. (#3949) +- The `Version` function to `go.opentelemetry.io/otel/exporters/otlp/otlpmetric` to return the OTLP metrics client version. (#3956) +- The `Version` function to `go.opentelemetry.io/otel/exporters/otlp/otlptrace` to return the OTLP trace client version. (#3956) ### Changed From 3615ee86da6e329562b866316130db37b89d9965 Mon Sep 17 00:00:00 2001 From: Remy Chantenay Date: Fri, 31 Mar 2023 19:55:42 +0200 Subject: [PATCH 5/8] Add nolint rule to hostid readFile --- sdk/resource/host_id.go | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/resource/host_id.go b/sdk/resource/host_id.go index 32a616d0879..39e35f4f2bf 100644 --- a/sdk/resource/host_id.go +++ b/sdk/resource/host_id.go @@ -38,6 +38,7 @@ type fileReader func(string) (string, error) type commandExecutor func(string, ...string) (string, error) +// nolint: unused // This is used by the hostReaderBSD, gated by build tags. func readFile(filename string) (string, error) { b, err := os.ReadFile(filename) if err != nil { From 3e1f28fa0547800e4f8cd70905832624baaed624 Mon Sep 17 00:00:00 2001 From: Remy Chantenay Date: Tue, 4 Apr 2023 17:51:45 +0200 Subject: [PATCH 6/8] Move GetUserAgentHeader to internal packages --- .../otlp/{otlptrace => otlpmetric/internal}/header.go | 8 ++++++-- .../{otlptrace => otlpmetric/internal}/header_test.go | 6 ++---- exporters/otlp/otlpmetric/internal/oconf/options.go | 4 ++-- exporters/otlp/otlpmetric/otlpmetrichttp/client.go | 3 +-- .../otlp/{otlpmetric => otlptrace/internal}/header.go | 8 ++++++-- .../{otlpmetric => otlptrace/internal}/header_test.go | 6 ++---- exporters/otlp/otlptrace/internal/otlpconfig/options.go | 4 ++-- exporters/otlp/otlptrace/otlptracehttp/client.go | 3 ++- 8 files changed, 23 insertions(+), 19 deletions(-) rename exporters/otlp/{otlptrace => otlpmetric/internal}/header.go (80%) rename exporters/otlp/{otlptrace => otlpmetric/internal}/header_test.go (81%) rename exporters/otlp/{otlpmetric => otlptrace/internal}/header.go (80%) rename exporters/otlp/{otlpmetric => otlptrace/internal}/header_test.go (81%) diff --git a/exporters/otlp/otlptrace/header.go b/exporters/otlp/otlpmetric/internal/header.go similarity index 80% rename from exporters/otlp/otlptrace/header.go rename to exporters/otlp/otlpmetric/internal/header.go index 175b78052bb..dde06fa8537 100644 --- a/exporters/otlp/otlptrace/header.go +++ b/exporters/otlp/otlpmetric/internal/header.go @@ -12,10 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -package otlptrace // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace" +package internal // import "go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal" + +import ( + "go.opentelemetry.io/otel/exporters/otlp/otlpmetric" +) // GetUserAgentHeader returns an OTLP header value form "OTel OTLP Exporter Go/{{ .Version }}" // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#user-agent func GetUserAgentHeader() string { - return "OTel OTLP Exporter Go/" + Version() + return "OTel OTLP Exporter Go/" + otlpmetric.Version() } diff --git a/exporters/otlp/otlptrace/header_test.go b/exporters/otlp/otlpmetric/internal/header_test.go similarity index 81% rename from exporters/otlp/otlptrace/header_test.go rename to exporters/otlp/otlpmetric/internal/header_test.go index ec2ba2aa2fd..d93340fc0d6 100644 --- a/exporters/otlp/otlptrace/header_test.go +++ b/exporters/otlp/otlpmetric/internal/header_test.go @@ -12,16 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -package otlptrace_test +package internal import ( "testing" "github.com/stretchr/testify/require" - - "go.opentelemetry.io/otel/exporters/otlp/otlptrace" ) func TestGetUserAgentHeader(t *testing.T) { - require.Regexp(t, "OTel OTLP Exporter Go/1\\..*", otlptrace.GetUserAgentHeader()) + require.Regexp(t, "OTel OTLP Exporter Go/1\\..*", GetUserAgentHeader()) } diff --git a/exporters/otlp/otlpmetric/internal/oconf/options.go b/exporters/otlp/otlpmetric/internal/oconf/options.go index eb9abfb324d..e696a0f78ba 100644 --- a/exporters/otlp/otlpmetric/internal/oconf/options.go +++ b/exporters/otlp/otlpmetric/internal/oconf/options.go @@ -27,7 +27,7 @@ import ( "go.opentelemetry.io/otel/exporters/otlp/internal" "go.opentelemetry.io/otel/exporters/otlp/internal/retry" - "go.opentelemetry.io/otel/exporters/otlp/otlpmetric" + ominternal "go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal" "go.opentelemetry.io/otel/internal/global" "go.opentelemetry.io/otel/sdk/metric" "go.opentelemetry.io/otel/sdk/metric/aggregation" @@ -117,7 +117,7 @@ func NewGRPCConfig(opts ...GRPCOption) Config { AggregationSelector: metric.DefaultAggregationSelector, }, RetryConfig: retry.DefaultConfig, - DialOptions: []grpc.DialOption{grpc.WithUserAgent(otlpmetric.GetUserAgentHeader())}, + DialOptions: []grpc.DialOption{grpc.WithUserAgent(ominternal.GetUserAgentHeader())}, } cfg = ApplyGRPCEnvConfigs(cfg) for _, opt := range opts { diff --git a/exporters/otlp/otlpmetric/otlpmetrichttp/client.go b/exporters/otlp/otlpmetric/otlpmetrichttp/client.go index 2ddba595958..8b90a090b87 100644 --- a/exporters/otlp/otlpmetric/otlpmetrichttp/client.go +++ b/exporters/otlp/otlpmetric/otlpmetrichttp/client.go @@ -32,7 +32,6 @@ import ( "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/exporters/otlp/internal" "go.opentelemetry.io/otel/exporters/otlp/internal/retry" - "go.opentelemetry.io/otel/exporters/otlp/otlpmetric" ominternal "go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal" "go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal/oconf" "go.opentelemetry.io/otel/sdk/metric" @@ -109,7 +108,7 @@ func newClient(opts ...Option) (ominternal.Client, error) { return nil, err } - req.Header.Set("User-Agent", otlpmetric.GetUserAgentHeader()) + req.Header.Set("User-Agent", ominternal.GetUserAgentHeader()) if n := len(cfg.Metrics.Headers); n > 0 { for k, v := range cfg.Metrics.Headers { diff --git a/exporters/otlp/otlpmetric/header.go b/exporters/otlp/otlptrace/internal/header.go similarity index 80% rename from exporters/otlp/otlpmetric/header.go rename to exporters/otlp/otlptrace/internal/header.go index a62168c815e..7fcd89a40fb 100644 --- a/exporters/otlp/otlpmetric/header.go +++ b/exporters/otlp/otlptrace/internal/header.go @@ -12,10 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -package otlpmetric // import "go.opentelemetry.io/otel/exporters/otlp/otlpmetric" +package internal // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal" + +import ( + "go.opentelemetry.io/otel/exporters/otlp/otlptrace" +) // GetUserAgentHeader returns an OTLP header value form "OTel OTLP Exporter Go/{{ .Version }}" // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#user-agent func GetUserAgentHeader() string { - return "OTel OTLP Exporter Go/" + Version() + return "OTel OTLP Exporter Go/" + otlptrace.Version() } diff --git a/exporters/otlp/otlpmetric/header_test.go b/exporters/otlp/otlptrace/internal/header_test.go similarity index 81% rename from exporters/otlp/otlpmetric/header_test.go rename to exporters/otlp/otlptrace/internal/header_test.go index acdc87f31fe..d93340fc0d6 100644 --- a/exporters/otlp/otlpmetric/header_test.go +++ b/exporters/otlp/otlptrace/internal/header_test.go @@ -12,16 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -package otlpmetric_test +package internal import ( "testing" "github.com/stretchr/testify/require" - - "go.opentelemetry.io/otel/exporters/otlp/otlpmetric" ) func TestGetUserAgentHeader(t *testing.T) { - require.Regexp(t, "OTel OTLP Exporter Go/1\\..*", otlpmetric.GetUserAgentHeader()) + require.Regexp(t, "OTel OTLP Exporter Go/1\\..*", GetUserAgentHeader()) } diff --git a/exporters/otlp/otlptrace/internal/otlpconfig/options.go b/exporters/otlp/otlptrace/internal/otlpconfig/options.go index 71a504e14dd..1a6bb423b30 100644 --- a/exporters/otlp/otlptrace/internal/otlpconfig/options.go +++ b/exporters/otlp/otlptrace/internal/otlpconfig/options.go @@ -27,7 +27,7 @@ import ( "go.opentelemetry.io/otel/exporters/otlp/internal" "go.opentelemetry.io/otel/exporters/otlp/internal/retry" - "go.opentelemetry.io/otel/exporters/otlp/otlptrace" + otinternal "go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal" ) const ( @@ -98,7 +98,7 @@ func NewGRPCConfig(opts ...GRPCOption) Config { Timeout: DefaultTimeout, }, RetryConfig: retry.DefaultConfig, - DialOptions: []grpc.DialOption{grpc.WithUserAgent(otlptrace.GetUserAgentHeader())}, + DialOptions: []grpc.DialOption{grpc.WithUserAgent(otinternal.GetUserAgentHeader())}, } cfg = ApplyGRPCEnvConfigs(cfg) for _, opt := range opts { diff --git a/exporters/otlp/otlptrace/otlptracehttp/client.go b/exporters/otlp/otlptrace/otlptracehttp/client.go index 829c5306291..be21724212b 100644 --- a/exporters/otlp/otlptrace/otlptracehttp/client.go +++ b/exporters/otlp/otlptrace/otlptracehttp/client.go @@ -33,6 +33,7 @@ import ( "go.opentelemetry.io/otel/exporters/otlp/internal" "go.opentelemetry.io/otel/exporters/otlp/internal/retry" "go.opentelemetry.io/otel/exporters/otlp/otlptrace" + otinternal "go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal" "go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/otlpconfig" coltracepb "go.opentelemetry.io/proto/otlp/collector/trace/v1" tracepb "go.opentelemetry.io/proto/otlp/trace/v1" @@ -209,7 +210,7 @@ func (d *client) newRequest(body []byte) (request, error) { return request{Request: r}, err } - r.Header.Set("User-Agent", otlptrace.GetUserAgentHeader()) + r.Header.Set("User-Agent", otinternal.GetUserAgentHeader()) for k, v := range d.cfg.Headers { r.Header.Set(k, v) From 5174be5c6b3f69f15fe499f949fd06433d710d97 Mon Sep 17 00:00:00 2001 From: Remy Chantenay Date: Tue, 4 Apr 2023 18:22:53 +0200 Subject: [PATCH 7/8] Update exporters/otlp/otlpmetric/version.go Co-authored-by: Tyler Yahn --- exporters/otlp/otlpmetric/version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exporters/otlp/otlpmetric/version.go b/exporters/otlp/otlpmetric/version.go index 23b6c27e8fa..952e6c02226 100644 --- a/exporters/otlp/otlpmetric/version.go +++ b/exporters/otlp/otlpmetric/version.go @@ -14,7 +14,7 @@ package otlpmetric // import "go.opentelemetry.io/otel/exporters/otlp/otlpmetric" -// Version is the current release version of the OpenTelemetry OTLP metrics client in use. +// Version is the current release version of the OpenTelemetry OTLP metrics exporter in use. func Version() string { return "1.15.0-rc.2" } From 4d3676f47c202b0fdcb0168e41b49499cc3df83e Mon Sep 17 00:00:00 2001 From: Remy Chantenay Date: Tue, 4 Apr 2023 18:23:00 +0200 Subject: [PATCH 8/8] Update exporters/otlp/otlptrace/version.go Co-authored-by: Tyler Yahn --- exporters/otlp/otlptrace/version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exporters/otlp/otlptrace/version.go b/exporters/otlp/otlptrace/version.go index a55f0ba1f52..1a1977e975c 100644 --- a/exporters/otlp/otlptrace/version.go +++ b/exporters/otlp/otlptrace/version.go @@ -14,7 +14,7 @@ package otlptrace // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace" -// Version is the current release version of the OpenTelemetry OTLP trace client in use. +// Version is the current release version of the OpenTelemetry OTLP trace exporter in use. func Version() string { return "1.15.0-rc.2" }