Read-only mirror of https://github.com/swissgeo/service-processes — SWISSGEO. Issues & pull requests at the source.
  • Python 78.6%
  • Makefile 14.6%
  • Dockerfile 6.8%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Benjamin Sugden 22f84bac97
Merge pull request #2 from swissgeo/feat-GPS-1009-setup
GPS-1009: Initial FastAPI setup
2026-09-24 11:50:26 +02:00
.github Added/Modified github workflows pr-auto-semver.yml #skip-tagging-and-release 2026-09-21 14:48:11 +02:00
app GPS-1009: Various minor improvements 2026-09-24 11:37:19 +02:00
.dockerignore GPS-1009: Various minor improvements 2026-09-24 11:37:19 +02:00
.env.default GPS-1009: Build status badges 2026-09-22 16:53:53 +02:00
.env.otel GPS-1009: Build status badges 2026-09-22 16:53:53 +02:00
.gitignore GPS-1009: Various minor improvements 2026-09-24 11:37:19 +02:00
.pre-commit-config.yaml GPS-1009: Initial FastAPI setup 2026-09-22 09:17:24 +02:00
.python-version GPS-1009: Initial FastAPI setup 2026-09-22 09:17:24 +02:00
docker-compose.yml GPS-1009: Initial FastAPI setup 2026-09-22 09:17:24 +02:00
Dockerfile GPS-1009: Various minor improvements 2026-09-24 11:37:19 +02:00
LICENSE.md Initial commit 2026-09-21 14:47:12 +02:00
logging-local-config.yaml GPS-1009: Initial FastAPI setup 2026-09-22 09:17:24 +02:00
logging-otel-config.yaml GPS-1009: Initial FastAPI setup 2026-09-22 09:17:24 +02:00
Makefile GPS-1009: Various minor improvements 2026-09-24 11:37:19 +02:00
otel-local-config.yaml GPS-1009: Initial FastAPI setup 2026-09-22 09:17:24 +02:00
prometheus.yml GPS-1009: Initial FastAPI setup 2026-09-22 09:17:24 +02:00
pyproject.toml GPS-1009: Various minor improvements 2026-09-24 11:37:19 +02:00
README.md GPS-1009: Various minor improvements 2026-09-24 11:37:19 +02:00
uv.lock GPS-1009: Various minor improvements 2026-09-24 11:37:19 +02:00

service-processes

Branch Status
develop Build Status codecov
main Build Status codecov

Service processes provides an API for managing and monitoring pipelines, decoupling consumers from Airflow's native API.

Development

This service uses the FastAPI framework.

Dependencies

Prerequisites on host for development and build:

  • python version 3.14
  • uv
  • docker and docker compose

Setup

To create and activate a virtual Python environment with all dependencies installed:

make setup

Then run OTEL dependencies

make docker-compose-up

Then run the server from a separate terminal

make serve

Linting and Formatting

This project uses ruff as linter and formatter. It also uses ty as type checker.

To lint and type check use

make lint

To format

make format

Pre-Commit Hooks

This project uses pre-commit hook to lint and type-check before committing. Pre-commits hooks can either be bypassed entirely with the --no-verify option (git commit --no-verify ...), or individually using the SKIP environment variable (SKIP=lint git commit ...).

Updating Packages

All packages used in production are pinned to a major version. Automatically updating these packages will use the latest minor (or patch) version available. Packages used for development, on the other hand, are not pinned unless they need to be used with a specific version of a production package (for example, boto3-stubs for boto3).

To update the packages to the latest minor/compatible versions, run:

uv sync --upgrade

To see what major/incompatible releases would be available, run:

uv pip list --outdated

To update packages to a new major release, run:

uv add "fastapi[standard]~=v0.141"

Testing

This project uses pytest for testing, to start the tests enter

make test

OpenAPI

FastAPI automatically generates an OpenAPI schema, so each path operation should define its request parameters and responses using pydantic models to ensure they are properly documented. To view the OpenAPI documentation, run:

make serve

And then open:

Observability

The service supports OpenTelemetry logging, tracing, and metrics.

Metrics

FastAPI auto-instrumentation metrics

The FastAPIInstrumentor (backed by opentelemetry-instrumentation-asgi) emits the following metrics automatically for every HTTP request. The default semantic-convention mode (DEFAULT) uses the old HTTP semconv attribute names.

Metric name Type Unit Description
http.server.request.duration Histogram s Duration of inbound HTTP requests
http.server.request.body.size Histogram By Size of HTTP request messages (compressed)
http.server.response.body.size Histogram By Size of HTTP response messages (compressed)
http.server.active_requests UpDownCounter {request} Number of currently in-flight HTTP requests

Attributes attached to http.server.request.duration, http.server.request.body.size, and http.server.response.body.size:

Attribute Example Description
url.scheme http URL scheme
network.protocol.version 1.1 Network protocol version
http.request.method GET HTTP request method
http.route / HTTP route
http.response.status_code 200 HTTP response status code

Attributes attached to http.server.active_requests:

Attribute Example
http.request.method GET
url.scheme http

Note

The metrics above are from the new semantic convention for HTTP. They need to be enabled by setting OTEL_SEMCONV_STABILITY_OPT_IN=http in your environment. Use OTEL_SEMCONV_STABILITY_OPT_IN=http/dup to emit both old and new metrics simultaneously during a migration.

In production deployments, telemetry can be exported using the configured OTLP exporters, typically to an OpenTelemetry Collector or any OTLP-compatible observability platform. Only the OTLP exporter is currently implemented by the application configuration layer.

By default, local development with the FastAPI dev server (make serve) runs with OpenTelemetry disabled and uses standard Python console logging for a simpler and more readable developer experience.

See OpenTelemetry Python Instrumentation documentation for more information about adding tracing and metrics inside the application code.

Logging implementation

The application uses the OpenTelemetry LoggerProvider directly to export logs.

Warning

The deprecated opentelemetry-instrumentation-logging package is intentionally not used, as LoggerProvider already associates logs with the active trace/span context and provides native structured OTEL log exporting.

Local OTEL testing

To test the full OTEL configuration locally (logs, traces, and metrics exported through OpenTelemetry), use the provided OTEL environment configuration and run the application with Docker:

  1. Start the local otel collector

    make start-otel
    
  2. In a new shell start the application

    cp .env.otel .env
    make dockerrun
    

This configuration enables the OTLP exporters and sends telemetry to the local configured OpenTelemetry collector endpoint created via make start-otel.

Then you will see OTEL logs and metrics in the first shell in which you started make start-otel and you can see the full trace using jaeger trace explorer at http://localhost:16686