Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update/go1.19 #2675

Merged
merged 6 commits into from Aug 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Expand Up @@ -8,7 +8,7 @@ env:
# path to where test results will be saved
TEST_RESULTS: /tmp/test-results
# Default minimum version of Go to support.
DEFAULT_GO_VERSION: 1.17
DEFAULT_GO_VERSION: 1.19
jobs:
lint:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -109,7 +109,7 @@ jobs:
compatibility-test:
strategy:
matrix:
go-version: [1.18, 1.17]
go-version: [1.19, 1.18, 1.17]
os: [ubuntu-latest, macos-latest, windows-latest]
# GitHub Actions does not support arm* architectures on default
# runners. It is possible to acomplish this with a self-hosted runner
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -8,6 +8,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

## [Unreleased]

### Changed

- Use Go 1.19 as the default version for CI testing/linting. (#2675)

## [1.9.0/0.34.0/0.4.0] - 2022-08-02

### Added
Expand Down
7 changes: 2 additions & 5 deletions Makefile
Expand Up @@ -53,9 +53,6 @@ $(MISSPELL): PACKAGE=github.com/client9/misspell/cmd/misspell
GOCOVMERGE = $(TOOLS)/gocovmerge
$(GOCOVMERGE): PACKAGE=github.com/wadey/gocovmerge

ESC = $(TOOLS)/esc
$(ESC): PACKAGE=github.com/mjibson/esc

STRINGER = $(TOOLS)/stringer
$(STRINGER): PACKAGE=golang.org/x/tools/cmd/stringer

Expand All @@ -71,15 +68,15 @@ $(TOOLS)/dbotconf: PACKAGE=go.opentelemetry.io/build-tools/dbotconf
CROSSLINK = $(TOOLS)/crosslink
$(CROSSLINK): PACKAGE=go.opentelemetry.io/build-tools/crosslink

tools: $(GOLANGCI_LINT) $(MISSPELL) $(GOCOVMERGE) $(STRINGER) $(ESC) $(PORTO) $(MULTIMOD) $(DBOTCONF) $(CROSSLINK)
tools: $(GOLANGCI_LINT) $(MISSPELL) $(GOCOVMERGE) $(STRINGER) $(PORTO) $(MULTIMOD) $(DBOTCONF) $(CROSSLINK)

# Build

.PHONY: generate build

generate: $(OTEL_GO_MOD_DIRS:%=generate/%)
generate/%: DIR=$*
generate/%: | $(STRINGER) $(ESC)
generate/%: | $(STRINGER)
@echo "$(GO) generate $(DIR)/..." \
&& cd $(DIR) \
&& PATH="$(TOOLS):$${PATH}" $(GO) generate ./...
Expand Down
26 changes: 21 additions & 5 deletions README.md
Expand Up @@ -22,25 +22,41 @@ board](https://github.com/orgs/open-telemetry/projects/5).

### Compatibility

OpenTelemetry-Go Contrib attempts to track the current supported versions of the
[Go language](https://golang.org/doc/devel/release#policy). The release
schedule after a new minor version of go is as follows:

- The first release or one month, which ever is sooner, will add build steps for the new go version.
- The first release after three months will remove support for the oldest go version.
OpenTelemetry-Go Contrib ensures compatibility with the current supported
versions of
the [Go language](https://golang.org/doc/devel/release#policy):

> Each major Go release is supported until there are two newer major releases.
> For example, Go 1.5 was supported until the Go 1.7 release, and Go 1.6 was supported until the Go 1.8 release.

For versions of Go that are no longer supported upstream, opentelemetry-go-contrib will
stop ensuring compatibility with these versions in the following manner:

- A minor release of opentelemetry-go-contrib will be made to add support for the new
supported release of Go.
- The following minor release of opentelemetry-go-contrib will remove compatibility
testing for the oldest (now archived upstream) version of Go. This, and
future, releases of opentelemetry-go-contrib may include features only supported by
the currently supported versions of Go.

This project is tested on the following systems.

| OS | Go Version | Architecture |
| ------- | ---------- | ------------ |
| Ubuntu | 1.19 | amd64 |
| Ubuntu | 1.18 | amd64 |
| Ubuntu | 1.17 | amd64 |
| Ubuntu | 1.19 | 386 |
| Ubuntu | 1.18 | 386 |
| Ubuntu | 1.17 | 386 |
| MacOS | 1.19 | amd64 |
| MacOS | 1.18 | amd64 |
| MacOS | 1.17 | amd64 |
| Windows | 1.19 | amd64 |
| Windows | 1.18 | amd64 |
| Windows | 1.17 | amd64 |
| Windows | 1.19 | 386 |
| Windows | 1.18 | 386 |
| Windows | 1.17 | 386 |

Expand Down
2 changes: 1 addition & 1 deletion detectors/aws/ec2/ec2.go
Expand Up @@ -79,7 +79,7 @@ type Client interface {
// compile time assertion that resourceDetector implements the resource.Detector interface.
var _ resource.Detector = (*resourceDetector)(nil)

//NewResourceDetector returns a resource detector that will detect AWS EC2 resources.
// NewResourceDetector returns a resource detector that will detect AWS EC2 resources.
func NewResourceDetector(opts ...Option) resource.Detector {
c := newConfig(opts...)
return &resourceDetector{c.getClient()}
Expand Down
3 changes: 1 addition & 2 deletions detectors/aws/ecs/ecs.go
Expand Up @@ -17,7 +17,6 @@ package ecs // import "go.opentelemetry.io/contrib/detectors/aws/ecs"
import (
"context"
"errors"
"io/ioutil"
"os"
"strings"

Expand Down Expand Up @@ -95,7 +94,7 @@ func (detector *resourceDetector) Detect(ctx context.Context) (*resource.Resourc

// returns docker container ID from default c group path.
func (ecsUtils ecsDetectorUtils) getContainerID() (string, error) {
fileData, err := ioutil.ReadFile(defaultCgroupPath)
fileData, err := os.ReadFile(defaultCgroupPath)
if err != nil {
return "", errCannotReadCGroupFile
}
Expand Down
8 changes: 4 additions & 4 deletions detectors/aws/ecs/ecs_test.go
Expand Up @@ -42,7 +42,7 @@ func (detectorUtils *MockDetectorUtils) getContainerName() (string, error) {
return args.String(0), args.Error(1)
}

//succesfully return resource when process is running on Amazon ECS environment.
// successfully return resource when process is running on Amazon ECS environment.
func TestDetect(t *testing.T) {
os.Clearenv()
_ = os.Setenv(metadataV3EnvVar, "3")
Expand All @@ -66,7 +66,7 @@ func TestDetect(t *testing.T) {
assert.Equal(t, res, expectedResource, "Resource returned is incorrect")
}

//returns empty resource when detector cannot read container ID.
// returns empty resource when detector cannot read container ID.
func TestDetectCannotReadContainerID(t *testing.T) {
os.Clearenv()
_ = os.Setenv(metadataV3EnvVar, "3")
Expand All @@ -83,7 +83,7 @@ func TestDetectCannotReadContainerID(t *testing.T) {
assert.Equal(t, 0, len(res.Attributes()))
}

//returns empty resource when detector cannot read container Name.
// returns empty resource when detector cannot read container Name.
func TestDetectCannotReadContainerName(t *testing.T) {
os.Clearenv()
_ = os.Setenv(metadataV3EnvVar, "3")
Expand All @@ -100,7 +100,7 @@ func TestDetectCannotReadContainerName(t *testing.T) {
assert.Equal(t, 0, len(res.Attributes()))
}

//returns empty resource when process is not running ECS.
// returns empty resource when process is not running ECS.
func TestReturnsIfNoEnvVars(t *testing.T) {
os.Clearenv()
detector := &resourceDetector{utils: nil}
Expand Down
3 changes: 1 addition & 2 deletions detectors/aws/eks/detector.go
Expand Up @@ -17,7 +17,6 @@ package eks // import "go.opentelemetry.io/contrib/detectors/aws/eks"
import (
"context"
"fmt"
"io/ioutil"
"os"
"regexp"
"strings"
Expand Down Expand Up @@ -181,7 +180,7 @@ func getClusterName(ctx context.Context, utils detectorUtils) (string, error) {

// getContainerID returns the containerID if currently running within a container.
func (eksUtils eksDetectorUtils) getContainerID() (string, error) {
fileData, err := ioutil.ReadFile(defaultCgroupPath)
fileData, err := os.ReadFile(defaultCgroupPath)
if err != nil {
return "", fmt.Errorf("getContainerID() error: cannot read file with path %s: %w", defaultCgroupPath, err)
}
Expand Down
Expand Up @@ -17,9 +17,8 @@ package main
import (
"flag"
"fmt"
"io/ioutil"
"io"
"log"

"net/http"
)

Expand All @@ -40,7 +39,7 @@ func main() {
log.Fatal(err)
}

body, err := ioutil.ReadAll(res.Body)
body, err := io.ReadAll(res.Body)
if err != nil {
log.Fatal(err)
}
Expand Down
Expand Up @@ -17,7 +17,7 @@ package test
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"os"
Expand Down Expand Up @@ -190,8 +190,9 @@ func TestStatic(t *testing.T) {
sr := tracetest.NewSpanRecorder()
tracerProvider := trace.NewTracerProvider(trace.WithSpanProcessor(sr))
meterProvider, metricExporter := metrictest.NewTestMeterProvider()
file, err := ioutil.TempFile("", "static-*.html")
file, err := os.CreateTemp("", "static-*.html")
require.NoError(t, err)
defer file.Close()
defer os.Remove(file.Name())
_, err = file.WriteString(beego.Htmlunquote("<h1>Hello, world!</h1>"))
require.NoError(t, err)
Expand All @@ -214,7 +215,7 @@ func TestStatic(t *testing.T) {
}

require.Equal(t, http.StatusOK, rr.Result().StatusCode)
body, err := ioutil.ReadAll(rr.Result().Body)
body, err := io.ReadAll(rr.Result().Body)
require.NoError(t, err)
require.Equal(t, "<h1>Hello, world!</h1>", string(body))
spans := sr.Ended()
Expand All @@ -233,13 +234,12 @@ func TestRender(t *testing.T) {
"<body>This is a template test. Hello {{.name}}</body></html>"

// Create a temp directory to hold a view
dir, err := ioutil.TempDir("", "views")
defer os.RemoveAll(dir)
require.NoError(t, err)
dir := t.TempDir()

// Create the view
file, err := ioutil.TempFile(dir, "*index.tpl")
file, err := os.CreateTemp(dir, "*index.tpl")
require.NoError(t, err)
defer file.Close()
_, err = file.WriteString(htmlStr)
require.NoError(t, err)
// Add path to view path
Expand All @@ -259,7 +259,7 @@ func TestRender(t *testing.T) {
req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("http://localhost/template%s", str), nil)
require.NoError(t, err)
mw(beego.BeeApp.Handlers).ServeHTTP(rr, req)
body, err := ioutil.ReadAll(rr.Result().Body)
body, err := io.ReadAll(rr.Result().Body)
require.Equal(t, strings.Replace(htmlStr, "{{.name}}", "test", 1), string(body))
require.NoError(t, err)
}
Expand Down Expand Up @@ -313,7 +313,7 @@ func runTest(t *testing.T, tc *testCase, url string) {
mw(beego.BeeApp.Handlers).ServeHTTP(rr, req)

require.Equal(t, tc.expectedHTTPStatus, rr.Result().StatusCode)
body, err := ioutil.ReadAll(rr.Result().Body)
body, err := io.ReadAll(rr.Result().Body)
require.NoError(t, err)
message := testReply{}
require.NoError(t, json.Unmarshal(body, &message))
Expand Down
Expand Up @@ -19,7 +19,7 @@
//
// Instrumentation of an incoming request is achieved via a go-restful
// FilterFunc called `OTelFilterFunc` which may be applied at any one of
// * the container level
// * webservice level
// * route level
// - the container level
// - webservice level
// - route level
package otelrestful // import "go.opentelemetry.io/contrib/instrumentation/github.com/emicklei/go-restful/otelrestful"
Expand Up @@ -60,7 +60,7 @@ func WithTracerProvider(provider oteltrace.TracerProvider) Option {
})
}

//WithSkipper specifies a skipper for allowing requests to skip generating spans.
// WithSkipper specifies a skipper for allowing requests to skip generating spans.
func WithSkipper(skipper middleware.Skipper) Option {
return optionFunc(func(cfg *config) {
cfg.Skipper = skipper
Expand Down
14 changes: 8 additions & 6 deletions instrumentation/host/doc.go
Expand Up @@ -21,13 +21,15 @@
//
// The metric events produced are listed here with attribute dimensions.
//
// Name Attribute
// Name Attribute
//
// ----------------------------------------------------------------------
// process.cpu.time state=user|system
// system.cpu.time state=user|system|other|idle
// system.memory.usage state=used|available
// system.memory.utilization state=used|available
// system.network.io direction=transmit|receive
//
// process.cpu.time state=user|system
// system.cpu.time state=user|system|other|idle
// system.memory.usage state=used|available
// system.memory.utilization state=used|available
// system.network.io direction=transmit|receive
//
// See https://github.com/open-telemetry/oteps/blob/main/text/0119-standard-system-metrics.md
// for the definition of these metric instruments.
Expand Down
Expand Up @@ -18,7 +18,7 @@ import (
"context"
"flag"
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"net/http/httptrace"
Expand Down Expand Up @@ -88,7 +88,7 @@ func main() {
if err != nil {
panic(err)
}
body, err = ioutil.ReadAll(res.Body)
body, err = io.ReadAll(res.Body)
_ = res.Body.Close()

return err
Expand Down
8 changes: 4 additions & 4 deletions instrumentation/net/http/otelhttp/config.go
Expand Up @@ -166,10 +166,10 @@ const (
// end of the request.
//
// Valid events are:
// * ReadEvents: Record the number of bytes read after every http.Request.Body.Read
// using the ReadBytesKey
// * WriteEvents: Record the number of bytes written after every http.ResponeWriter.Write
// using the WriteBytesKey
// - ReadEvents: Record the number of bytes read after every http.Request.Body.Read
// using the ReadBytesKey
// - WriteEvents: Record the number of bytes written after every http.ResponeWriter.Write
// using the WriteBytesKey
func WithMessageEvents(events ...event) Option {
return optionFunc(func(c *config) {
for _, e := range events {
Expand Down
4 changes: 2 additions & 2 deletions instrumentation/net/http/otelhttp/example/client/client.go
Expand Up @@ -18,7 +18,7 @@ import (
"context"
"flag"
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"time"
Expand Down Expand Up @@ -84,7 +84,7 @@ func main() {
if err != nil {
panic(err)
}
body, err = ioutil.ReadAll(res.Body)
body, err = io.ReadAll(res.Body)
_ = res.Body.Close()

return err
Expand Down
5 changes: 2 additions & 3 deletions instrumentation/net/http/otelhttp/handler_example_test.go
Expand Up @@ -4,7 +4,7 @@
// 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
// 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,
Expand All @@ -17,7 +17,6 @@ import (
"context"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"strings"
Expand Down Expand Up @@ -78,7 +77,7 @@ func ExampleNewHandler() {
return
}

d, err := ioutil.ReadAll(r.Body)
d, err := io.ReadAll(r.Body)
if err != nil {
log.Println("error reading body: ", err)
w.WriteHeader(http.StatusBadRequest)
Expand Down