From 1401a881c33b29c9cc85c8a8875154fc11def640 Mon Sep 17 00:00:00 2001 From: Stephen von Takach Date: Mon, 13 Jan 2025 15:22:13 +1100 Subject: [PATCH] chore: simplify logging --- shard.lock | 54 ++++++-------------------------------------- shard.yml | 3 +++ src/config.cr | 3 --- src/search-ingest.cr | 14 +++++++----- src/telemetry.cr | 11 --------- 5 files changed, 18 insertions(+), 67 deletions(-) delete mode 100644 src/telemetry.cr diff --git a/shard.lock b/shard.lock index 3bb259d..9c31e20 100644 --- a/shard.lock +++ b/shard.lock @@ -36,22 +36,10 @@ shards: git: https://github.com/vici37/crystal-kcov.git version: 0.2.3+git.commit.7e49fe22d7d47040c9de77eb77a6daa76ce0655d - csuuid: - git: https://github.com/wyhaines/csuuid.cr.git - version: 1.0.2 - db: git: https://github.com/crystal-lang/crystal-db.git version: 0.13.1 - debug: - git: https://github.com/sija/debug.cr.git - version: 2.0.4 - - defined: - git: https://github.com/wyhaines/defined.cr.git - version: 0.3.6 - email: git: https://github.com/arcage/crystal-email.git version: 0.7.1 @@ -104,10 +92,6 @@ shards: git: https://github.com/luckyframework/lucky_router.git version: 0.6.0 - nbchannel: - git: https://github.com/wyhaines/nbchannel.cr.git - version: 0.1.0 - neuroplastic: git: https://github.com/spider-gazelle/neuroplastic.git version: 1.13.1 @@ -120,26 +104,10 @@ shards: git: https://github.com/spider-gazelle/openssl_ext.git version: 2.4.4 - opentelemetry-api: - git: https://github.com/wyhaines/opentelemetry-api.cr.git - version: 0.5.2+git.commit.77c9232ca6ff7de52529f309a0cb20b8459f7b20 - - opentelemetry-instrumentation: - git: https://github.com/wyhaines/opentelemetry-instrumentation.cr.git - version: 0.6.0+git.commit.6978cfe19aa590fb61fd7fdc0a25eb0c78674309 - - opentelemetry-sdk: - git: https://github.com/wyhaines/opentelemetry-sdk.cr.git - version: 0.6.4+git.commit.c7237732135f6d0cab84abc6bb6d438c9f8f9d66 - pars: git: https://github.com/spider-gazelle/pars.git version: 1.1.0 - parse_date: - git: https://github.com/wyhaines/parsedate.cr.git - version: 0.1.2 - pegmatite: git: https://github.com/jemc/crystal-pegmatite.git version: 0.2.3+git.commit.f1b6d99b71774f82b6bd17b825d6d7fdd5de38f9 @@ -158,7 +126,7 @@ shards: placeos-log-backend: git: https://github.com/place-labs/log-backend.git - version: 0.11.4 + version: 0.13.0 placeos-models: git: https://github.com/placeos/models.git @@ -176,10 +144,6 @@ shards: git: https://github.com/spider-gazelle/promise.git version: 3.2.0 - protobuf: - git: https://github.com/jeromegn/protobuf.cr.git - version: 2.3.1 - redis: git: https://github.com/stefanwille/crystal-redis.git version: 2.9.1 @@ -192,17 +156,13 @@ shards: git: https://github.com/place-labs/secrets-env.git version: 1.3.1 - splay_tree_map: - git: https://github.com/wyhaines/splay_tree_map.cr.git - version: 0.3.0 - - time-ext: - git: https://github.com/wyhaines/time-ext.cr.git - version: 1.0.1 + simple_retry: + git: https://github.com/spider-gazelle/simple_retry.git + version: 1.1.1 - tracer: - git: https://github.com/wyhaines/tracer.cr.git - version: 0.3.2 + tasker: + git: https://github.com/spider-gazelle/tasker.git + version: 2.1.4 ulid: git: https://github.com/place-labs/ulid.git diff --git a/shard.yml b/shard.yml index 999e838..1f8e90f 100644 --- a/shard.yml +++ b/shard.yml @@ -43,6 +43,9 @@ dependencies: github: place-labs/secrets-env version: ~> 1.3 + simple_retry: + github: spider-gazelle/simple_retry + development_dependencies: ameba: github: crystal-ameba/ameba diff --git a/src/config.cr b/src/config.cr index da92b5b..2a9ea90 100644 --- a/src/config.cr +++ b/src/config.cr @@ -38,9 +38,6 @@ require "./api" require "./constants" require "action-controller" -# Require telemetry after application code -require "./telemetry" - # Server require "action-controller/server" diff --git a/src/search-ingest.cr b/src/search-ingest.cr index ef3090e..24841b5 100644 --- a/src/search-ingest.cr +++ b/src/search-ingest.cr @@ -1,16 +1,18 @@ require "log_helper" - +require "simple_retry" require "./constants" require "./search-ingest/*" module SearchIngest def self.wait_for_elasticsearch - Retriable.retry( - max_elapsed_time: 1.minutes, - on_retry: ->(_e : Exception, n : Int32, _t : Time::Span, _i : Time::Span) { - Log.warn { "attempt #{n} connecting to #{SearchIngest::Elastic.settings.host}:#{SearchIngest::Elastic.settings.port}" } - } + attempt = 0 + SimpleRetry.try_to( + base_interval: 1.second, + max_elapsed_time: 1.minute ) do + attempt += 1 + Log.warn { "attempt #{attempt} connecting to #{SearchIngest::Elastic.settings.host}:#{SearchIngest::Elastic.settings.port}" } if attempt > 1 + # Ensure elastic is available raise "retry" unless SearchIngest::Elastic.healthy? end diff --git a/src/telemetry.cr b/src/telemetry.cr deleted file mode 100644 index 6308ef6..0000000 --- a/src/telemetry.cr +++ /dev/null @@ -1,11 +0,0 @@ -require "./logging" -require "opentelemetry-instrumentation/src/opentelemetry/instrumentation/instrument" -require "placeos-log-backend/telemetry" -require "placeos-resource/instrumentation" - -module SearchIngest - PlaceOS::LogBackend.configure_opentelemetry( - service_name: APP_NAME, - service_version: VERSION, - ) -end