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

Set Metrics configuration using ldlfags #1088

Merged
merged 2 commits into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,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 @@ -305,6 +307,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 }}'"
meain marked this conversation as resolved.
Show resolved Hide resolved
meain marked this conversation as resolved.
Show resolved Hide resolved
./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