Skip to content

Commit

Permalink
fix git version fetching
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel-v committed Jan 28, 2023
1 parent 5c0bec2 commit a8e9420
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.git
# .git
.cache
blobs
snoop/localsettings.py
Expand Down
6 changes: 6 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,14 @@ depends_on:
concurrency:
limit: 1

clone:
depth: 5000

steps:
- name: fetch
image: alpine/git
commands:
- git fetch --tags

- name: GH CR build base docker image
image: plugins/docker
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ ADD Pipfile Pipfile.lock ./
RUN pipenv install --system --deploy --ignore-pipfile

COPY . .
COPY .git .
RUN chmod +x /opt/hoover/snoop/docker-entrypoint.sh

ENV THREAD_COUNT 20
Expand Down
2 changes: 1 addition & 1 deletion snoop/data/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from celery import Celery
from celery.signals import worker_process_init

from hoover.search.tracing import init_tracing
from snoop.data.tracing import init_tracing

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "snoop.defaultsettings")

Expand Down
16 changes: 12 additions & 4 deletions snoop/data/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# from opentelemetry.instrumentation.celery import CeleryInstrumentor

SERVICE_NAME = "hoover-snoop"
SERVICE_VERSION = subprocess.check_output("git describe --tags", shell=True).decode().strip()
SERVICE_VERSION = subprocess.check_output("git describe --tags --always", shell=True).decode().strip()

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -76,9 +76,17 @@ def span(self, *args, **kwds):
finally:
if we_are_first:
log.debug('destroying tracer for module %s...', self.name)
trace.get_tracer_provider().force_flush()
trace.get_tracer_provider().shutdown()
local.tracer = None
try:
trace.get_tracer_provider().force_flush()
trace.get_tracer_provider().shutdown()
# the ProxyTracerProvider we get when no tracing is configured
# doesn't have these methods.
except AttributeError:
pass
except Exception as e:
log.warning('tracer shutdown exception: ' + str(e))
finally:
local.tracer = None

def wrap_function(self):
"""Returns a function wrapper that has a telemetry span around the function.
Expand Down

0 comments on commit a8e9420

Please sign in to comment.