diff --git a/.circleci/config.yml b/.circleci/config.yml index 1d16cf8df..5d0b47eb4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -44,14 +44,6 @@ workflows: ignore: /.*/ tags: only: /^v[0-9]+(\.[0-9]+)*$/ - - compile-armhf: - requires: - - deps - filters: - branches: - ignore: /.*/ - tags: - only: /^v[0-9]+(\.[0-9]+)*$/ - compile-arm64: requires: - deps @@ -69,15 +61,6 @@ workflows: ignore: /.*/ tags: only: /^v[0-9]+(\.[0-9]+)*$/ - - package-debian-armhf: - requires: - - compile-armhf - - versions - filters: - branches: - ignore: /.*/ - tags: - only: /^v[0-9]+(\.[0-9]+)*$/ - package-debian-arm64: requires: - compile-arm64 @@ -91,7 +74,6 @@ workflows: requires: - unit-test - package-debian-amd64 - - package-debian-armhf - package-debian-arm64 filters: branches: @@ -128,9 +110,6 @@ workflows: - compile-amd64: requires: - deps - - compile-armhf: - requires: - - deps - compile-arm64: requires: - deps @@ -138,10 +117,6 @@ workflows: requires: - compile-amd64 - versions - - package-debian-armhf: - requires: - - compile-armhf - - versions - package-debian-arm64: requires: - compile-arm64 @@ -150,7 +125,6 @@ workflows: requires: - unit-test - package-debian-amd64 - - package-debian-armhf - package-debian-arm64 - blackbox-test-amd64: requires: @@ -230,7 +204,7 @@ jobs: echo -e "${META}" > /mnt/ramdisk/META else echo -e "${CIRCLE_TAG#v}" > /mnt/ramdisk/VERSION - echo -e "main" > /mnt/ramdisk/META + echo -e "-main" > /mnt/ramdisk/META fi - save_cache: key: versions-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }} @@ -301,29 +275,6 @@ jobs: # -------------------------------------------------------------------------- # - compile-armhf: - executor: go - working_directory: /mnt/ramdisk - steps: - - restore_cache: - key: code-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }} - - restore_cache: - key: dependencies-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }} - - run: - name: Compile lake binary - command: | - /mnt/ramdisk/dev/lifecycle/package \ - --arch linux/armhf \ - --source /mnt/ramdisk/services/lake \ - --output /mnt/ramdisk/packaging/bin - no_output_timeout: 5m - - save_cache: - key: binaries-armhf-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }} - paths: - - /mnt/ramdisk/packaging/bin - - # -------------------------------------------------------------------------- # - compile-arm64: executor: go working_directory: /home/circleci/project @@ -374,33 +325,6 @@ jobs: # -------------------------------------------------------------------------- # - package-debian-armhf: - executor: debian - working_directory: /mnt/ramdisk - steps: - - restore_cache: - key: code-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }} - - restore_cache: - key: binaries-armhf-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }} - - restore_cache: - key: versions-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }} - - run: - name: Package for debian - command: | - VERSION=$(cat /mnt/ramdisk/VERSION) - /mnt/ramdisk/dev/lifecycle/debian \ - --arch armhf \ - --pkg lake \ - --version ${VERSION} \ - --source /mnt/ramdisk/packaging - no_output_timeout: 5m - - save_cache: - key: debian-armhf-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }} - paths: - - /mnt/ramdisk/packaging/bin - - # -------------------------------------------------------------------------- # - package-debian-arm64: executor: debian working_directory: /mnt/ramdisk @@ -437,14 +361,10 @@ jobs: key: code-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }} - restore_cache: key: binaries-amd64-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }} - - restore_cache: - key: binaries-armhf-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }} - restore_cache: key: binaries-arm64-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }} - restore_cache: key: debian-amd64-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }} - - restore_cache: - key: debian-armhf-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }} - restore_cache: key: debian-arm64-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }} - restore_cache: @@ -508,13 +428,14 @@ jobs: echo -e "${META}" > /home/circleci/project/META else echo -e "${CIRCLE_TAG#v}" > /home/circleci/project/VERSION - echo -e "main" > /home/circleci/project/META + echo -e "-main" > /home/circleci/project/META fi - run: name: Run blackbox tests command: | export VERSION=v$(cat /home/circleci/project/VERSION) export META=$(cat /home/circleci/project/META) + export ARCH=amd64 docker-compose up -d bbtest docker exec -t $(docker-compose ps -q bbtest) python3 /opt/app/bbtest/main.py @@ -536,14 +457,10 @@ jobs: key: code-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }} - restore_cache: key: binaries-amd64-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }} - - restore_cache: - key: binaries-armhf-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }} - restore_cache: key: binaries-arm64-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }} - restore_cache: key: debian-amd64-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }} - - restore_cache: - key: debian-armhf-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }} - restore_cache: key: debian-arm64-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }} - deploy: diff --git a/.jenkins/commit.groovy b/.jenkins/commit.groovy index a151c2ce3..716c6848c 100644 --- a/.jenkins/commit.groovy +++ b/.jenkins/commit.groovy @@ -213,7 +213,6 @@ pipeline { options = """ |-e IMAGE_VERSION=${env.VERSION} |-e UNIT_VERSION=${env.VERSION} - |-e UNIT_ARCH=${env.ARCH} |--volumes-from=${cid} |-v /var/run/docker.sock:/var/run/docker.sock:rw |-v /var/lib/docker/containers:/var/lib/docker/containers:rw diff --git a/.jenkins/perf.groovy b/.jenkins/perf.groovy index 10da61562..da0c6287c 100644 --- a/.jenkins/perf.groovy +++ b/.jenkins/perf.groovy @@ -77,7 +77,6 @@ pipeline { options = """ |-e IMAGE_VERSION=${params.VERSION} |-e UNIT_VERSION=${params.VERSION} - |-e UNIT_ARCH=amd64 |-e MESSAGES_PUSHED=${params.MESSAGES_RELAYED} |--volumes-from=${cid} |--cpus=1 diff --git a/Makefile b/Makefile index afbfebe71..b78b0ec51 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ META := $(shell git rev-parse --abbrev-ref HEAD 2> /dev/null | sed 's:.*/::') VERSION := $(shell git fetch --tags --force 2> /dev/null; tags=($$(git tag --sort=-v:refname)) && ([ $${\#tags[@]} -eq 0 ] && echo v0.0.0 || echo $${tags[0]})) +ARCH := $(shell uname -m | sed 's/x86_64/amd64/') export COMPOSE_DOCKER_CLI_BUILD = 1 export DOCKER_BUILDKIT = 1 @@ -9,14 +10,13 @@ export COMPOSE_PROJECT_NAME = lake .ONESHELL: .PHONY: arm64 .PHONY: amd64 -.PHONY: armhf .PHONY: all all: bootstrap sync test package bbtest perf .PHONY: package package: - @$(MAKE) package-amd64 + @$(MAKE) package-$(ARCH) @$(MAKE) bundle-docker .PHONY: package-% @@ -26,7 +26,7 @@ package-%: % .PHONY: bundle-binaries-% bundle-binaries-%: % - @docker-compose \ + @ARCH=$(ARCH) docker-compose \ run \ --rm package \ --arch linux/$^ \ @@ -35,7 +35,7 @@ bundle-binaries-%: % .PHONY: bundle-debian-% bundle-debian-%: % - @docker-compose \ + @ARCH=$(ARCH) docker-compose \ run \ --rm debian-package \ --version $(VERSION) \ @@ -52,7 +52,7 @@ bundle-docker: .PHONY: bootstrap bootstrap: - @docker-compose build --force-rm go + @ARCH=$(ARCH) docker-compose build --force-rm go .PHONY: lint lint: @@ -64,7 +64,7 @@ lint: .PHONY: sec sec: - @docker-compose \ + @ARCH=$(ARCH) docker-compose \ run \ --rm sec \ --source /go/src/github.com/jancajthaml-openbank/lake \ @@ -72,7 +72,7 @@ sec: .PHONY: sync sync: - @docker-compose \ + @ARCH=$(ARCH) docker-compose \ run \ --rm sync \ --source /go/src/github.com/jancajthaml-openbank/lake @@ -86,7 +86,7 @@ scan: .PHONY: test test: - @docker-compose \ + @ARCH=$(ARCH) docker-compose \ run \ --rm test \ --source /go/src/github.com/jancajthaml-openbank/lake \ @@ -94,7 +94,7 @@ test: .PHONY: release release: - @docker-compose \ + @ARCH=$(ARCH) docker-compose \ run \ --rm release \ --version $(VERSION) \ @@ -102,12 +102,12 @@ release: .PHONY: bbtest bbtest: - @META=$(META) VERSION=$(VERSION) docker-compose up -d bbtest - @docker exec -t $$(docker-compose ps -q bbtest) python3 /opt/app/bbtest/main.py - @docker-compose down -v + @ARCH=$(ARCH) META=$(META) VERSION=$(VERSION) docker-compose up -d bbtest + @docker exec -t $$(ARCH=$(ARCH) docker-compose ps -q bbtest) python3 /opt/app/bbtest/main.py + @ARCH=$(ARCH) docker-compose down -v .PHONY: perf perf: - @META=$(META) VERSION=$(VERSION) docker-compose up -d perf - @docker exec -t $$(docker-compose ps -q perf) python3 /opt/app/perf/main.py - @docker-compose down -v + @ARCH=$(ARCH) META=$(META) VERSION=$(VERSION) docker-compose up -d perf + @docker exec -t $$(ARCH=$(ARCH) docker-compose ps -q perf) python3 /opt/app/perf/main.py + @ARCH=$(ARCH) docker-compose down -v diff --git a/bbtest/features/metrics.feature b/bbtest/features/metrics.feature index bda7a9ceb..b76d67d86 100644 --- a/bbtest/features/metrics.feature +++ b/bbtest/features/metrics.feature @@ -8,6 +8,5 @@ Feature: Metrics test Then lake responds with "A B" And metrics reports: | key | type | value | - | openbank.lake.message.ingress | count | 1 | - | openbank.lake.message.egress | count | 1 | + | openbank.lake.message.relayed | count | 1 | | openbank.lake.memory.bytes | gauce | | diff --git a/bbtest/helpers/unit.py b/bbtest/helpers/unit.py index 105609d84..f67148ab0 100644 --- a/bbtest/helpers/unit.py +++ b/bbtest/helpers/unit.py @@ -25,8 +25,8 @@ def default_config(): def get_arch(self): return { 'x86_64': 'amd64', - 'armv7l': 'armhf', - 'armv8': 'arm64' + 'armv8': 'arm64', + 'aarch64': 'arm64', }.get(platform.uname().machine, 'amd64') def __init__(self, context): diff --git a/dev/lifecycle/debian b/dev/lifecycle/debian index 48c7e1346..6555186cd 100755 --- a/dev/lifecycle/debian +++ b/dev/lifecycle/debian @@ -101,7 +101,6 @@ lifecycle::debian::package() { local CC=gcc case ${TARGET_ARCHITECTURE} in - armhf) CC=arm-linux-gnueabihf-gcc ;; arm64) CC=aarch64-linux-gnu-gcc ;; *) CC=gcc ;; esac diff --git a/dev/lifecycle/package b/dev/lifecycle/package index 65d2fdafa..9f87a93e5 100755 --- a/dev/lifecycle/package +++ b/dev/lifecycle/package @@ -67,22 +67,6 @@ lifecycle::go::build() { case ${ARCH} in - armhf) - cd ${source} && \ - \ - GOOS=${PLATFORM} \ - GOARM=7 \ - GOARCH=arm \ - CGO_ENABLED=1 \ - GOFLAGS=-buildmode=pie \ - CC=arm-linux-gnueabihf-gcc \ - \ - go build -a -o ${output} || { - (>&2 echo "[error] ${output} unable to build") - exit 1 - } - ;; - arm64) cd ${source} && \ \ @@ -133,10 +117,6 @@ lifecycle::go::strip() { case ${ARCH} in - armhf) - arm-linux-gnueabihf-objcopy --strip-unneeded ${output} - ;; - arm64) aarch64-linux-gnu-objcopy --strip-unneeded ${output} ;; diff --git a/docker-compose.yml b/docker-compose.yml index acd6a5583..e91cd1421 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,8 +10,8 @@ services: image: jancajthaml/go tty: true volumes: - - .:/project - - ./services/lake:/go/src/github.com/jancajthaml-openbank/lake + - .:/project:delegated + - ./services/lake:/go/src/github.com/jancajthaml-openbank/lake:delegated working_dir: /project environment: - GOOS @@ -25,7 +25,7 @@ services: image: jancajthaml/debian-packager tty: true volumes: - - .:/project + - .:/project:delegated working_dir: /project # -------------------------------------------------------------------------- # @@ -87,11 +87,10 @@ services: # -------------------------------------------------------------------------- # bbtest: - image: jancajthaml/bbtest:amd64 + image: jancajthaml/bbtest:${ARCH} environment: IMAGE_VERSION: ${VERSION:-latest}-${META:-main} UNIT_VERSION: ${VERSION:-latest} - UNIT_ARCH: amd64 CI: ${CI:-false} volumes: - /var/run/docker.sock:/var/run/docker.sock:rw @@ -103,12 +102,11 @@ services: # -------------------------------------------------------------------------- # perf: - image: jancajthaml/bbtest:amd64 + image: jancajthaml/bbtest:${ARCH} environment: IMAGE_VERSION: ${VERSION:-latest}-${META:-main} UNIT_VERSION: ${VERSION:-latest} - UNIT_ARCH: amd64 - MESSAGES_PUSHED: 10000000 + MESSAGES_PUSHED: 100000000 volumes: - /var/run/docker.sock:/var/run/docker.sock:rw - /var/lib/docker/containers:/var/lib/docker/containers:rw diff --git a/packaging/debian/lake.install.armhf b/packaging/debian/lake.install.armhf deleted file mode 100644 index 079a3067b..000000000 --- a/packaging/debian/lake.install.armhf +++ /dev/null @@ -1,2 +0,0 @@ -bin/lake-linux-armhf usr/bin -init.conf etc/lake/conf.d diff --git a/perf/appliance_manager.py b/perf/appliance_manager.py index fc04619b5..424972e04 100644 --- a/perf/appliance_manager.py +++ b/perf/appliance_manager.py @@ -16,8 +16,8 @@ class ApplianceManager(object): def get_arch(self): return { 'x86_64': 'amd64', - 'armv7l': 'armhf', - 'armv8': 'arm64' + 'armv8': 'arm64', + 'aarch64': 'arm64', }.get(platform.uname().machine, 'amd64') def __init__(self): @@ -138,7 +138,7 @@ def __delitem__(self, key): def configure(self) -> None: options = { - 'LOG_LEVEL': 'INFO', + 'LOG_LEVEL': 'DEBUG', 'PORT_PULL': '5562', 'PORT_PUB': '5561', 'STATSD_ENDPOINT': '127.0.0.1:8125', diff --git a/perf/main.py b/perf/main.py index f7fea2e8c..7c83f81eb 100644 --- a/perf/main.py +++ b/perf/main.py @@ -55,14 +55,15 @@ def main(): messages_to_push = int(os.environ.get('MESSAGES_PUSHED', '100000')) i = 1_000 + while i <= messages_to_push: info('pushing {:,.0f} messages throught ZMQ'.format(i)) - with timeit('{:,.0f} messages'.format(i)): + with timeit('{:,.0f} messages relay'.format(i)): with metrics(manager, 'count_{}'.format(i)): Publisher(i) info('generating graph for {:,.0f} messages'.format(i)) - with timeit('{:,.0f} ingress graph'.format(i)): + with timeit('{:,.0f} graph plotting'.format(i)): Graph(Metrics('{}/../reports/perf-tests/metrics/metrics.count_{}.json'.format(cwd, i))) i *= 10 diff --git a/perf/messaging/publisher.py b/perf/messaging/publisher.py index 81ec5014a..8e8801ba6 100644 --- a/perf/messaging/publisher.py +++ b/perf/messaging/publisher.py @@ -3,6 +3,7 @@ import time import zmq +#import zmq.green as zmq import math import itertools from multiprocessing import Process @@ -24,6 +25,7 @@ def PusherWorker(number_of_messages, port): push_url = 'tcp://127.0.0.1:{}'.format(port) ctx = zmq.Context.instance() + ctx.set(zmq.IO_THREADS, 1) region = 'PERF' msg = "YXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXZ" @@ -34,21 +36,8 @@ def PusherWorker(number_of_messages, port): number_of_messages = int(number_of_messages) - def do_it(): - while True: - try: - push.send(msg) - return - except zmq.ZMQError as e: - if e.errno == zmq.EAGAIN: - continue - else: - raise e - except Exception as e: - raise e - for _ in itertools.repeat(None, number_of_messages): - do_it() + push.send(msg) push.disconnect(push_url) @@ -78,10 +67,7 @@ def SubscriberWorker(number_of_messages, port): try: sub.recv() except: - if fails > 2: - break - else: - fails += 1 + break sub.disconnect(sub_url) diff --git a/perf/metrics/aggregator.py b/perf/metrics/aggregator.py index 22da6fbd6..68295c869 100644 --- a/perf/metrics/aggregator.py +++ b/perf/metrics/aggregator.py @@ -34,7 +34,7 @@ def strip_trailing_zero_values(self) -> None: last_not_nil = None in_deletion_stage = False for key, value in self.__store.items(): - if value['i'] != 0 and value['e'] != 0: + if value['i'] != 0: last_not_nil = key for key in self.__store.keys(): if key == last_not_nil: @@ -63,14 +63,12 @@ def __process_change(self, data) -> None: if not ts in self.__store: self.__store[ts] = { - 'e': 0, 'i': 0, 'm': 0, } - if key == 'openbank.lake.message.ingress': - self.__store[ts]['i'] += int(value) - elif key == 'openbank.lake.message.egress': - self.__store[ts]['e'] += int(value) + if key == 'openbank.lake.message.relayed': + if int(value) != 1: + self.__store[ts]['i'] += int(value) elif key == 'openbank.lake.memory.bytes': self.__store[ts]['m'] = max(self.__store[ts]['m'], int(value)) diff --git a/perf/metrics/plot.py b/perf/metrics/plot.py index 4cc36c815..50d4bb515 100644 --- a/perf/metrics/plot.py +++ b/perf/metrics/plot.py @@ -59,18 +59,14 @@ def __init__(self, metrics): x1 = list(range(0, duration, 1)) y1 = [item['i'] for item in metrics.dataset.values()] fps_i = [item['i'] for item in metrics.dataset.values()] - fps_e = [item['e'] for item in metrics.dataset.values()] if duration == 1: duration += 1 x1 = [0] + [x + 1 for x in x1] y1 = [0] + y1 fps_i = [fps_i[0]] + fps_i - fps_e = [fps_e[0]] + fps_e - fps_i_median = numpy.median(fps_i) - fps_e_median = numpy.median(fps_e) - fps_median = min(fps_i_median, fps_e_median) + fps_median = numpy.mean(fps_i) x_interval = list(reversed(range(duration-1, -1, min(-1, -int(duration/4))))) x_interval[0] = 0 @@ -86,11 +82,10 @@ def __init__(self, metrics): ax2 = ax1.twinx() ax2.plot(x1, [fps_median if len(fps_i) else 0]*len(x1), linewidth=0.5, linestyle='--', antialiased=False, color='black') - ax2.plot(x1, fps_i, linewidth=3, color='green', antialiased=True) - ax2.plot(x1, fps_e, linewidth=1, color='crimson', antialiased=True) + ax2.plot(x1, fps_i, linewidth=1, color='crimson', antialiased=True) #dodgerblue ax2.set_xlim(xmin=0, xmax=max(x1)) - ax2.set_ylim(ymin=0, ymax=max(y1) * 2) + ax2.set_ylim(ymin=0, ymax=max(max(y1), 2*fps_median)) ax2.set_yticks([0, fps_median]) ax2.set_yticklabels(['{} / s'.format(human_readable_count(x)) for x in ax2.get_yticks()]) diff --git a/perf/utils.py b/perf/utils.py index e3aa9cd41..68f967524 100644 --- a/perf/utils.py +++ b/perf/utils.py @@ -47,7 +47,7 @@ def info(msg) -> None: def print_daemon(msg) -> None: this.__progress_running = False - sys.stdout.write('\033[0m │ {0}\033[0m \n'.format(msg)) + sys.stdout.write('\033[0m │ {0} \n'.format(msg)) sys.stdout.flush() def error(msg) -> None: @@ -81,7 +81,7 @@ def __exit__(self, exception_type, exception_value, traceback): return te = time.time() - sys.stdout.write('\033[90m │ {0} took {1}\033[0m\n'.format(self.__label, human_readable_duration((te - self.ts)*1e3))) + sys.stdout.write('\033[0m │\033[90m {0} took {1}\033[0m\n'.format(self.__label, human_readable_duration((te - self.ts)*1e3))) sys.stdout.flush() def human_readable_count(num): diff --git a/services/lake/metrics/metrics.go b/services/lake/metrics/metrics.go index 28b632ea7..108aaabd6 100644 --- a/services/lake/metrics/metrics.go +++ b/services/lake/metrics/metrics.go @@ -22,15 +22,13 @@ import ( // Metrics provides helper function for metrics type Metrics interface { - MessageEgress() - MessageIngress() + Message() } // StatsdMetrics provides metrics helper with statsd client type StatsdMetrics struct { client *statsd.Client - messageEgress int64 - messageIngress int64 + messageRelayed int64 } // NewMetrics returns blank metrics holder @@ -42,25 +40,16 @@ func NewMetrics(endpoint string) *StatsdMetrics { } return &StatsdMetrics{ client: client, - messageEgress: int64(0), - messageIngress: int64(0), + messageRelayed: int64(0), } } -// MessageEgress increment number of outcomming messages -func (instance *StatsdMetrics) MessageEgress() { +// MessageEgress increment number of relayed messages +func (instance *StatsdMetrics) Message() { if instance == nil { return } - instance.messageEgress +=1 -} - -// MessageIngress increment number of incomming messages -func (instance *StatsdMetrics) MessageIngress() { - if instance == nil { - return - } - instance.messageIngress +=1 + instance.messageRelayed +=1 } // Setup does nothing @@ -87,17 +76,13 @@ func (instance *StatsdMetrics) Work() { return } - egress := instance.messageEgress - ingress := instance.messageIngress - + relayed := instance.messageRelayed var stats = new(runtime.MemStats) runtime.ReadMemStats(stats) - instance.client.Count("openbank.lake.message.ingress", ingress, nil, 1) - instance.client.Count("openbank.lake.message.egress", egress, nil, 1) + instance.client.Count("openbank.lake.message.relayed", relayed, nil, 1) instance.client.Gauge("openbank.lake.memory.bytes", float64(stats.Sys), nil, 1) - instance.messageEgress -= egress - instance.messageIngress -= ingress + instance.messageRelayed -= relayed } diff --git a/services/lake/relay/relay.go b/services/lake/relay/relay.go index 43d1fe486..34ee89e0b 100644 --- a/services/lake/relay/relay.go +++ b/services/lake/relay/relay.go @@ -187,7 +187,6 @@ pull: if err != nil { goto fail } - relay.metrics.MessageIngress() pub: _, err = relay.publisher.SendBytes(chunk, 0) if err != nil { @@ -196,7 +195,7 @@ pub: } goto fail } - relay.metrics.MessageEgress() + relay.metrics.Message() goto pull fail: diff --git a/services/lake/relay/relay_test.go b/services/lake/relay/relay_test.go index 4f46317e9..5046df5d2 100644 --- a/services/lake/relay/relay_test.go +++ b/services/lake/relay/relay_test.go @@ -14,8 +14,7 @@ import ( type mockMetrics struct{} -func (mockMetrics) MessageEgress() {} -func (mockMetrics) MessageIngress() {} +func (mockMetrics) Message() {} func subRoutine(ctx context.Context, cancel context.CancelFunc, sub chan string, port int) { runtime.LockOSThread()