Skip to content

IHS-219: Add query_name parameter to all(), filters(), and get() for observability#965

Merged
solababs merged 6 commits intoinfrahub-developfrom
sb-23042026-add-query-name-to-funcs-for-observability-ihs-219
Apr 23, 2026
Merged

IHS-219: Add query_name parameter to all(), filters(), and get() for observability#965
solababs merged 6 commits intoinfrahub-developfrom
sb-23042026-add-query-name-to-funcs-for-observability-ihs-219

Conversation

@solababs
Copy link
Copy Markdown
Contributor

Why

When the SDK issues GraphQL queries internally, they are anonymous (query { ... }), making it impossible to correlate a slow backend trace span back to a specific call site. Developers debugging performance issues have no way to tell which all() or filters() call produced a given trace.

Goal: give every SDK-generated query a meaningful GraphQL operation name so trace spans are identifiable without custom instrumentation.

Closes #923

What changed

  • all(), filters(), get(), and count() on both InfrahubClient and InfrahubClientSync now accept an optional query_name: str | None = None parameter.
  • When query_name is supplied it becomes the GraphQL operation name (e.g. query GetAllEdgeDevices { ... }).
  • When omitted, a default name is auto-generated from the method and kind: All_CoreRepository, Filters_CoreRepository, Get_CoreRepository, Count_CoreRepository. This means all queries now have an operation name — previously they were anonymous.

How to test

uv run pytest tests/unit/sdk/test_client.py -k "query_name" -v

Impact & rollout

  • Backward compatibility: fully backward-compatible. query_name defaults to an auto-generated value, so existing call sites need no changes.
  • Performance: no measurable impact — the name is a short string prepended to the query.
  • Config/env changes: none.
  • Deployment notes: safe to deploy independently.

Checklist

  • Tests added/updated
  • Changelog entry added (uv run towncrier create ...)
  • External docs updated (if user-facing or ops-facing change)
  • Internal .md docs updated (internal knowledge and AI code tools knowledge)

@solababs solababs requested a review from a team as a code owner April 23, 2026 10:11
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

❌ Patch coverage is 92.59259% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
infrahub_sdk/client.py 92.59% 1 Missing and 1 partial ⚠️
@@                 Coverage Diff                  @@
##           infrahub-develop     #965      +/-   ##
====================================================
+ Coverage             81.11%   81.40%   +0.29%     
====================================================
  Files                   134      134              
  Lines                 11314    11347      +33     
  Branches               1693     1703      +10     
====================================================
+ Hits                   9177     9237      +60     
+ Misses                 1594     1567      -27     
  Partials                543      543              
Flag Coverage Δ
integration-tests 41.84% <55.55%> (+<0.01%) ⬆️
python-3.10 54.36% <70.37%> (+0.33%) ⬆️
python-3.11 54.34% <70.37%> (+0.31%) ⬆️
python-3.12 54.34% <70.37%> (+0.33%) ⬆️
python-3.13 54.34% <70.37%> (+0.31%) ⬆️
python-3.14 55.96% <77.77%> (+0.34%) ⬆️
python-filler-3.12 22.74% <14.81%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
infrahub_sdk/client.py 74.58% <92.59%> (+0.55%) ⬆️

... and 4 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Apr 23, 2026

Deploying infrahub-sdk-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: c2381d6
Status: ✅  Deploy successful!
Preview URL: https://8ae4178d.infrahub-sdk-python.pages.dev
Branch Preview URL: https://sb-23042026-add-query-name-t.infrahub-sdk-python.pages.dev

View logs

@github-actions github-actions Bot added the type/documentation Improvements or additions to documentation label Apr 23, 2026
Comment thread infrahub_sdk/client.py Outdated
parallel (bool, optional): Whether to use parallel processing for the query.
order (Order, optional): Ordering related options. Setting `disable=True` enhances performances.
include_metadata (bool, optional): If True, includes node_metadata and relationship_metadata in the query.
query_name (str, optional): If provided is used a the GraphQL operation name else All_<kind> is used.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is used a -> is used as

Comment thread infrahub_sdk/client.py Outdated
parallel (bool, optional): Whether to use parallel processing for the query.
order (Order, optional): Ordering related options. Setting `disable=True` enhances performances.
include_metadata (bool, optional): If True, includes node_metadata and relationship_metadata in the query.
query_name (str, optional): If provided is used a the GraphQL operation name else Filters_<kind> is used.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same

Comment thread infrahub_sdk/client.py Outdated
parallel (bool, optional): Whether to use parallel processing for the query.
order (Order, optional): Ordering related options. Setting `disable=True` enhances performances.
include_metadata (bool, optional): If True, includes node_metadata and relationship_metadata in the query.
query_name (str, optional): If provided is used a the GraphQL operation name else All_<kind> is used.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same

@solababs solababs merged commit c065b3f into infrahub-develop Apr 23, 2026
20 checks passed
@solababs solababs deleted the sb-23042026-add-query-name-to-funcs-for-observability-ihs-219 branch April 23, 2026 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants