Skip to content

Commit

Permalink
Test opentelemetry instrumentation
Browse files Browse the repository at this point in the history
  • Loading branch information
mephenor committed Jan 21, 2025
1 parent fec8533 commit 7d91de5
Show file tree
Hide file tree
Showing 47 changed files with 22,489 additions and 222 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ repos:
- id: no-commit-to-branch
args: [--branch, dev, --branch, int, --branch, main]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.1
rev: v0.9.2
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
13 changes: 13 additions & 0 deletions .pyproject_generation/pyproject_custom.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@ dependencies = [
"crypt4gh>=1.6",
"hvac>=2",
"httpx>=0.27",
"opentelemetry-api==1.29.0",
"opentelemetry-sdk==1.29.0",
"opentelemetry-distro==0.50b0",
"opentelemetry-instrumentation==0.50b0",
"opentelemetry-instrumentation-aiokafka==0.50b0",
"opentelemetry-instrumentation-asyncio==0.50b0",
"opentelemetry-instrumentation-botocore==0.50b0",
"opentelemetry-instrumentation-click==0.50b0",
"opentelemetry-instrumentation-fastapi==0.50b0",
"opentelemetry-instrumentation-httpx==0.50b0",
"opentelemetry-instrumentation-logging==0.50b0",
"opentelemetry-instrumentation-pymongo==0.50b0",
"opentelemetry-instrumentation-urllib3==0.50b0",
]

[project.urls]
Expand Down
414 changes: 278 additions & 136 deletions lock/requirements-dev.txt

Large diffs are not rendered by default.

428 changes: 343 additions & 85 deletions lock/requirements.txt

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@ dependencies = [
"crypt4gh>=1.6",
"hvac>=2",
"httpx>=0.27",
"opentelemetry-api==1.29.0",
"opentelemetry-sdk==1.29.0",
"opentelemetry-distro==0.50b0",
"opentelemetry-instrumentation==0.50b0",
"opentelemetry-instrumentation-aiokafka==0.50b0",
"opentelemetry-instrumentation-asyncio==0.50b0",
"opentelemetry-instrumentation-botocore==0.50b0",
"opentelemetry-instrumentation-click==0.50b0",
"opentelemetry-instrumentation-fastapi==0.50b0",
"opentelemetry-instrumentation-httpx==0.50b0",
"opentelemetry-instrumentation-logging==0.50b0",
"opentelemetry-instrumentation-pymongo==0.50b0",
"opentelemetry-instrumentation-urllib3==0.50b0",
]
readme = "README.md"
authors = [
Expand Down
51 changes: 51 additions & 0 deletions services/dcs/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Copyright 2021 - 2024 Universität Tübingen, DKFZ, EMBL, and Universität zu Köln
# for the German Human Genome-Phenome Archive (GHGA)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# BASE: a base image with updated packages
FROM python:3.12-alpine AS base
RUN apk upgrade --no-cache --available

# BUILDER: a container to build the service wheel
FROM base AS builder
RUN pip install build
COPY . /service
WORKDIR /service
RUN python -m build

# DEP-BUILDER: a container to (build and) install dependencies
FROM base AS dep-builder
RUN apk update
RUN apk add build-base gcc g++ libffi-dev zlib-dev
RUN apk upgrade --available
WORKDIR /service
COPY --from=builder /service/lock/requirements.txt /service
RUN pip install --no-deps -r requirements.txt
RUN echo $(find / -name opentelemetry-instrument)

# RUNNER: a container to run the service
FROM base AS runner
WORKDIR /service
RUN rm -rf /usr/local/lib/python3.12
COPY --from=dep-builder /usr/local/lib/python3.12 /usr/local/lib/python3.12
COPY --from=builder /service/dist/ /service
COPY --from=dep-builder /usr/local/bin/opentelemetry-instrument /usr/local/bin
RUN pip install --no-deps *.whl
RUN rm *.whl
RUN adduser -D appuser
WORKDIR /home/appuser
USER appuser
ENV PYTHONUNBUFFERED=1

ENTRYPOINT ["opentelemetry-instrument", "--traces_export", "console", "--metrics_exporter", "console", "--logs_export", "console", "dcs"]
56 changes: 56 additions & 0 deletions services/dcs/lock/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!--
Copyright 2021 - 2023 Universität Tübingen, DKFZ, EMBL, and Universität zu Köln
for the German Human Genome-Phenome Archive (GHGA)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

# Lock Files

This directory contains two lock files locking the dependencies of this microservice:

The [`./requirements.txt`](./requirements.txt) contains production dependencies.

The [`./requirements-dev.txt`](./requirements-dev.txt) additionally contains development
dependencies.

## Sources

For generating the production lock file, only the dependencies specified in the
[`../pyproject.toml`](../pyproject.toml) are considered as input.

For generating the development lock file, additionally, the
[`./requirements-dev-template.in`](./requirements-dev-template.in) as well as
the [`./requirements-dev.in`](./requirements-dev.in) are considered.

The `./requirements-dev-template.in` is automatically updated from the template
repository and should not be manually modified.

If you require additional dev dependencies not part of the
`./requirements-dev-template.in`, you can add them to the
`./requirements-dev.in`.

## Update and Upgrade

The lock files can be updated running the
[`../scripts/update_lock.py`](../scripts/update_lock.py) script. This will keep the
dependency versions in the lockfile unchanged unless they are in conflict with the
the input sources. In that case, the affected dependencies are updated to the latest
versions compatible with the input.

If you would like to upgrade all dependencies in the lock file to the latest versions
compatible with the input, you can run `../scripts/update_lock.py --upgrade`.

If you just want to check if the script would do update, you can run
`../scripts/update_lock.py --check`.
32 changes: 32 additions & 0 deletions services/dcs/lock/requirements-dev-template.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# common requirements for development and testing of services

pytest>=8.2
pytest-asyncio>=0.23.7
pytest-cov>=5
snakeviz>=2.2
logot>=1.3

pre-commit>=3.7

mypy>=1.10
mypy-extensions>=1.0

ruff>=0.4

click>=8.1
typer>=0.12

httpx>=0.27
pytest-httpx>=0.30

urllib3>=1.26.18
requests>=2.31

stringcase>=1.2
jsonschema2md>=1.1
setuptools>=69.5

# required since switch to pyproject.toml and pip-tools
tomli_w>=1.0

uv>=0.2.13
7 changes: 7 additions & 0 deletions services/dcs/lock/requirements-dev.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# requirements for development and testing this service

# template requirements for development and testing
-r requirements-dev-template.in

# additional requirements can be listed here
testcontainers[kafka,mongo]>=4.6.0
Loading

0 comments on commit 7d91de5

Please sign in to comment.