Skip to content

Commit

Permalink
Merge branch 'master' into pr/martian711/287
Browse files Browse the repository at this point in the history
  • Loading branch information
trallnag committed Mar 12, 2024
2 parents af9910d + 4530ba4 commit b09ede9
Show file tree
Hide file tree
Showing 17 changed files with 766 additions and 670 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
exclude = .git,.lock
max-complexity = 12
max-line-length = 90
ignore=E501,W503
ignore=E501,W503,E231
12 changes: 6 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,30 @@ on:
- cron: 4 4 * * 1

env:
poetry_version: "1.3.2"
poetry_version: "1.8.2"

jobs:
ci:
name: CI
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.7"]
python-version: ["3.12", "3.8"]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

# ------------------------------------------------------------------------
# Python & Poetry.

- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Cache Poetry installation
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
~/.local/bin/poetry
Expand All @@ -51,7 +51,7 @@ jobs:
POETRY_VERSION: ${{ env.poetry_version }}

- name: Cache Poetry cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.cache/pypoetry
key: |-
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,27 @@ on:
- cron: 4 4 * * 1

env:
poetry_version: "1.3.2"
python_version: "3.11"
poetry_version: "1.8.2"
python_version: "3.12"

jobs:
pre-commit:
name: Pre-commit
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

# ------------------------------------------------------------------------
# Python & Poetry.

- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ env.python_version }}

- name: Cache Poetry installation
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
~/.local/bin/poetry
Expand All @@ -59,7 +59,7 @@ jobs:
POETRY_VERSION: ${{ env.poetry_version }}

- name: Cache Poetry cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.cache/pypoetry
key: |-
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,27 @@ permissions:
contents: write

env:
poetry_version: "1.3.2"
python_version: "3.11"
poetry_version: "1.8.2"
python_version: "3.12"

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

# ------------------------------------------------------------------------
# Python & Poetry.

- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ env.python_version }}

- name: Cache Poetry installation
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
~/.local/bin/poetry
Expand Down Expand Up @@ -76,6 +76,6 @@ jobs:
TOKEN: ${{ secrets.PYPI_TOKEN }}

- name: Draft GitHub release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
draft: true
10 changes: 5 additions & 5 deletions .github/workflows/testpypi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,27 @@ on:
default: ""

env:
poetry_version: "1.3.2"
python_version: "3.11"
poetry_version: "1.8.2"
python_version: "3.12"

jobs:
testpypi:
name: TestPyPI
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

# ------------------------------------------------------------------------
# Python & Poetry.

- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ env.python_version }}

- name: Cache Poetry installation
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
~/.local/bin/poetry
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-ast
- id: check-executables-have-shebangs
Expand All @@ -12,21 +12,21 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: v9.5.0
rev: v9.13.0
hooks:
- id: commitlint
stages: [commit-msg]
additional_dependencies: ["@commitlint/config-conventional"]

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0
rev: v4.0.0-alpha.8
hooks:
- id: prettier
types_or: [json, yaml, markdown]
args: [--prose-wrap=always]

- repo: https://github.com/DavidAnson/markdownlint-cli2
rev: v0.8.1
rev: v0.12.1
hooks:
- id: markdownlint-cli2

Expand Down
40 changes: 39 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,45 @@ and adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0).

## Unreleased

Nothing.
### Added

- Instrumentator now works without FastAPI. This is possible because every
FastAPI app is also a Starlette app (but not the other way around). Or to be
more specific: FastAPI uses Starlette for things like routing and middleware
this package relies on. The change is backwards compatible, even type checkers
like mypy should continue working. Thanks to
[@mvanderlee](https://github.com/mvanderlee) for proposing this in
[#280](https://github.com/trallnag/prometheus-fastapi-instrumentator/issues/280)
and implementing it in
[#288](https://github.com/trallnag/prometheus-fastapi-instrumentator/pull/288).

- **Middleware also records duration without streaming** in addition to the
already existing total latency (i.e. the time consumed for streaming is not
included in the duration value). The differentiation can be valuable as it
shows the time to first byte.

This mode is opt-in and can be enabled / used in several ways: The
`Instrumentator()` constructor, the `metrics.default()` closure, and the
`metrics.latency()` closure now come with the flag
`should_exclude_streaming_duration`. The attribute
`modified_duration_without_streaming` has been added to the `metrics.Info`
class. Instances of `metrics.Info` are passed to instrumentation functions,
where the added value can be used to set metrics.

Thanks to [@dosuken123](https://github.com/dosuken123) for proposing this in
[#291](https://github.com/trallnag/prometheus-fastapi-instrumentator/issues/291)
and implementing it in
[#290](https://github.com/trallnag/prometheus-fastapi-instrumentator/pull/290).

- Relaxed type of `get_route_name` argument to `HTTPConnection`. This allows
developers to use the `get_route_name` function for getting the name of
websocket routes as well. Thanks to [@pajowu](https://github.com/pajowu) for
proposing and implementing this feature in
[#276](https://github.com/trallnag/prometheus-fastapi-instrumentator/pull/276).

### Removed

- **BREAKING:** Dropped support for Python 3.7 which is has reached end-of-life.

## [6.1.0](https://github.com/trallnag/prometheus-fastapi-instrumentator/compare/v6.0.0...v6.1.0) / 2023-07-15

Expand Down
Loading

0 comments on commit b09ede9

Please sign in to comment.