Skip to content

Commit

Permalink
update version source
Browse files Browse the repository at this point in the history
  • Loading branch information
SpencerTorres committed Aug 30, 2024
1 parent ad0923b commit 7ccb221
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 23 deletions.
11 changes: 4 additions & 7 deletions exporter/clickhouseexporter/integration_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

//go:build integration
// +build integration

package clickhouseexporter

import (
Expand All @@ -27,10 +24,10 @@ func TestIntegration(t *testing.T) {
image string
}{
// TODO: Skipping due to https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/32530
// {
// name: "test clickhouse 24-alpine",
// image: "clickhouse/clickhouse-server:24-alpine",
// },
{
name: "test clickhouse 24-alpine",
image: "clickhouse/clickhouse-server:24-alpine",
},
// {
// name: "test clickhouse 23-alpine",
// image: "clickhouse/clickhouse-server:23-alpine",
Expand Down
21 changes: 5 additions & 16 deletions exporter/clickhouseexporter/version_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,26 @@ package clickhouseexporter
import (
"runtime"
"runtime/debug"
"strings"
"sync"
)

var (
once sync.Once
cachedVersion string
once sync.Once
version string
)

func getCollectorVersion() string {
once.Do(func() {
osInformation := runtime.GOOS[:3] + "-" + runtime.GOARCH
unknownVersion := "unknown-" + osInformation
version = "unknown-" + osInformation

info, ok := debug.ReadBuildInfo()
if !ok {
cachedVersion = unknownVersion
return
}

for _, mod := range info.Deps {
if mod.Path == "go.opentelemetry.io/collector" {
// Extract the semantic version without metadata.
semVer := strings.SplitN(mod.Version, "-", 2)[0]
cachedVersion = semVer + "-" + osInformation
return
}
}

cachedVersion = unknownVersion
version = info.Main.Version + "-" + osInformation
})

return cachedVersion
return version
}

0 comments on commit 7ccb221

Please sign in to comment.