Skip to content
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
1 change: 0 additions & 1 deletion .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ jobs:
- name: Go Generate
run: |
go generate ./...
cat tracing/commit.txt

- name: Validate Docs Data
run: |
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ vendor
Gopkg.lock
build/compiled
.idea
commit.txt
.envrc
.golangci.yml
2 changes: 1 addition & 1 deletion build/package/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ COPY . .
RUN --mount=type=cache,target=/go/pkg \
--mount=type=cache,target=/root/.cache/go-build \
go generate ./... \
&& GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="-s -w" -trimpath -o source main.go
&& GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="-s -w -X github.com/overmindtech/aws-source/tracing.ServiceVersion=$(git describe --tags --exact-match 2>/dev/null || git rev-parse --short HEAD)" -trimpath -o source main.go

FROM alpine:3.21
WORKDIR /
Expand Down
12 changes: 9 additions & 3 deletions tracing/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@ import (
semconv "go.opentelemetry.io/otel/semconv/v1.26.0"
)

//go:generate sh -c "echo -n $(git describe --tags --exact-match 2>/dev/null || git rev-parse --short HEAD) > commit.txt"
//go:embed commit.txt
var ServiceVersion string
// ServiceVersion is the version of the service. This will be overridden by the
// build system, using:
// go build -ldflags "-X github.com/overmindtech/api-server/tracing.ServiceVersion=$(git describe --tags --exact-match 2>/dev/null || git rev-parse --short HEAD)" -o your-app
//
// This allows our change detection workflow to work correctly. If we were
// embedding the version here each time we would always produce a slightly
// different compiled binary, and therefore it would look like there was a
// change each time
var ServiceVersion = "dev"

func tracingResource() *resource.Resource {
// Identify your application using resource detection
Expand Down