Skip to content

Commit

Permalink
feat(agent): fix version.
Browse files Browse the repository at this point in the history
  • Loading branch information
Luiz Pegoraro committed Oct 12, 2023
1 parent 54a48aa commit 75343bc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ GO_OS ?= $(shell dpkg-architecture -q DEB_TARGET_ARCH_OS)
DIODE_TAG ?= develop
ORB_VERSION = $(shell cat VERSION)
COMMIT_HASH = $(shell git rev-parse --short HEAD)
OTEL_COLLECTOR_CONTRIB_VERSION ?= 0.81.0
OTEL_COLLECTOR_CONTRIB_VERSION ?= 0.87.0
OTEL_CONTRIB_URL ?= "https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v$(OTEL_COLLECTOR_CONTRIB_VERSION)/otelcol-contrib_$(OTEL_COLLECTOR_CONTRIB_VERSION)_$(GO_OS)_$(GOARCH).tar.gz"

define compile_service
Expand Down
32 changes: 15 additions & 17 deletions agent/backend/otel/otel.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,26 +95,24 @@ func (o *openTelemetryBackend) Version() (string, error) {
return o.otelCurrVersion, nil
}
ctx, cancel := context.WithTimeout(o.mainContext, 60*time.Second)
defer cancel()
var versionOutput string
command := cmd.NewCmdOptions(defaultCmdOptions, o.otelExecutablePath, "--version")
go func() {
status := command.Start()
select {
case stdout := <-command.Stdout:
o.logger.Info("running opentelemetry-contrib version", zap.String("stdout", stdout))
o.otelCurrVersion = stdout
break
case stderr := <-command.Stderr:
o.logger.Error("error during getting version", zap.String("stderr", stderr))
case <-ctx.Done():
o.logger.Error("timeout during getting version", zap.Error(ctx.Err()))
case _ = <-status:
break
command := cmd.NewCmd(o.otelExecutablePath, "--version")
status := command.Start()
select {
case finalStatus := <-status:
if finalStatus.Error != nil {
o.logger.Error("error during call of otelcol-contrib version", zap.Error(finalStatus.Error))
} else {
output := finalStatus.Stdout
o.otelCurrVersion = output[0]
versionOutput = output[0]
}
case <-ctx.Done():
o.logger.Error("timeout during getting version", zap.Error(ctx.Err()))
}

o.logger.Info("running opentelemetry-contrib version", zap.String("version", versionOutput))
}()
cancel()
o.logger.Info("running opentelemetry-contrib version", zap.String("version", versionOutput))

return versionOutput, nil

Expand Down

0 comments on commit 75343bc

Please sign in to comment.