Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Set metrics values using ldflags
Browse files Browse the repository at this point in the history
  • Loading branch information
meain committed Oct 13, 2022
1 parent f1f6c06 commit 0240f31
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ jobs:
workdir: src
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RUDDERSTACK_CORSO_WRITE_KEY: ${{ secrets.RUDDERSTACK_CORSO_WRITE_KEY }}
RUDDERSTACK_CORSO_DATA_PLANE_URL: ${{ secrets.RUDDERSTACK_CORSO_DATA_PLANE_URL }}

- name: Upload assets
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -303,6 +305,7 @@ jobs:

- name: Build Corso Binaries
run: >
export CORSO_BUILD_LDFLAGS="-X 'github.com/alcionai/corso/src/internal/events.RudderStackWriteKey=${{ secrets.RUDDERSTACK_CORSO_WRITE_KEY }}' -X 'github.com/alcionai/corso/src/internal/events.RudderStackDataPlaneURL=${{ secrets.RUDDERSTACK_CORSO_DATA_PLANE_URL }}'"
./build.sh
--platforms ${{ env.PLATFORMS }}
Expand Down
2 changes: 1 addition & 1 deletion build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ do
--env GOARCH=${GOARCH} \
--entrypoint /usr/local/go/bin/go \
golang:${GOVER} \
build -o corso ${CORSO_BUILD_ARGS}
build -o corso ${CORSO_BUILD_ARGS} -ldflags "${CORSO_BUILD_LDFLAGS}"
set +x

mkdir -p ${PROJECT_ROOT}/bin/${GOOS}-${GOARCH}
Expand Down
4 changes: 4 additions & 0 deletions src/.goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ builds:
ignore:
- goos: windows
goarch: arm64
ldflags:
- -X 'github.com/alcionai/corso/src/internal/events.RudderStackWriteKey={{.Env.RUDDERSTACK_CORSO_WRITE_KEY}}'
- -X 'github.com/alcionai/corso/src/internal/events.RudderStackDataPlaneURL={{.Env.RUDDERSTACK_CORSO_DATA_PLANE_URL}}'

archives:
- replacements:
darwin: Darwin
Expand Down
12 changes: 6 additions & 6 deletions src/internal/events/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ type Bus struct {
}

var (
WriteKey string
DataPlaneURL string
RudderStackWriteKey string
RudderStackDataPlaneURL string
)

func NewBus(s storage.Storage, tenID string, opts control.Options) Bus {
Expand All @@ -70,17 +70,17 @@ func NewBus(s storage.Storage, tenID string, opts control.Options) Bus {

envWK := os.Getenv("RUDDERSTACK_CORSO_WRITE_KEY")
if len(envWK) > 0 {
WriteKey = envWK
RudderStackWriteKey = envWK
}

envDPU := os.Getenv("RUDDERSTACK_CORSO_DATA_PLANE_URL")
if len(envDPU) > 0 {
DataPlaneURL = envDPU
RudderStackDataPlaneURL = envDPU
}

var client analytics.Client
if len(WriteKey) > 0 && len(DataPlaneURL) > 0 {
client = analytics.New(WriteKey, DataPlaneURL)
if len(RudderStackWriteKey) > 0 && len(RudderStackDataPlaneURL) > 0 {
client = analytics.New(RudderStackWriteKey, RudderStackDataPlaneURL)
}

return Bus{
Expand Down

0 comments on commit 0240f31

Please sign in to comment.