Skip to content

Commit

Permalink
Merge branch 'main' into no-sum-hist
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlias committed Jul 18, 2023
2 parents 9cdbaa3 + 9b0c4d2 commit 363fd3c
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 112 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

- Correctly format log messages from the `go.opentelemetry.io/otel/exporters/zipkin` exporter. (#4143)
- Log an error for calls to `NewView` in `go.opentelemetry.io/otel/sdk/metric` that have empty criteria. (#4307)
- Fix `resource.WithHostID()` to not set an empty `host.id`. (#4317)

## [1.16.0/0.39.0] 2023-05-18

Expand Down
111 changes: 0 additions & 111 deletions sdk/metric/internal/aggregate/aggregator_example_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion sdk/resource/host_id_readfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import "os"
func readFile(filename string) (string, error) {
b, err := os.ReadFile(filename)
if err != nil {
return "", nil
return "", err
}

return string(b), nil
Expand Down
53 changes: 53 additions & 0 deletions sdk/resource/host_id_readfile_test.go
Original file line number Diff line number Diff line change
@@ -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.

//go:build linux || dragonfly || freebsd || netbsd || openbsd || solaris

package resource

import (
"os"
"testing"

"github.com/stretchr/testify/require"
)

func TestReadFileExistent(t *testing.T) {
fileContents := "foo"

f, err := os.CreateTemp("", "readfile_")
require.NoError(t, err)

defer os.Remove(f.Name())

_, err = f.WriteString(fileContents)
require.NoError(t, err)
require.NoError(t, f.Close())

result, err := readFile(f.Name())
require.NoError(t, err)
require.Equal(t, result, fileContents)
}

func TestReadFileNonExistent(t *testing.T) {
// create unique filename
f, err := os.CreateTemp("", "readfile_")
require.NoError(t, err)

// make file non-existent
require.NoError(t, os.Remove(f.Name()))

_, err = readFile(f.Name())
require.ErrorIs(t, err, os.ErrNotExist)
}

0 comments on commit 363fd3c

Please sign in to comment.