Skip to content

Commit

Permalink
Merge branch 'main' into oc-bridge-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlias committed Aug 6, 2021
2 parents 876414d + d18c135 commit 3801b4c
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 431 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

### Added

- Added `ErrorHandlerFunc` to use a function as an `"go.opentelemetry.io/otel".ErrorHandler`. (#2149)

### Changed

### Deprecated
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ $(TOOLS)/%: | $(TOOLS)
cd $(TOOLS_MOD_DIR) && \
$(GO) build -o $@ $(PACKAGE)

SEMCONVGEN = $(TOOLS)/semconv-gen
$(TOOLS)/semconv-gen: PACKAGE=go.opentelemetry.io/otel/$(TOOLS_MOD_DIR)/semconv-gen
SEMCONVGEN = $(TOOLS)/semconvgen
$(TOOLS)/semconvgen: PACKAGE=go.opentelemetry.io/build-tools/semconvgen

CROSSLINK = $(TOOLS)/crosslink
$(TOOLS)/crosslink: PACKAGE=go.opentelemetry.io/otel/$(TOOLS_MOD_DIR)/crosslink
Expand Down
9 changes: 4 additions & 5 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
## Semantic Convention Generation

If a new version of the OpenTelemetry Specification has been released it will be necessary to generate a new
semantic convention package from the YAML definitions in the specification repository. There is a utility in
`internal/tools/semconv-gen` that can be used to generate the a package with the name matching the specification
semantic convention package from the YAML definitions in the specification repository. There is a `semconvgen` utility
installed by `make tools` that can be used to generate the a package with the name matching the specification
version number under the `semconv` package. This will ideally be done soon after the specification release is
tagged. Make sure that the specification repo contains a checkout of the the latest tagged release so that the
generated files match the released semantic conventions.

There are currently two categories of semantic conventions that must be generated, `resource` and `trace`.

```
cd internal/tools/semconv-gen
go run generator.go -i /path/to/specification/repo/semantic_conventions/resource
go run generator.go -i /path/to/specification/repo/semantic_conventions/trace
.tools/semconvgen -i /path/to/specification/repo/semantic_conventions/resource -t semconv/template.j2
.tools/semconvgen -i /path/to/specification/repo/semantic_conventions/trace -t semconv/template.j2
```

Using default values for all options other than `input` will result in using the `template.j2` template to
Expand Down
15 changes: 6 additions & 9 deletions bridge/opencensus/test/bridge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,27 +267,24 @@ func TestSetThings(t *testing.T) {
if v := aeAttrs[attribute.Key("string")]; v.AsString() != "annotateval" {
t.Errorf("Got annotateEvent.Attributes[string] = %v, expected annotateval", v.AsString())
}

uncompressedKey := attribute.Key("uncompressed byte size")
compressedKey := attribute.Key("compressed byte size")
seAttrs := attrsMap(sendEvent.Attributes)
reAttrs := attrsMap(receiveEvent.Attributes)
if sendEvent.Name != "message send" {
if sendEvent.Name != internal.MessageSendEvent {
t.Errorf("Got sendEvent.Name = %v, expected message send", sendEvent.Name)
}
if v := seAttrs[uncompressedKey]; v.AsInt64() != 456 {
if v := seAttrs[internal.UncompressedKey]; v.AsInt64() != 456 {
t.Errorf("Got sendEvent.Attributes[uncompressedKey] = %v, expected 456", v.AsInt64())
}
if v := seAttrs[compressedKey]; v.AsInt64() != 789 {
if v := seAttrs[internal.CompressedKey]; v.AsInt64() != 789 {
t.Errorf("Got sendEvent.Attributes[compressedKey] = %v, expected 789", v.AsInt64())
}
if receiveEvent.Name != "message receive" {
if receiveEvent.Name != internal.MessageReceiveEvent {
t.Errorf("Got receiveEvent.Name = %v, expected message receive", receiveEvent.Name)
}
if v := reAttrs[uncompressedKey]; v.AsInt64() != 135 {
if v := reAttrs[internal.UncompressedKey]; v.AsInt64() != 135 {
t.Errorf("Got receiveEvent.Attributes[uncompressedKey] = %v, expected 135", v.AsInt64())
}
if v := reAttrs[compressedKey]; v.AsInt64() != 369 {
if v := reAttrs[internal.CompressedKey]; v.AsInt64() != 369 {
t.Errorf("Got receiveEvent.Attributes[compressedKey] = %v, expected 369", v.AsInt64())
}
}
11 changes: 11 additions & 0 deletions error_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,14 @@ type ErrorHandler interface {
// DO NOT CHANGE: any modification will not be backwards compatible and
// must never be done outside of a new major release.
}

// ErrorHandlerFunc is a convenience adapter to allow the use of a function
// as an ErrorHandler.
type ErrorHandlerFunc func(error)

var _ ErrorHandler = ErrorHandlerFunc(nil)

// Handle handles the irremediable error by calling the ErrorHandlerFunc itself.
func (f ErrorHandlerFunc) Handle(err error) {
f(err)
}
3 changes: 1 addition & 2 deletions internal/tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ require (
github.com/gogo/protobuf v1.3.2
github.com/golangci/golangci-lint v1.41.1
github.com/itchyny/gojq v0.12.4
github.com/spf13/pflag v1.0.5
golang.org/x/mod v0.4.2
go.opentelemetry.io/build-tools/semconvgen v0.0.0-20210730171444-520d53fe242d
golang.org/x/tools v0.1.5
)

Expand Down
4 changes: 4 additions & 0 deletions internal/tools/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,10 @@ go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opentelemetry.io/build-tools v0.0.0-20210719163622-92017e64f35b h1:tFMjUqEDGM2F82663yYidqTluwEJmmihk/AXr19J7rI=
go.opentelemetry.io/build-tools v0.0.0-20210719163622-92017e64f35b/go.mod h1:zZRrJN8qdwDdPNkCEyww4SW54mM1Da0v9H3TyQet9T4=
go.opentelemetry.io/build-tools/semconvgen v0.0.0-20210730171444-520d53fe242d h1:EjYSijh2wWPht3w0Zfa6V7280z5iDBr1228TysQgurM=
go.opentelemetry.io/build-tools/semconvgen v0.0.0-20210730171444-520d53fe242d/go.mod h1:QJyAzHKDKGDl52AUIAZhWKx3nOPBZJ3dD44utso2FPE=
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
Expand Down
Loading

0 comments on commit 3801b4c

Please sign in to comment.