Skip to content

Commit

Permalink
Log build CGO_ENABLED state (temporalio#2509)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexshtin authored Feb 22, 2022
1 parent 61b9b65 commit 0a76b2a
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
5 changes: 5 additions & 0 deletions build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import (
"embed"
"encoding/json"
"time"

"go.temporal.io/server/build/cgo"
)

const (
Expand All @@ -40,6 +42,8 @@ type (
GitRevision string
// BuildTimeUnix is the seconds since epoch representing the date this build was created.
BuildTimeUnix int64
// CgoEnabled indicates whether cgo was enabled when this build was created.
CgoEnabled bool
}
)

Expand All @@ -53,6 +57,7 @@ func init() {
InfoData = Info{
GitRevision: "unknown",
BuildTimeUnix: 0,
CgoEnabled: cgo.Enabled,
}

buildInfoDataJson, err := buildInfoFs.ReadFile(buildInfoDataFile)
Expand Down
31 changes: 31 additions & 0 deletions build/cgo/cgo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// The MIT License
//
// Copyright (c) 2020 Temporal Technologies Inc. All rights reserved.
//
// Copyright (c) 2020 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

//go:build cgo

package cgo

const (
Enabled = true
)
31 changes: 31 additions & 0 deletions build/cgo/nocgo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// The MIT License
//
// Copyright (c) 2020 Temporal Technologies Inc. All rights reserved.
//
// Copyright (c) 2020 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

//go:build !cgo

package cgo

const (
Enabled = false
)
1 change: 1 addition & 0 deletions cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ func buildCLI() *cli.App {
tag.NewStringTag("platform", runtime.GOARCH),
tag.NewStringTag("go-version", runtime.Version()),
tag.NewStringTag("server-version", headers.ServerVersion),
tag.NewBoolTag("cgo-enabled", build.InfoData.CgoEnabled),
)

var dynamicConfigClient dynamicconfig.Client
Expand Down

0 comments on commit 0a76b2a

Please sign in to comment.