From e2ca05262cd27dd5e0fa26f07fb38230df49b4c6 Mon Sep 17 00:00:00 2001 From: Siegfried Puchbauer Date: Fri, 5 Mar 2021 19:19:39 -0800 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20Exposing=20git=20commit?= =?UTF-8?q?=20SHA=20in=20--version=20output?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yaml | 2 +- Dockerfile | 3 +++ docs/cli.md | 4 ++-- src/index.ts | 8 +++++++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index cbd7993..32a5723 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -25,7 +25,7 @@ jobs: - name: Pull latest pre-release image run: docker pull ghcr.io/splunkdlt/ethlogger-pre:latest - name: Build docker image - run: docker build -t ghcr.io/splunkdlt/ethlogger-pre:commit-$GITHUB_SHA . --cache-from ghcr.io/splunkdlt/ethlogger-pre:latest + run: docker build --build-arg ETHLOGGER_GIT_COMMIT=$GITHUB_SHA -t ghcr.io/splunkdlt/ethlogger-pre:commit-$GITHUB_SHA . --cache-from ghcr.io/splunkdlt/ethlogger-pre:latest - name: Publish docker image run: docker push ghcr.io/splunkdlt/ethlogger-pre:commit-$GITHUB_SHA - name: Publish docker image diff --git a/Dockerfile b/Dockerfile index edce606..97af565 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,4 +32,7 @@ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 CMD ethlo ENV NODE_ENV production ENV NODE_OPTS --max-old-size=4096 +ARG ETHLOGGER_GIT_COMMIT="n/a" +ENV ETHLOGGER_GIT_COMMIT $ETHLOGGER_GIT_COMMIT + ENTRYPOINT [ "ethlogger" ] diff --git a/docs/cli.md b/docs/cli.md index 3d4b196..d445899 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -7,10 +7,10 @@ The ethlogger CLI tool is used to start and configure connections to the blockch ``` -Splunk Connect for Ethereum +Ethlogger is an agent to gather metrics and blockchain information from an Ethereum node and ingest it in Splunk via its HTTP Event Collector. It is part of Splunk Connect for Ethereum. USAGE - $ ethlogger + $ ethlogger --rpc-url= [options] OPTIONS -c, --config-file=config-file diff --git a/src/index.ts b/src/index.ts index 688879b..1a9669c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -25,12 +25,18 @@ import { InternalStatsCollector } from './utils/stats'; const { debug, error, info } = createModuleDebug('cli'); class Ethlogger extends Command { - static description = 'Splunk Connect for Ethereum'; + static description = + 'Ethlogger is an agent to gather metrics and blockchain information from an Ethereum node ' + + 'and ingest it in Splunk via its HTTP Event Collector. It is part of Splunk Connect for Ethereum.'; + static usage = '--rpc-url= [options]'; static flags = CLI_FLAGS; private resources: ManagedResource[] = []; async run() { + if (process.env.ETHLOGGER_GIT_COMMIT != null) { + this.config.userAgent = `${this.config.userAgent} git-sha=${process.env.ETHLOGGER_GIT_COMMIT}`; + } const { flags } = this.parse(Ethlogger); if (flags.debug) {