Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalize usage of request correlation id to all integrations #101

Merged
merged 4 commits into from
Mar 4, 2024

Conversation

leplatrem
Copy link
Contributor

@leplatrem leplatrem commented Feb 29, 2024

  • Read X-Request-ID headers in all integrations
  • Make header name configurable
  • Adjust docs
  • Prepare release notes to announce usage of log filter

@leplatrem leplatrem force-pushed the generalize-request-id-middleware branch from d8a176d to 942753d Compare February 29, 2024 11:41
@leplatrem leplatrem force-pushed the generalize-request-id-middleware branch from 942753d to 64ccb50 Compare February 29, 2024 15:00
@leplatrem leplatrem marked this pull request as ready for review February 29, 2024 15:00
grahamalama
grahamalama previously approved these changes Mar 1, 2024
Comment on lines +169 to +171
rid = headers.get(header_name, "")
if not rid:
rid = str(uuid.uuid4())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason you didn't do

Suggested change
rid = headers.get(header_name, "")
if not rid:
rid = str(uuid.uuid4())
rid = headers.get(header_name, str(uuid.uuid4()))

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just in case the header is empty 🤷‍♂️ norhing else

tests/fastapi/test_fastapi.py Outdated Show resolved Hide resolved
@leplatrem leplatrem merged commit a953916 into main Mar 4, 2024
46 checks passed
@leplatrem leplatrem deleted the generalize-request-id-middleware branch March 4, 2024 10:43
github-merge-queue bot pushed a commit to mozilla/experimenter that referenced this pull request Mar 4, 2024
…er (#10355)

Bumps
[dockerflow](https://github.com/mozilla-services/python-dockerflow) from
2024.2.0 to 2024.3.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/mozilla-services/python-dockerflow/releases">dockerflow's
releases</a>.</em></p>
<blockquote>
<h2>2024.3.0</h2>
<h2>What's Changed</h2>
<p><strong>New features</strong></p>
<ul>
<li>Add optional querystring logging to MozLog
<code>&quot;request.summary&quot;</code> by <a
href="https://github.com/leplatrem"><code>@​leplatrem</code></a> in <a
href="https://redirect.github.com/mozilla-services/python-dockerflow/pull/97">mozilla-services/python-dockerflow#97</a></li>
<li>Configurable status for failed heartbeat by <a
href="https://github.com/leplatrem"><code>@​leplatrem</code></a> in <a
href="https://redirect.github.com/mozilla-services/python-dockerflow/pull/98">mozilla-services/python-dockerflow#98</a></li>
<li>Support of request correlation id <a
href="https://github.com/leplatrem"><code>@​leplatrem</code></a> in <a
href="https://redirect.github.com/mozilla-services/python-dockerflow/pull/100">mozilla-services/python-dockerflow#100</a>
and <a
href="https://redirect.github.com/mozilla-services/python-dockerflow/pull/101">mozilla-services/python-dockerflow#101</a></li>
<li>Fix docs about heartbeat status on warnings (200, not 5XX) by <a
href="https://github.com/leplatrem"><code>@​leplatrem</code></a> in <a
href="https://redirect.github.com/mozilla-services/python-dockerflow/pull/99">mozilla-services/python-dockerflow#99</a></li>
</ul>
<p><strong>Internal Changes</strong></p>
<ul>
<li>Use <code>ruff</code> instead of flake8 and black by <a
href="https://github.com/leplatrem"><code>@​leplatrem</code></a> in <a
href="https://redirect.github.com/mozilla-services/python-dockerflow/pull/96">mozilla-services/python-dockerflow#96</a></li>
<li>Github Action status for each tox combination by <a
href="https://github.com/leplatrem"><code>@​leplatrem</code></a> in <a
href="https://redirect.github.com/mozilla-services/python-dockerflow/pull/102">mozilla-services/python-dockerflow#102</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/mozilla-services/python-dockerflow/compare/2024.2.0...2024.3.0">https://github.com/mozilla-services/python-dockerflow/compare/2024.2.0...2024.3.0</a></p>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/mozilla-services/python-dockerflow/blob/main/docs/changelog.rst">dockerflow's
changelog</a>.</em></p>
<blockquote>
<p>2024.3.0</p>
<pre><code>
- Add request correlation ID support
([#101](mozilla-services/python-dockerflow#101)).
In order to add a ``rid`` field to all log messages, add the
``dockerflow.logging.RequestIdLogFilter`` filter to your logging
handlers.
See: :ref:`Django &lt;django-logging&gt;`, :ref:`FastAPI
&lt;fastapi-logging&gt;`, :ref:`Flask &lt;flask-logging&gt;`,
:ref:`Sanic &lt;sanic-logging&gt;` for details.
</code></pre>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/mozilla-services/python-dockerflow/commit/b98b4ffa664536f1f369d7e9df564b8bd7595687"><code>b98b4ff</code></a>
Update changelog 2024.3.0</li>
<li><a
href="https://github.com/mozilla-services/python-dockerflow/commit/a95391683043282e7278dbb0c79fe232ccf48d43"><code>a953916</code></a>
Generalize usage of request correlation id to all integrations (<a
href="https://redirect.github.com/mozilla-services/python-dockerflow/issues/101">#101</a>)</li>
<li><a
href="https://github.com/mozilla-services/python-dockerflow/commit/6a6c78a90bd4f992f0b7b59c4d6785a1ac39ba0c"><code>6a6c78a</code></a>
Github Action status for each tox combination (<a
href="https://redirect.github.com/mozilla-services/python-dockerflow/issues/102">#102</a>)</li>
<li><a
href="https://github.com/mozilla-services/python-dockerflow/commit/6b9e191942bc98994edc8ffa8bb03325bd7968f3"><code>6b9e191</code></a>
Use <code>ruff</code> instead of flake8 and black (<a
href="https://redirect.github.com/mozilla-services/python-dockerflow/issues/96">#96</a>)</li>
<li><a
href="https://github.com/mozilla-services/python-dockerflow/commit/4bad6254429d9145a904c69c6c06c8bccf918cf6"><code>4bad625</code></a>
(fastapi) Log request ID when set in headers (<a
href="https://redirect.github.com/mozilla-services/python-dockerflow/issues/100">#100</a>)</li>
<li><a
href="https://github.com/mozilla-services/python-dockerflow/commit/c93963707645fb7ebdf353a76f13f4b204796c94"><code>c939637</code></a>
Fix docs about heartbeat status on warnings (200, not 5XX) (<a
href="https://redirect.github.com/mozilla-services/python-dockerflow/issues/99">#99</a>)</li>
<li><a
href="https://github.com/mozilla-services/python-dockerflow/commit/e695de74acbb25ccf84e56ce7ca84fd7a6faeec8"><code>e695de7</code></a>
Configurable status for failed heartbeat (<a
href="https://redirect.github.com/mozilla-services/python-dockerflow/issues/98">#98</a>)</li>
<li><a
href="https://github.com/mozilla-services/python-dockerflow/commit/39ea4e4cf995bb4d0086a6b486a4e8e134efdb44"><code>39ea4e4</code></a>
Add querystring to MozLog <code>&quot;request.summary&quot;</code> (<a
href="https://redirect.github.com/mozilla-services/python-dockerflow/issues/97">#97</a>)</li>
<li>See full diff in <a
href="https://github.com/mozilla-services/python-dockerflow/compare/2024.2.0...2024.3.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=dockerflow&package-manager=pip&previous-version=2024.2.0&new-version=2024.3.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
Dependabot will merge this PR once CI passes on it, as requested by
@jaredlockhart.

[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants