Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

Commit

Permalink
Move version accessor to the opencensus package (#781)
Browse files Browse the repository at this point in the history
Version returns the OpenCensus library version. It is not an exporter utility.
If it is an exporter utility, it shouldnt be in exportutil. In Go, utility packages
are organized under an existing package.

For example, io/iotuil or net/http/httputil.

Fixes #779.
  • Loading branch information
rakyll authored Jun 6, 2018
1 parent 57c7434 commit 0dabe09
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
8 changes: 7 additions & 1 deletion exporterutil/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,14 @@
// limitations under the License.

// Package exporterutil contains common utilities for exporter implementations.
//
// Deprecated: Don't use this package.
package exporterutil

import opencensus "go.opencensus.io"

// Version is the current release version of OpenCensus in use. It is made
// available for exporters to include in User-Agent-like metadata.
var Version = "0.13.0"
var Version = opencensus.Version()

// TODO(jbd): Remove this package at the next release.
8 changes: 4 additions & 4 deletions internal/check/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"strconv"
"strings"

"go.opencensus.io/exporterutil"
opencensus "go.opencensus.io"
)

func main() {
Expand All @@ -48,12 +48,12 @@ func main() {
return versionLess(versions[i], versions[j])
})
latest := versions[len(versions)-1]
codeVersion := parseVersion("v" + exporterutil.Version)
codeVersion := parseVersion("v" + opencensus.Version())
if !versionLess(latest, codeVersion) {
fmt.Printf("exporterutil.Version is out of date with Git tags. Got %s; want %s\n", latest, exporterutil.Version)
fmt.Printf("exporter.Version is out of date with Git tags. Got %s; want %s\n", latest, opencensus.Version())
os.Exit(1)
}
fmt.Printf("exporterutil.Version is up-to-date: %s\n", exporterutil.Version)
fmt.Printf("exporter.Version is up-to-date: %s\n", opencensus.Version())
}

type version [3]int
Expand Down
4 changes: 2 additions & 2 deletions internal/internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import (
"fmt"
"time"

"go.opencensus.io/exporterutil"
"go.opencensus.io"
)

// UserAgent is the user agent to be added to the outgoing
// requests from the exporters.
var UserAgent = fmt.Sprintf("opencensus-go [%s]", exporterutil.Version)
var UserAgent = fmt.Sprintf("opencensus-go [%s]", opencensus.Version())

// MonotonicEndTime returns the end time at present
// but offset from start, monotonically.
Expand Down
5 changes: 5 additions & 0 deletions doc.go → opencensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@

// Package opencensus contains Go support for OpenCensus.
package opencensus // import "go.opencensus.io"

// Version is the current release version of OpenCensus in use.
func Version() string {
return "0.13.0"
}

0 comments on commit 0dabe09

Please sign in to comment.