From 9bdf194d702516f6491d73855d1a651c9795cfdf Mon Sep 17 00:00:00 2001 From: Vibhu Pandey Date: Mon, 24 Mar 2025 14:38:48 +0530 Subject: [PATCH] feat: add the new version package (#7411) --- .github/workflows/build.yaml | 128 ++++++-- .github/workflows/commitci.yaml | 12 - .github/workflows/goci.yaml | 27 ++ .github/workflows/gor-signoz-community.yaml | 2 +- .github/workflows/gor-signoz.yaml | 2 +- .github/workflows/push.yaml | 134 -------- .github/workflows/staging-deployment.yaml | 6 +- .github/workflows/testing-deployment.yaml | 6 +- Makefile | 292 +++++++----------- conf/example.yaml | 6 + deploy/docker/docker-compose.ha.yaml | 2 +- deploy/docker/docker-compose.testing.yaml | 2 +- deploy/docker/docker-compose.yaml | 2 +- docs/contributing/development.md | 2 +- ee/query-service/.goreleaser.yaml | 12 +- ee/query-service/Dockerfile | 33 +- ee/query-service/app/api/api.go | 5 +- ee/query-service/main.go | 6 +- pkg/instrumentation/sdk.go | 6 +- pkg/query-service/.goreleaser.yaml | 12 +- pkg/query-service/Dockerfile | 38 +-- pkg/query-service/app/http_handler.go | 5 +- pkg/query-service/config/alerts.yml | 11 - pkg/query-service/config/cache-config.yml | 4 - pkg/query-service/config/prometheus.yml | 25 -- pkg/query-service/main.go | 5 +- pkg/query-service/telemetry/telemetry.go | 4 +- .../templates/invitation_email_template.html | 14 - pkg/query-service/version/version.go | 46 --- pkg/signoz/config.go | 5 + pkg/signoz/signoz.go | 5 +- pkg/version/config.go | 28 ++ pkg/version/doc.go | 4 - pkg/version/version.go | 108 ++++++- 34 files changed, 452 insertions(+), 547 deletions(-) delete mode 100644 .github/workflows/push.yaml delete mode 100644 pkg/query-service/config/alerts.yml delete mode 100644 pkg/query-service/config/cache-config.yml delete mode 100644 pkg/query-service/config/prometheus.yml delete mode 100644 pkg/query-service/templates/invitation_email_template.html delete mode 100644 pkg/query-service/version/version.go create mode 100644 pkg/version/config.go delete mode 100644 pkg/version/doc.go diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 360fa4ec08..8defcd797c 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,48 +1,122 @@ -name: build-pipeline +name: build on: - pull_request: + push: branches: - main - - release/v* + tags: + - v* jobs: - build-frontend: + enterprise: runs-on: ubuntu-latest steps: - - name: Checkout code + - name: checkout uses: actions/checkout@v4 - - name: Install dependencies - run: cd frontend && yarn install - - name: Build frontend static files - shell: bash - run: | - make build-frontend-static - - build-signoz: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Setup golang - uses: actions/setup-go@v4 + - name: setup + uses: actions/setup-go@v5 with: go-version: "1.22" - - name: Build signoz image + - name: setup-qemu + uses: docker/setup-qemu-action@v3 + - name: setup-buildx + uses: docker/setup-buildx-action@v3 + with: + version: latest + - name: docker-login + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: create-env-file + run: | + echo 'INTERCOM_APP_ID="${{ secrets.INTERCOM_APP_ID }}"' > frontend/.env + echo 'SEGMENT_ID="${{ secrets.SEGMENT_ID }}"' >> frontend/.env + echo 'SENTRY_AUTH_TOKEN="${{ secrets.SENTRY_AUTH_TOKEN }}"' >> frontend/.env + echo 'SENTRY_ORG="${{ secrets.SENTRY_ORG }}"' >> frontend/.env + echo 'SENTRY_PROJECT_ID="${{ secrets.SENTRY_PROJECT_ID }}"' >> frontend/.env + echo 'SENTRY_DSN="${{ secrets.SENTRY_DSN }}"' >> frontend/.env + echo 'TUNNEL_URL="${{ secrets.TUNNEL_URL }}"' >> frontend/.env + echo 'TUNNEL_DOMAIN="${{ secrets.TUNNEL_DOMAIN }}"' >> frontend/.env + echo 'POSTHOG_KEY="${{ secrets.POSTHOG_KEY }}"' >> frontend/.env + echo 'CUSTOMERIO_ID="${{ secrets.CUSTOMERIO_ID }}"' >> frontend/.env + echo 'CUSTOMERIO_SITE_ID="${{ secrets.CUSTOMERIO_SITE_ID }}"' >> frontend/.env + - name: github-ref-info shell: bash run: | - make build-signoz-amd64 + GH_REF=${{ github.ref }} + if [[ "${{ github.ref_type }}" == "tag" ]]; then + PREFIX="refs/tags/" + echo "GH_IS_TAG=true" >> $GITHUB_ENV + echo "GH_TAG=${GH_REF#$PREFIX}" >> $GITHUB_ENV + else + PREFIX="refs/heads/" + echo "GH_IS_TAG=false" >> $GITHUB_ENV + echo "GH_BRANCH_NAME=${GH_REF#$PREFIX}" >> $GITHUB_ENV + fi + - name: set-version + run: | + if [ '${{ env.GH_IS_TAG }}' == 'true' ]; then + echo "VERSION=${{ env.GH_TAG }}" >> $GITHUB_ENV + elif [ '${{ env.GH_BRANCH_NAME }}' == 'main' ]; then + echo "VERSION=latest" >> $GITHUB_ENV + else + echo "VERSION=${{ env.GH_BRANCH_NAME }}" >> $GITHUB_ENV + fi + - name: cross-compilation-tools + run: | + set -ex + sudo apt-get update + sudo apt-get install -y gcc-aarch64-linux-gnu musl-tools + - name: publish + run: make docker-buildx-enterprise - build-signoz-community: + community: runs-on: ubuntu-latest steps: - - name: Checkout code + - name: checkout uses: actions/checkout@v4 - - name: Setup golang - uses: actions/setup-go@v4 + - name: setup-go + uses: actions/setup-go@v5 with: go-version: "1.22" - - name: Build signoz community image + - name: setup-qemu + uses: docker/setup-qemu-action@v3 + - name: setup-buildx + uses: docker/setup-buildx-action@v3 + with: + version: latest + - name: docker-login + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: github-ref-info shell: bash run: | - make build-signoz-community-amd64 + GH_REF=${{ github.ref }} + if [[ "${{ github.ref_type }}" == "tag" ]]; then + PREFIX="refs/tags/" + echo "GH_IS_TAG=true" >> $GITHUB_ENV + echo "GH_TAG=${GH_REF#$PREFIX}" >> $GITHUB_ENV + else + PREFIX="refs/heads/" + echo "GH_IS_TAG=false" >> $GITHUB_ENV + echo "GH_BRANCH_NAME=${GH_REF#$PREFIX}" >> $GITHUB_ENV + fi + - name: set-version + run: | + if [ '${{ env.GH_IS_TAG }}' == 'true' ]; then + echo "VERSION=${{ env.GH_TAG }}" >> $GITHUB_ENV + elif [ '${{ env.GH_BRANCH_NAME }}' == 'main' ]; then + echo "VERSION=latest" >> $GITHUB_ENV + else + echo "VERSION=${{ env.GH_BRANCH_NAME }}" >> $GITHUB_ENV + fi + - name: cross-compilation-tools + run: | + set -ex + sudo apt-get update + sudo apt-get install -y gcc-aarch64-linux-gnu musl-tools + - name: publish + run: make docker-buildx-community diff --git a/.github/workflows/commitci.yaml b/.github/workflows/commitci.yaml index 5b02f75dc5..2c67ba5f9f 100644 --- a/.github/workflows/commitci.yaml +++ b/.github/workflows/commitci.yaml @@ -25,15 +25,3 @@ jobs: else echo "No references to 'ee' packages found in 'pkg' directory" fi - lint: - if: | - (github.event_name == 'pull_request' && ! github.event.pull_request.head.repo.fork && github.event.pull_request.user.login != 'dependabot[bot]' && ! contains(github.event.pull_request.labels.*.name, 'safe-to-test')) || - (github.event_name == 'pull_request_target' && contains(github.event.pull_request.labels.*.name, 'safe-to-test')) - runs-on: ubuntu-latest - steps: - - name: checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: lint - uses: wagoid/commitlint-github-action@v5 diff --git a/.github/workflows/goci.yaml b/.github/workflows/goci.yaml index 01db82f1fb..4a45f65620 100644 --- a/.github/workflows/goci.yaml +++ b/.github/workflows/goci.yaml @@ -34,3 +34,30 @@ jobs: secrets: inherit with: PRIMUS_REF: main + build: + if: | + (github.event_name == 'pull_request' && ! github.event.pull_request.head.repo.fork && github.event.pull_request.user.login != 'dependabot[bot]' && ! contains(github.event.pull_request.labels.*.name, 'safe-to-test')) || + (github.event_name == 'pull_request_target' && contains(github.event.pull_request.labels.*.name, 'safe-to-test')) + runs-on: ubuntu-latest + steps: + - name: self-checkout + uses: actions/checkout@v4 + - name: go-install + uses: actions/setup-go@v5 + with: + go-version: "1.22" + - name: qemu-install + uses: docker/setup-qemu-action@v3 + - name: aarch64-install + run: | + set -ex + sudo apt-get update + sudo apt-get install -y gcc-aarch64-linux-gnu musl-tools + - name: docker-community + shell: bash + run: | + make docker-build-community + - name: docker-enterprise + shell: bash + run: | + make docker-build-enterprise diff --git a/.github/workflows/gor-signoz-community.yaml b/.github/workflows/gor-signoz-community.yaml index b3c72da837..1cadda2a21 100644 --- a/.github/workflows/gor-signoz-community.yaml +++ b/.github/workflows/gor-signoz-community.yaml @@ -22,7 +22,7 @@ jobs: run: | echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV - name: build-frontend - run: make build-frontend-static + run: make js-build - name: upload-frontend-artifact uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/gor-signoz.yaml b/.github/workflows/gor-signoz.yaml index e0b0de93f5..5aa30f1fe0 100644 --- a/.github/workflows/gor-signoz.yaml +++ b/.github/workflows/gor-signoz.yaml @@ -36,7 +36,7 @@ jobs: echo 'CUSTOMERIO_ID="${{ secrets.CUSTOMERIO_ID }}"' >> .env echo 'CUSTOMERIO_SITE_ID="${{ secrets.CUSTOMERIO_SITE_ID }}"' >> .env - name: build-frontend - run: make build-frontend-static + run: make js-build - name: upload-frontend-artifact uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml deleted file mode 100644 index be4eb10538..0000000000 --- a/.github/workflows/push.yaml +++ /dev/null @@ -1,134 +0,0 @@ -name: push - -on: - push: - branches: - - main - tags: - - v* - -jobs: - image-build-and-push-signoz: - runs-on: ubuntu-latest - steps: - - name: checkout - uses: actions/checkout@v4 - - name: setup - uses: actions/setup-go@v4 - with: - go-version: "1.22" - - name: setup-qemu - uses: docker/setup-qemu-action@v3 - - name: setup-buildx - uses: docker/setup-buildx-action@v3 - with: - version: latest - - name: docker-login - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: create-env-file - run: | - echo 'INTERCOM_APP_ID="${{ secrets.INTERCOM_APP_ID }}"' > frontend/.env - echo 'SEGMENT_ID="${{ secrets.SEGMENT_ID }}"' >> frontend/.env - echo 'SENTRY_AUTH_TOKEN="${{ secrets.SENTRY_AUTH_TOKEN }}"' >> frontend/.env - echo 'SENTRY_ORG="${{ secrets.SENTRY_ORG }}"' >> frontend/.env - echo 'SENTRY_PROJECT_ID="${{ secrets.SENTRY_PROJECT_ID }}"' >> frontend/.env - echo 'SENTRY_DSN="${{ secrets.SENTRY_DSN }}"' >> frontend/.env - echo 'TUNNEL_URL="${{ secrets.TUNNEL_URL }}"' >> frontend/.env - echo 'TUNNEL_DOMAIN="${{ secrets.TUNNEL_DOMAIN }}"' >> frontend/.env - echo 'POSTHOG_KEY="${{ secrets.POSTHOG_KEY }}"' >> frontend/.env - echo 'CUSTOMERIO_ID="${{ secrets.CUSTOMERIO_ID }}"' >> frontend/.env - echo 'CUSTOMERIO_SITE_ID="${{ secrets.CUSTOMERIO_SITE_ID }}"' >> frontend/.env - - uses: benjlevesque/short-sha@v2.2 - id: short-sha - - name: branch-name - id: branch-name - uses: tj-actions/branch-names@v7.0.7 - - name: docker-tag - run: | - if [ '${{ steps.branch-name.outputs.is_tag }}' == 'true' ]; then - echo "DOCKER_TAG=${{ steps.branch-name.outputs.tag }}" >> $GITHUB_ENV - elif [ '${{ steps.branch-name.outputs.current_branch }}' == 'main' ]; then - echo "DOCKER_TAG=latest" >> $GITHUB_ENV - else - echo "DOCKER_TAG=${{ steps.branch-name.outputs.current_branch }}" >> $GITHUB_ENV - fi - - name: cross-compilation-tools - run: | - set -ex - sudo apt-get update - sudo apt-get install -y gcc-aarch64-linux-gnu musl-tools - - name: publish-signoz - run: make build-push-signoz - - name: qs-docker-tag - run: | - if [ '${{ steps.branch-name.outputs.is_tag }}' == 'true' ]; then - tag="${{ steps.branch-name.outputs.tag }}" - tag="${tag:1}" - echo "DOCKER_TAG=${tag}" >> $GITHUB_ENV - elif [ '${{ steps.branch-name.outputs.current_branch }}' == 'main' ]; then - echo "DOCKER_TAG=latest" >> $GITHUB_ENV - else - echo "DOCKER_TAG=${{ steps.branch-name.outputs.current_branch }}" >> $GITHUB_ENV - fi - - name: publish-query-service - run: | - SIGNOZ_DOCKER_IMAGE=query-service make build-push-signoz - - image-build-and-push-signoz-community: - runs-on: ubuntu-latest - steps: - - name: checkout - uses: actions/checkout@v4 - - name: setup-go - uses: actions/setup-go@v4 - with: - go-version: "1.22" - - name: setup-qemu - uses: docker/setup-qemu-action@v3 - - name: setup-buildx - uses: docker/setup-buildx-action@v3 - with: - version: latest - - name: docker-login - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - uses: benjlevesque/short-sha@v2.2 - id: short-sha - - name: branch-name - id: branch-name - uses: tj-actions/branch-names@v7.0.7 - - name: docker-tag - run: | - if [ '${{ steps.branch-name.outputs.is_tag }}' == 'true' ]; then - echo "DOCKER_TAG=${{ steps.branch-name.outputs.tag }}" >> $GITHUB_ENV - elif [ '${{ steps.branch-name.outputs.current_branch }}' == 'main' ]; then - echo "DOCKER_TAG=latest" >> $GITHUB_ENV - else - echo "DOCKER_TAG=${{ steps.branch-name.outputs.current_branch }}" >> $GITHUB_ENV - fi - - name: cross-compilation-tools - run: | - set -ex - sudo apt-get update - sudo apt-get install -y gcc-aarch64-linux-gnu musl-tools - - name: publish-signoz-community - run: make build-push-signoz-community - - name: qs-docker-tag - run: | - if [ '${{ steps.branch-name.outputs.is_tag }}' == 'true' ]; then - tag="${{ steps.branch-name.outputs.tag }}" - tag="${tag:1}" - echo "DOCKER_TAG=${tag}-oss" >> $GITHUB_ENV - elif [ '${{ steps.branch-name.outputs.current_branch }}' == 'main' ]; then - echo "DOCKER_TAG=latest-oss" >> $GITHUB_ENV - else - echo "DOCKER_TAG=${{ steps.branch-name.outputs.current_branch }}-oss" >> $GITHUB_ENV - fi - - name: publish-query-service-oss - run: | - SIGNOZ_COMMUNITY_DOCKER_IMAGE=query-service make build-push-signoz-community diff --git a/.github/workflows/staging-deployment.yaml b/.github/workflows/staging-deployment.yaml index 6ebfcfbfb5..5a87ccdfc1 100644 --- a/.github/workflows/staging-deployment.yaml +++ b/.github/workflows/staging-deployment.yaml @@ -35,7 +35,7 @@ jobs: read -r -d '' COMMAND < Building frontend static files" - @echo "------------------" - @cd $(FRONTEND_DIRECTORY) && \ - rm -rf build && \ - CI=1 yarn install && \ - yarn build && \ - ls -l build - -# Steps to build static binary of signoz -.PHONY: build-signoz-static -build-signoz-static: - @echo "------------------" - @echo "--> Building signoz static binary" - @echo "------------------" - @if [ $(DEV_BUILD) != "" ]; then \ - cd $(EE_QUERY_SERVICE_DIRECTORY) && \ - CGO_ENABLED=1 go build -tags timetzdata -a -o ./bin/signoz-${GOOS}-${GOARCH} \ - -ldflags "-linkmode external -extldflags '-static' -s -w ${LD_FLAGS} ${DEV_LD_FLAGS}"; \ +.PHONY: go-build-community $(GO_BUILD_ARCHS_COMMUNITY) +go-build-community: ## Builds the go backend server for community +go-build-community: $(GO_BUILD_ARCHS_COMMUNITY) +$(GO_BUILD_ARCHS_COMMUNITY): go-build-community-%: $(TARGET_DIR) + @mkdir -p $(TARGET_DIR)/$(OS)-$* + @echo ">> building binary $(TARGET_DIR)/$(OS)-$*/$(NAME)-community" + @if [ $* = "arm64" ]; then \ + CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOARCH=$* GOOS=$(OS) go build -C $(GO_BUILD_CONTEXT_COMMUNITY) -tags timetzdata -o $(TARGET_DIR)/$(OS)-$*/$(NAME)-community -ldflags "-linkmode external -extldflags '-static' -s -w $(GO_BUILD_LDFLAGS_COMMUNITY)"; \ else \ - cd $(EE_QUERY_SERVICE_DIRECTORY) && \ - CGO_ENABLED=1 go build -tags timetzdata -a -o ./bin/signoz-${GOOS}-${GOARCH} \ - -ldflags "-linkmode external -extldflags '-static' -s -w ${LD_FLAGS} ${PROD_LD_FLAGS}"; \ + CGO_ENABLED=1 GOARCH=$* GOOS=$(OS) go build -C $(GO_BUILD_CONTEXT_COMMUNITY) -tags timetzdata -o $(TARGET_DIR)/$(OS)-$*/$(NAME)-community -ldflags "-linkmode external -extldflags '-static' -s -w $(GO_BUILD_LDFLAGS_COMMUNITY)"; \ fi -.PHONY: build-signoz-static-amd64 -build-signoz-static-amd64: - make GOARCH=amd64 build-signoz-static -.PHONY: build-signoz-static-arm64 -build-signoz-static-arm64: - make CC=aarch64-linux-gnu-gcc GOARCH=arm64 build-signoz-static - -# Steps to build static binary of signoz for all platforms -.PHONY: build-signoz-static-all -build-signoz-static-all: build-signoz-static-amd64 build-signoz-static-arm64 build-frontend-static - -# Steps to build and push docker image of signoz -.PHONY: build-signoz-amd64 build-push-signoz -# Step to build docker image of signoz in amd64 (used in build pipeline) -build-signoz-amd64: build-signoz-static-amd64 build-frontend-static - @echo "------------------" - @echo "--> Building signoz docker image for amd64" - @echo "------------------" - @docker build --file $(EE_QUERY_SERVICE_DIRECTORY)/Dockerfile \ - --tag $(REPONAME)/$(SIGNOZ_DOCKER_IMAGE):$(DOCKER_TAG) \ - --build-arg TARGETPLATFORM="linux/amd64" . - -# Step to build and push docker image of query in amd64 and arm64 (used in push pipeline) -build-push-signoz: build-signoz-static-all - @echo "------------------" - @echo "--> Building and pushing signoz docker image" - @echo "------------------" - @docker buildx build --file $(EE_QUERY_SERVICE_DIRECTORY)/Dockerfile --progress plain \ - --push --platform linux/arm64,linux/amd64 \ - --tag $(REPONAME)/$(SIGNOZ_DOCKER_IMAGE):$(DOCKER_TAG) . - -# Step to build docker image of signoz community in amd64 (used in build pipeline) -build-signoz-community-amd64: - @echo "------------------" - @echo "--> Building signoz docker image for amd64" - @echo "------------------" - make EE_QUERY_SERVICE_DIRECTORY=${QUERY_SERVICE_DIRECTORY} SIGNOZ_DOCKER_IMAGE=${SIGNOZ_COMMUNITY_DOCKER_IMAGE} build-signoz-amd64 - -# Step to build and push docker image of signoz community in amd64 and arm64 (used in push pipeline) -build-push-signoz-community: - @echo "------------------" - @echo "--> Building and pushing signoz community docker image" - @echo "------------------" - make EE_QUERY_SERVICE_DIRECTORY=${QUERY_SERVICE_DIRECTORY} SIGNOZ_DOCKER_IMAGE=${SIGNOZ_COMMUNITY_DOCKER_IMAGE} build-push-signoz - -pull-signoz: - @docker-compose -f $(STANDALONE_DIRECTORY)/docker-compose.yaml pull - -run-signoz: - @docker-compose -f $(STANDALONE_DIRECTORY)/docker-compose.yaml up --build -d - -run-testing: - @docker-compose -f $(STANDALONE_DIRECTORY)/docker-compose.testing.yaml up --build -d - -down-signoz: - @docker-compose -f $(STANDALONE_DIRECTORY)/docker-compose.yaml down -v - -check-no-ee-references: - @echo "Checking for 'ee' package references in 'pkg' directory..." - @if grep -R --include="*.go" '.*/ee/.*' pkg/; then \ - echo "Error: Found references to 'ee' packages in 'pkg' directory"; \ - exit 1; \ +.PHONY: go-build-enterprise $(GO_BUILD_ARCHS_ENTERPRISE) +go-build-enterprise: ## Builds the go backend server for enterprise +go-build-enterprise: $(GO_BUILD_ARCHS_ENTERPRISE) +$(GO_BUILD_ARCHS_ENTERPRISE): go-build-enterprise-%: $(TARGET_DIR) + @mkdir -p $(TARGET_DIR)/$(OS)-$* + @echo ">> building binary $(TARGET_DIR)/$(OS)-$*/$(NAME)" + @if [ $* = "arm64" ]; then \ + CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOARCH=$* GOOS=$(OS) go build -C $(GO_BUILD_CONTEXT_ENTERPRISE) -tags timetzdata -o $(TARGET_DIR)/$(OS)-$*/$(NAME) -ldflags "-linkmode external -extldflags '-static' -s -w $(GO_BUILD_LDFLAGS_ENTERPRISE)"; \ else \ - echo "No references to 'ee' packages found in 'pkg' directory"; \ + CGO_ENABLED=1 GOARCH=$* GOOS=$(OS) go build -C $(GO_BUILD_CONTEXT_ENTERPRISE) -tags timetzdata -o $(TARGET_DIR)/$(OS)-$*/$(NAME) -ldflags "-linkmode external -extldflags '-static' -s -w $(GO_BUILD_LDFLAGS_ENTERPRISE)"; \ fi -test: - go test ./pkg/... +############################################################## +# js commands +############################################################## +.PHONY: js-build +js-build: ## Builds the js frontend + @echo ">> building js frontend" + @cd $(JS_BUILD_CONTEXT) && CI=1 yarn install && yarn build -######################################################## -# Goreleaser -######################################################## -.PHONY: gor-snapshot gor-snapshot-histogram-quantile gor-snapshot-signoz gor-snapshot-signoz-community gor-split gor-split-histogram-quantile gor-split-signoz gor-split-signoz-community gor-merge +############################################################## +# docker commands +############################################################## +.PHONY: docker-build-community $(DOCKER_BUILD_ARCHS_COMMUNITY) +docker-build-community: ## Builds the docker image for community +docker-build-community: $(DOCKER_BUILD_ARCHS_COMMUNITY) +$(DOCKER_BUILD_ARCHS_COMMUNITY): docker-build-community-%: go-build-community-% js-build + @echo ">> building docker image for $(NAME)-community" + @docker build -t "$(DOCKER_REGISTRY_COMMUNITY):$(VERSION)-$*" \ + --build-arg TARGETARCH="$*" \ + -f $(DOCKERFILE_COMMUNITY) $(SRC) -gor-snapshot: - @if [[ ${GORELEASER_WORKDIR} ]]; then \ - ${GORELEASER_BIN} release --config ${GORELEASER_WORKDIR}/.goreleaser.yaml --clean --snapshot; \ - else \ - ${GORELEASER_BIN} release --clean --snapshot; \ - fi +.PHONY: docker-buildx-community +docker-buildx-community: ## Builds the docker image for community using buildx +docker-buildx-community: go-build-community js-build + @echo ">> building docker image for $(NAME)-community" + @docker buildx build --file $(DOCKERFILE_COMMUNITY) \ + --progress plain \ + --platform linux/arm64,linux/amd64 \ + --push \ + --tag $(DOCKER_REGISTRY_COMMUNITY):$(VERSION) $(SRC) -gor-snapshot-histogram-quantile: - make GORELEASER_WORKDIR=$(CH_HISTOGRAM_QUANTILE_DIRECTORY) goreleaser-snapshot +.PHONY: docker-build-enterprise $(DOCKER_BUILD_ARCHS_ENTERPRISE) +docker-build-enterprise: ## Builds the docker image for enterprise +docker-build-enterprise: $(DOCKER_BUILD_ARCHS_ENTERPRISE) +$(DOCKER_BUILD_ARCHS_ENTERPRISE): docker-build-enterprise-%: go-build-enterprise-% js-build + @echo ">> building docker image for $(NAME)" + @docker build -t "$(DOCKER_REGISTRY_ENTERPRISE):$(VERSION)-$*" \ + --build-arg TARGETARCH="$*" \ + -f $(DOCKERFILE_ENTERPRISE) $(SRC) -gor-snapshot-signoz: build-frontend-static - make GORELEASER_WORKDIR=$(EE_QUERY_SERVICE_DIRECTORY) goreleaser-snapshot - -gor-snapshot-signoz-community: build-frontend-static - make GORELEASER_WORKDIR=$(QUERY_SERVICE_DIRECTORY) goreleaser-snapshot - -gor-split: - @if [[ ${GORELEASER_WORKDIR} ]]; then \ - ${GORELEASER_BIN} release --config ${GORELEASER_WORKDIR}/.goreleaser.yaml --clean --split; \ - else \ - ${GORELEASER_BIN} release --clean --split; \ - fi - -gor-split-histogram-quantile: - make GORELEASER_WORKDIR=$(CH_HISTOGRAM_QUANTILE_DIRECTORY) goreleaser-split - -gor-split-signoz: build-frontend-static - make GORELEASER_WORKDIR=$(EE_QUERY_SERVICE_DIRECTORY) goreleaser-split - -gor-split-signoz-community: build-frontend-static - make GORELEASER_WORKDIR=$(QUERY_SERVICE_DIRECTORY) goreleaser-split - -gor-merge: - ${GORELEASER_BIN} continue --merge +.PHONY: docker-buildx-enterprise +docker-buildx-enterprise: ## Builds the docker image for enterprise using buildx +docker-buildx-enterprise: go-build-enterprise js-build + @echo ">> building docker image for $(NAME)" + @docker buildx build --file $(DOCKERFILE_ENTERPRISE) \ + --progress plain \ + --platform linux/arm64,linux/amd64 \ + --push \ + --tag $(DOCKER_REGISTRY_ENTERPRISE):$(VERSION) $(SRC) diff --git a/conf/example.yaml b/conf/example.yaml index 4f07c56329..61d4f7b48c 100644 --- a/conf/example.yaml +++ b/conf/example.yaml @@ -3,6 +3,12 @@ # Do not modify this file # +##################### Version ##################### +version: + banner: + # Whether to enable the version banner on startup. + enabled: true + ##################### Instrumentation ##################### instrumentation: logs: diff --git a/deploy/docker/docker-compose.ha.yaml b/deploy/docker/docker-compose.ha.yaml index ca747fefe0..26ba3ab3ba 100644 --- a/deploy/docker/docker-compose.ha.yaml +++ b/deploy/docker/docker-compose.ha.yaml @@ -177,7 +177,7 @@ services: # - ../common/clickhouse/storage.xml:/etc/clickhouse-server/config.d/storage.xml signoz: !!merge <<: *db-depend - image: signoz/signoz:${DOCKER_TAG:-v0.76.2} + image: signoz/signoz:${VERSION:-v0.76.2} container_name: signoz command: - --config=/root/config/prometheus.yml diff --git a/deploy/docker/docker-compose.testing.yaml b/deploy/docker/docker-compose.testing.yaml index a6a19b2fca..8c55743258 100644 --- a/deploy/docker/docker-compose.testing.yaml +++ b/deploy/docker/docker-compose.testing.yaml @@ -110,7 +110,7 @@ services: # - ../common/clickhouse/storage.xml:/etc/clickhouse-server/config.d/storage.xml signoz: !!merge <<: *db-depend - image: signoz/signoz:${DOCKER_TAG:-v0.76.2} + image: signoz/signoz:${VERSION:-v0.76.2} container_name: signoz command: - --config=/root/config/prometheus.yml diff --git a/deploy/docker/docker-compose.yaml b/deploy/docker/docker-compose.yaml index c43b856214..146e8cca5c 100644 --- a/deploy/docker/docker-compose.yaml +++ b/deploy/docker/docker-compose.yaml @@ -110,7 +110,7 @@ services: # - ../common/clickhouse/storage.xml:/etc/clickhouse-server/config.d/storage.xml signoz: !!merge <<: *db-depend - image: signoz/signoz:${DOCKER_TAG:-v0.76.2} + image: signoz/signoz:${VERSION:-v0.76.2} container_name: signoz command: - --config=/root/config/prometheus.yml diff --git a/docs/contributing/development.md b/docs/contributing/development.md index 262a9d6703..abbd2ce45d 100644 --- a/docs/contributing/development.md +++ b/docs/contributing/development.md @@ -61,7 +61,7 @@ This command: 1. Run the backend server: ```bash - make run-go + make go-run-community ``` 2. Verify it's working: diff --git a/ee/query-service/.goreleaser.yaml b/ee/query-service/.goreleaser.yaml index 66ba7182d1..3e17e5fff4 100644 --- a/ee/query-service/.goreleaser.yaml +++ b/ee/query-service/.goreleaser.yaml @@ -30,13 +30,11 @@ builds: - v8.0 ldflags: - -s -w - - -X github.com/SigNoz/signoz/pkg/query-service/version.version={{ .Version }} - - -X main.commit={{ .Commit }} -X main.date={{ .CommitDate }} - - -X main.builtBy=goreleaser - - -X github.com/SigNoz/signoz/pkg/query-service/version.buildVersion={{ .Version }} - - -X github.com/SigNoz/signoz/pkg/query-service/version.buildHash={{ .ShortCommit }} - - -X github.com/SigNoz/signoz/pkg/query-service/version.buildTime={{ .Date }} - - -X github.com/SigNoz/signoz/pkg/query-service/version.gitBranch={{ .Branch }} + - -X github.com/SigNoz/signoz/pkg/version.version=v{{ .Version }} + - -X github.com/SigNoz/signoz/pkg/version.variant=enterprise + - -X github.com/SigNoz/signoz/pkg/version.hash={{ .ShortCommit }} + - -X github.com/SigNoz/signoz/pkg/version.time={{ .CommitTimestamp }} + - -X github.com/SigNoz/signoz/pkg/version.branch={{ .Branch }} - -X github.com/SigNoz/signoz/ee/query-service/constants.ZeusURL=https://api.signoz.cloud - -X github.com/SigNoz/signoz/ee/query-service/constants.LicenseSignozIo=https://license.signoz.io/api/v1 - >- diff --git a/ee/query-service/Dockerfile b/ee/query-service/Dockerfile index a01620f249..648eb004a2 100644 --- a/ee/query-service/Dockerfile +++ b/ee/query-service/Dockerfile @@ -1,34 +1,21 @@ -# use a minimal alpine image FROM alpine:3.20.3 - -# Add Maintainer Info LABEL maintainer="signoz" - -# define arguments that can be passed during build time -ARG TARGETOS TARGETARCH - -# add ca-certificates in case you need them -RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/* - -# set working directory WORKDIR /root -# copy the signoz binary -COPY ee/query-service/bin/signoz-${TARGETOS}-${TARGETARCH} /root/signoz +ARG OS="linux" +ARG TARGETARCH -# copy prometheus YAML config -COPY pkg/query-service/config/prometheus.yml /root/config/prometheus.yml -COPY pkg/query-service/templates /root/templates +RUN apk update && \ + apk add ca-certificates && \ + rm -rf /var/cache/apk/* -# Make signoz executable for non-root users -RUN chmod 755 /root /root/signoz -# Copy frontend +COPY ./target/${OS}-${TARGETARCH}/signoz /root/signoz +COPY ./conf/prometheus.yml /root/config/prometheus.yml +COPY ./templates/email /root/templates COPY frontend/build/ /etc/signoz/web/ -# run the binary +RUN chmod 755 /root /root/signoz + ENTRYPOINT ["./signoz"] - CMD ["-config", "/root/config/prometheus.yml"] - -EXPOSE 8080 diff --git a/ee/query-service/app/api/api.go b/ee/query-service/app/api/api.go index 8620621473..bfc48b0006 100644 --- a/ee/query-service/app/api/api.go +++ b/ee/query-service/app/api/api.go @@ -19,9 +19,9 @@ import ( baseint "github.com/SigNoz/signoz/pkg/query-service/interfaces" basemodel "github.com/SigNoz/signoz/pkg/query-service/model" rules "github.com/SigNoz/signoz/pkg/query-service/rules" - "github.com/SigNoz/signoz/pkg/query-service/version" "github.com/SigNoz/signoz/pkg/signoz" "github.com/SigNoz/signoz/pkg/types/authtypes" + "github.com/SigNoz/signoz/pkg/version" "github.com/gorilla/mux" ) @@ -200,9 +200,8 @@ func (ah *APIHandler) RegisterCloudIntegrationsRoutes(router *mux.Router, am *ba } func (ah *APIHandler) getVersion(w http.ResponseWriter, r *http.Request) { - version := version.GetVersion() versionResponse := basemodel.GetVersionResponse{ - Version: version, + Version: version.Info.Version(), EE: "Y", SetupCompleted: ah.SetupCompleted, } diff --git a/ee/query-service/main.go b/ee/query-service/main.go index 7c48778383..79b970ac16 100644 --- a/ee/query-service/main.go +++ b/ee/query-service/main.go @@ -12,9 +12,9 @@ import ( "github.com/SigNoz/signoz/pkg/config/fileprovider" "github.com/SigNoz/signoz/pkg/query-service/auth" baseconst "github.com/SigNoz/signoz/pkg/query-service/constants" - "github.com/SigNoz/signoz/pkg/query-service/version" "github.com/SigNoz/signoz/pkg/signoz" "github.com/SigNoz/signoz/pkg/types/authtypes" + "github.com/SigNoz/signoz/pkg/version" prommodel "github.com/prometheus/common/model" @@ -78,8 +78,6 @@ func main() { zap.ReplaceGlobals(loggerMgr) defer loggerMgr.Sync() // flushes buffer, if any - version.PrintVersion() - config, err := signoz.NewConfig(context.Background(), config.ResolverConfig{ Uris: []string{"env:"}, ProviderFactories: []config.ProviderFactory{ @@ -95,6 +93,8 @@ func main() { zap.L().Fatal("Failed to create config", zap.Error(err)) } + version.Info.PrettyPrint(config.Version) + signoz, err := signoz.New( context.Background(), config, diff --git a/pkg/instrumentation/sdk.go b/pkg/instrumentation/sdk.go index 7665995639..89c2fb0305 100644 --- a/pkg/instrumentation/sdk.go +++ b/pkg/instrumentation/sdk.go @@ -28,12 +28,12 @@ type SDK struct { // New creates a new Instrumentation instance with configured providers. // It sets up logging, tracing, and metrics based on the provided configuration. -func New(ctx context.Context, build version.Build, cfg Config) (*SDK, error) { +func New(ctx context.Context, cfg Config, build version.Build, serviceName string) (*SDK, error) { // Set default resource attributes if not provided if cfg.Resource.Attributes == nil { cfg.Resource.Attributes = map[string]any{ - string(semconv.ServiceNameKey): build.Name, - string(semconv.ServiceVersionKey): build.Version, + string(semconv.ServiceNameKey): serviceName, + string(semconv.ServiceVersionKey): build.Version(), } } diff --git a/pkg/query-service/.goreleaser.yaml b/pkg/query-service/.goreleaser.yaml index d4f5ffa04a..8bd4631205 100644 --- a/pkg/query-service/.goreleaser.yaml +++ b/pkg/query-service/.goreleaser.yaml @@ -30,13 +30,11 @@ builds: - v8.0 ldflags: - -s -w - - -X github.com/SigNoz/signoz/pkg/query-service/version.version={{ .Version }} - - -X main.commit={{ .Commit }} -X main.date={{ .CommitDate }} - - -X main.builtBy=goreleaser - - -X github.com/SigNoz/signoz/pkg/query-service/version.buildVersion={{ .Version }} - - -X github.com/SigNoz/signoz/pkg/query-service/version.buildHash={{ .ShortCommit }} - - -X github.com/SigNoz/signoz/pkg/query-service/version.buildTime={{ .Date }} - - -X github.com/SigNoz/signoz/pkg/query-service/version.gitBranch={{ .Branch }} + - -X github.com/SigNoz/signoz/pkg/version.version=v{{ .Version }} + - -X github.com/SigNoz/signoz/pkg/version.variant=community + - -X github.com/SigNoz/signoz/pkg/version.hash={{ .ShortCommit }} + - -X github.com/SigNoz/signoz/pkg/version.time={{ .CommitTimestamp }} + - -X github.com/SigNoz/signoz/pkg/version.branch={{ .Branch }} - >- {{- if eq .Os "linux" }}-linkmode external -extldflags '-static'{{- end }} mod_timestamp: "{{ .CommitTimestamp }}" diff --git a/pkg/query-service/Dockerfile b/pkg/query-service/Dockerfile index 07caa03bf3..043bfb0cd0 100644 --- a/pkg/query-service/Dockerfile +++ b/pkg/query-service/Dockerfile @@ -1,37 +1,21 @@ -# use a minimal alpine image FROM alpine:3.20.3 - -# Add Maintainer Info LABEL maintainer="signoz" - -# define arguments that can be passed during build time -ARG TARGETOS TARGETARCH - -# add ca-certificates in case you need them -RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/* - -# set working directory WORKDIR /root -# copy the signoz binary -COPY pkg/query-service/bin/signoz-${TARGETOS}-${TARGETARCH} /root/signoz +ARG OS="linux" +ARG TARGETARCH -# copy prometheus YAML config -COPY pkg/query-service/config/prometheus.yml /root/config/prometheus.yml -COPY pkg/query-service/templates /root/templates +RUN apk update && \ + apk add ca-certificates && \ + rm -rf /var/cache/apk/* + + +COPY ./target/${OS}-${TARGETARCH}/signoz-community /root/signoz +COPY ./conf/prometheus.yml /root/config/prometheus.yml +COPY ./templates/email /root/templates +COPY frontend/build/ /etc/signoz/web/ -# Make signoz executable for non-root users RUN chmod 755 /root /root/signoz -# Copy frontend -COPY frontend/build/ /etc/signoz/web/ - -# Copy frontend -COPY frontend/build/ /etc/signoz/web/ - -# run the binary ENTRYPOINT ["./signoz"] - CMD ["-config", "/root/config/prometheus.yml"] - -EXPOSE 8080 diff --git a/pkg/query-service/app/http_handler.go b/pkg/query-service/app/http_handler.go index 7a2172d56c..ad2126b552 100644 --- a/pkg/query-service/app/http_handler.go +++ b/pkg/query-service/app/http_handler.go @@ -71,7 +71,7 @@ import ( "github.com/SigNoz/signoz/pkg/query-service/model" "github.com/SigNoz/signoz/pkg/query-service/rules" "github.com/SigNoz/signoz/pkg/query-service/telemetry" - "github.com/SigNoz/signoz/pkg/query-service/version" + "github.com/SigNoz/signoz/pkg/version" ) type status string @@ -1899,9 +1899,8 @@ func (aH *APIHandler) getDisks(w http.ResponseWriter, r *http.Request) { } func (aH *APIHandler) getVersion(w http.ResponseWriter, r *http.Request) { - version := version.GetVersion() versionResponse := model.GetVersionResponse{ - Version: version, + Version: version.Info.Version(), EE: "Y", SetupCompleted: aH.SetupCompleted, } diff --git a/pkg/query-service/config/alerts.yml b/pkg/query-service/config/alerts.yml deleted file mode 100644 index 99e1b95fa0..0000000000 --- a/pkg/query-service/config/alerts.yml +++ /dev/null @@ -1,11 +0,0 @@ -groups: -- name: ExampleCPULoadGroup - rules: - - alert: HighCpuLoad-dev - expr: system_cpu_load_average_1m > 0.01 - for: 0m - labels: - severity: warning - annotations: - summary: High CPU load - description: "CPU load is > 0.01\n VALUE = {{ $value }}\n LABELS = {{ $labels }}" \ No newline at end of file diff --git a/pkg/query-service/config/cache-config.yml b/pkg/query-service/config/cache-config.yml deleted file mode 100644 index b1bd329584..0000000000 --- a/pkg/query-service/config/cache-config.yml +++ /dev/null @@ -1,4 +0,0 @@ -provider: "inmemory" -inmemory: - ttl: 60m - cleanupInterval: 10m diff --git a/pkg/query-service/config/prometheus.yml b/pkg/query-service/config/prometheus.yml deleted file mode 100644 index 6513cd0c3f..0000000000 --- a/pkg/query-service/config/prometheus.yml +++ /dev/null @@ -1,25 +0,0 @@ -# my global config -global: - scrape_interval: 5s # Set the scrape interval to every 15 seconds. Default is every 1 minute. - evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. - # scrape_timeout is set to the global default (10s). - -# Alertmanager configuration -alerting: - alertmanagers: - - static_configs: - - targets: - - 127.0.0.1:9093 - -# Load rules once and periodically evaluate them according to the global 'evaluation_interval'. -rule_files: - # - "first_rules.yml" - # - "second_rules.yml" - - 'alerts.yml' - -# A scrape configuration containing exactly one endpoint to scrape: -# Here it's Prometheus itself. -scrape_configs: [] - -remote_read: - - url: tcp://localhost:9000/signoz_metrics diff --git a/pkg/query-service/main.go b/pkg/query-service/main.go index a04ea9ba1c..2e20aa5af3 100644 --- a/pkg/query-service/main.go +++ b/pkg/query-service/main.go @@ -12,9 +12,9 @@ import ( "github.com/SigNoz/signoz/pkg/query-service/app" "github.com/SigNoz/signoz/pkg/query-service/auth" "github.com/SigNoz/signoz/pkg/query-service/constants" - "github.com/SigNoz/signoz/pkg/query-service/version" "github.com/SigNoz/signoz/pkg/signoz" "github.com/SigNoz/signoz/pkg/types/authtypes" + "github.com/SigNoz/signoz/pkg/version" prommodel "github.com/prometheus/common/model" "go.uber.org/zap" @@ -75,7 +75,6 @@ func main() { defer loggerMgr.Sync() // flushes buffer, if any logger := loggerMgr.Sugar() - version.PrintVersion() config, err := signoz.NewConfig(context.Background(), config.ResolverConfig{ Uris: []string{"env:"}, @@ -92,6 +91,8 @@ func main() { zap.L().Fatal("Failed to create config", zap.Error(err)) } + version.Info.PrettyPrint(config.Version) + signoz, err := signoz.New( context.Background(), config, diff --git a/pkg/query-service/telemetry/telemetry.go b/pkg/query-service/telemetry/telemetry.go index 679301ed7f..06e809794e 100644 --- a/pkg/query-service/telemetry/telemetry.go +++ b/pkg/query-service/telemetry/telemetry.go @@ -19,8 +19,8 @@ import ( "github.com/SigNoz/signoz/pkg/query-service/interfaces" "github.com/SigNoz/signoz/pkg/query-service/model" v3 "github.com/SigNoz/signoz/pkg/query-service/model/v3" - "github.com/SigNoz/signoz/pkg/query-service/version" "github.com/SigNoz/signoz/pkg/types" + "github.com/SigNoz/signoz/pkg/version" ) const ( @@ -740,7 +740,7 @@ func (a *Telemetry) SendEvent(event string, data map[string]interface{}, userEma // zap.L().Info(data) properties := analytics.NewProperties() - properties.Set("version", version.GetVersion()) + properties.Set("version", version.Info.Version) properties.Set("deploymentType", getDeploymentType()) properties.Set("companyDomain", a.getCompanyDomain()) diff --git a/pkg/query-service/templates/invitation_email_template.html b/pkg/query-service/templates/invitation_email_template.html deleted file mode 100644 index 75fa3a32e8..0000000000 --- a/pkg/query-service/templates/invitation_email_template.html +++ /dev/null @@ -1,14 +0,0 @@ - - - -

Hi {{.CustomerName}},

-

You have been invited to join SigNoz project by {{.InviterName}} ({{.InviterEmail}}).

-

Please click on the following button to accept the invitation:

- Accept Invitation -

Button not working? Paste the following link into your browser:

-

{{.Link}}

-

Follow docs here 👉 to Get Started with SigNoz Cloud

-

Thanks,

-

SigNoz Team

- - diff --git a/pkg/query-service/version/version.go b/pkg/query-service/version/version.go deleted file mode 100644 index 3e2f984d4c..0000000000 --- a/pkg/query-service/version/version.go +++ /dev/null @@ -1,46 +0,0 @@ -package version - -import ( - "fmt" - "runtime" -) - -// These fields are set during an official build -// Global vars set from command-line arguments -var ( - buildVersion = "--" - buildHash = "--" - buildTime = "--" - gitBranch = "--" -) - -// BuildDetails returns a string containing details about the SigNoz query-service binary. -func BuildDetails() string { - licenseInfo := `Check SigNoz Github repo for license details` - - return fmt.Sprintf(` -SigNoz version : %v -Commit SHA-1 : %v -Commit timestamp : %v -Branch : %v -Go version : %v - -For SigNoz Official Documentation, visit https://signoz.io/docs/ -For SigNoz Community Slack, visit http://signoz.io/slack/ -For archive of discussions about SigNoz, visit https://knowledgebase.signoz.io/ - -%s. -Copyright 2024 SigNoz -`, - buildVersion, buildHash, buildTime, gitBranch, - runtime.Version(), licenseInfo) -} - -// PrintVersion prints version and other helpful information. -func PrintVersion() { - fmt.Println(BuildDetails()) -} - -func GetVersion() string { - return buildVersion -} diff --git a/pkg/signoz/config.go b/pkg/signoz/config.go index d7645a7180..1d690f9d9b 100644 --- a/pkg/signoz/config.go +++ b/pkg/signoz/config.go @@ -18,11 +18,15 @@ import ( "github.com/SigNoz/signoz/pkg/sqlmigrator" "github.com/SigNoz/signoz/pkg/sqlstore" "github.com/SigNoz/signoz/pkg/telemetrystore" + "github.com/SigNoz/signoz/pkg/version" "github.com/SigNoz/signoz/pkg/web" ) // Config defines the entire input configuration of signoz. type Config struct { + // Version config + Version version.Config `mapstructure:"version"` + // Instrumentation config Instrumentation instrumentation.Config `mapstructure:"instrumentation"` @@ -61,6 +65,7 @@ type DeprecatedFlags struct { func NewConfig(ctx context.Context, resolverConfig config.ResolverConfig, deprecatedFlags DeprecatedFlags) (Config, error) { configFactories := []factory.ConfigFactory{ + version.NewConfigFactory(), instrumentation.NewConfigFactory(), web.NewConfigFactory(), cache.NewConfigFactory(), diff --git a/pkg/signoz/signoz.go b/pkg/signoz/signoz.go index 2dc3ee0458..b86ef89201 100644 --- a/pkg/signoz/signoz.go +++ b/pkg/signoz/signoz.go @@ -34,12 +34,13 @@ func New( telemetrystoreProviderFactories factory.NamedMap[factory.ProviderFactory[telemetrystore.TelemetryStore, telemetrystore.Config]], ) (*SigNoz, error) { // Initialize instrumentation - instrumentation, err := instrumentation.New(ctx, version.Build{}, config.Instrumentation) + instrumentation, err := instrumentation.New(ctx, config.Instrumentation, version.Info, "signoz") if err != nil { return nil, err } - instrumentation.Logger().DebugContext(ctx, "starting signoz", "config", config) + instrumentation.Logger().InfoContext(ctx, "starting signoz", "version", version.Info.Version(), "variant", version.Info.Variant(), "commit", version.Info.Hash(), "branch", version.Info.Branch(), "go", version.Info.GoVersion(), "time", version.Info.Time()) + instrumentation.Logger().DebugContext(ctx, "loaded signoz config", "config", config) // Get the provider settings from instrumentation providerSettings := instrumentation.ToProviderSettings() diff --git a/pkg/version/config.go b/pkg/version/config.go new file mode 100644 index 0000000000..ef147f50ba --- /dev/null +++ b/pkg/version/config.go @@ -0,0 +1,28 @@ +package version + +import "github.com/SigNoz/signoz/pkg/factory" + +type BannerConfig struct { + Enabled bool `mapstructure:"enabled"` +} + +type Config struct { + Banner BannerConfig `mapstructure:"banner"` +} + +func NewConfigFactory() factory.ConfigFactory { + return factory.NewConfigFactory(factory.MustNewName("version"), newConfig) + +} + +func newConfig() factory.Config { + return Config{ + Banner: BannerConfig{ + Enabled: true, + }, + } +} + +func (c Config) Validate() error { + return nil +} diff --git a/pkg/version/doc.go b/pkg/version/doc.go deleted file mode 100644 index 9b6483a085..0000000000 --- a/pkg/version/doc.go +++ /dev/null @@ -1,4 +0,0 @@ -// Package version is used to track the build information of the application. -// This is typically set via ldflags at build time. -// Eg: -ldflags="-X 'pkg/version.Build.Version=v1.0.0'" -package version diff --git a/pkg/version/version.go b/pkg/version/version.go index 9cbd8c4436..8506468224 100644 --- a/pkg/version/version.go +++ b/pkg/version/version.go @@ -1,9 +1,111 @@ package version +import ( + "fmt" + "runtime" + "strconv" + gotime "time" +) + +// This will be set via ldflags at build time. +var ( + variant string = "" + version string = "" + hash string = "" + time string = "" + branch string = "" +) + +var ( + Info Build = Build{ + variant: variant, + version: version, + hash: hash, + time: time, + branch: branch, + goVersion: runtime.Version(), + } +) + // Build contains information about the build environment. type Build struct { - // The name of the current build. - Name string + // The variant of the current build. + variant string + // The version of the current build. - Version string + version string + + // The git hash of the current build. + hash string + + // The time of the current build. + time string + + // The branch of the current build. + branch string + + // The version of go. + goVersion string +} + +func (b Build) Variant() string { + return b.variant +} + +func (b Build) Version() string { + return b.version +} + +func (b Build) Hash() string { + return b.hash +} + +func (b Build) Time() string { + return b.time +} + +func (b Build) Branch() string { + return b.branch +} + +func (b Build) GoVersion() string { + return b.goVersion +} + +func (b Build) PrettyPrint(cfg Config) { + if !cfg.Banner.Enabled { + return + } + + year := gotime.Now().Year() + ascii := []string{ + " -**********= ", + " .::-=+**********+=--:. ", + " .-=*******++=-----==+******=-. ", + " :-+*******=:. :-+******=: ", + " .-********+: .=*******=. ", + " :+********+: .=*******+: ", + " .+*********+ :+***+. -********+: ", + " -**********+. .****= =*********= " + " ____ _ _ _ ____ _ _ _ ", + " .************: +**** +**********: " + " / ___|| |_ __ _ _ __| |_(_)_ __ __ _ / ___|(_) __ _| \\ | | ___ ____ ", + ".************+ .----: -***********- " + " \\___ \\| __/ _` | '__| __| | '_ \\ / _` | \\___ \\| |/ _` | \\| |/ _ \\_ / ", + "*************= :************." + " ___) | || (_| | | | |_| | | | | (_| | ___) | | (_| | |\\ | (_) / / _ _ _ ", + ":************+ ----: -***********= " + " |____/ \\__\\__,_|_| \\__|_|_| |_|\\__, | |____/|_|\\__, |_| \\_|\\___/___(_|_|_)", + " :************. ***** +**********: " + " |___/ |___/ ", + " .=**********+ :****= -*********+. " + " Version: " + b.version + " (" + b.variant + ")" + " [Copyright " + strconv.Itoa(year) + " SigNoz, All rights reserved]", + " :+*********+ :+***+ -********+: ", + " :+********+. =*******+- ", + " :=********=. -*******=: ", + " :=*******+-. .-+******=-. ", + " :-+*******+=--:::--=+******+=: ", + " .:-==+***********+=-:: ", + " :**********= ", + } + + fmt.Println() + for _, line := range ascii { + fmt.Print(line) + fmt.Println() + } + fmt.Println() }