Skip to content

Commit

Permalink
fix: Release codes
Browse files Browse the repository at this point in the history
Release codes used for error reporting are now properly formatted and
also reported on the 'version' command.
  • Loading branch information
bcessa committed Jul 31, 2022
1 parent f1fb126 commit 0524176
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 961 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pkg?="..."
# locally (on a dev container) or using a builder image.
buf:=buf
ifndef REMOTE_CONTAINERS_SOCKETS
buf=docker run --platform linux/amd64 --rm -it -v $(shell pwd):/workdir ghcr.io/bryk-io/buf-builder:1.5.0 buf
buf=docker run --platform linux/amd64 --rm -it -v $(shell pwd):/workdir ghcr.io/bryk-io/buf-builder:1.7.0 buf
endif

help:
Expand Down
1 change: 1 addition & 0 deletions client/cli/cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var versionCmd = &cobra.Command{
"Build code": info.BuildCode,
"OS/Arch": fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH),
"Go version": runtime.Version(),
"Release": conf.ReleaseCode(),
}
if info.BuildTimestamp != "" {
rd, err := time.Parse(time.RFC3339, info.BuildTimestamp)
Expand Down
30 changes: 27 additions & 3 deletions client/internal/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package internal
import (
"fmt"
"path/filepath"
"strings"
"time"

"github.com/aidtechnology/did-method/info"
Expand Down Expand Up @@ -153,9 +154,8 @@ func (s *Settings) OTEL(log xlog.Logger) []otel.OperatorOption {
}

// Error reporter
sentryInfo := s.Agent.OTEL.Sentry
if sentryInfo.DSN != "" {
rep, err := sentry.Reporter(sentryInfo.DSN, sentryInfo.Env, info.CoreVersion)
if sentryInfo := s.Agent.OTEL.Sentry; sentryInfo.DSN != "" {
rep, err := sentry.Reporter(sentryInfo.DSN, sentryInfo.Env, s.ReleaseCode())
if err == nil {
opts = append(opts, otel.WithErrorReporter(rep))
}
Expand Down Expand Up @@ -257,6 +257,30 @@ func (s *Settings) SetDefaults(v *viper.Viper, home, appID string) {
})
}

// ReleaseCode returns the release identifier for the application. A release
// identifier is of the form: `service-name@version+commit_hash`. If `version`
// or `commit_hash` are not available will be omitted.
func (s *Settings) ReleaseCode() string {
// use service name
release := serviceName

// attach version tag. manually set value by default but prefer the one set
// at build time if available
version := s.Agent.OTEL.ServiceVersion
if strings.Count(info.CoreVersion, ".") >= 2 {
version = info.CoreVersion
}
if version != "" {
release = fmt.Sprintf("%s@%s", release, version)
}

// attach commit hash if available
if info.BuildCode != "" {
release = fmt.Sprintf("%s+%s", release, info.BuildCode)
}
return release
}

// Configuration settings available when running an agent instance.
type agent struct {
PoW uint `json:"pow" yaml:"pow" mapstructure:"pow"`
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ require (
github.com/kennygrant/sanitize v1.2.4
github.com/spf13/cobra v1.5.0
github.com/spf13/viper v1.12.0
go.bryk.io/pkg v0.0.0-20220727144146-0045a4e25d12
go.bryk.io/pkg v0.0.0-20220729163329-49b6a33b3621
go.mongodb.org/mongo-driver v1.10.0
go.opentelemetry.io/otel v1.8.0
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa
google.golang.org/genproto v0.0.0-20220719170305-83ca9fad585f
google.golang.org/grpc v1.48.0
google.golang.org/protobuf v1.28.0
google.golang.org/protobuf v1.28.1
storj.io/drpc v0.0.32
)
960 changes: 8 additions & 952 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion helm/didctl/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: didctl
description: Network agent deployment for the "bryk" DID method
type: application
version: 0.2.1
appVersion: 0.9.0
appVersion: 0.9.1
home: https://github.com/bryk-io/did-method
icon: https://raw.githubusercontent.com/bryk-io/did-method/master/helm/didctl/icon.png
sources:
Expand Down
2 changes: 1 addition & 1 deletion proto/did/v1/agent_api.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions proto/did/v1/agent_api.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"parameters": [
{
"name": "body",
"description": "Mutation request, either to publish or deactivate a DID record.",
"in": "body",
"required": true,
"schema": {
Expand Down
2 changes: 1 addition & 1 deletion proto/did/v1/agent_api_drpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0524176

Please sign in to comment.