Skip to content

Conversation

StefanoOvus
Copy link

@StefanoOvus StefanoOvus commented Aug 5, 2025

Description

Added missing parameter capture_parameters for psycopg instrumentation:

PsycopgInstrumentor().instrument(capture_parameters=True)

populates the db.statement.parameters attribute in spans.

Fixes #3569

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Added tests for sync and async connection:

  • instrumentation/opentelemetry-instrumentation-psycopg/tests/test_psycopg_integration.py::TestPostgresqlIntegration::test_span_params_attribute
  • instrumentation/opentelemetry-instrumentation-psycopg/tests/test_psycopg_integration.py::TestPostgresqlIntegrationAsync::test_span_params_attribute

Tested in a small script with Python 3.13.3 + jaegertracing/jaeger:2.6.0 docker image (OTLP/gRPC protocol).

  • tox -e py313-test-instrumentation-psycopg
  • tox -e spellcheck
  • tox -e lint-instrumentation-psycopg

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

Copy link

linux-foundation-easycla bot commented Aug 5, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@xrmx xrmx moved this to Ready for review in @xrmx's Python PR digest Aug 22, 2025
Copy link
Contributor

@xrmx xrmx left a comment

Choose a reason for hiding this comment

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

LGTM, please add a CHANGELOG entry

@StefanoOvus StefanoOvus force-pushed the psycopg-instrumentation-capture-params branch from b30ad9c to 6eabb29 Compare August 25, 2025 15:22
@StefanoOvus StefanoOvus requested a review from a team as a code owner August 25, 2025 15:34
@StefanoOvus
Copy link
Author

@xrmx added changelog as requested.

@xrmx xrmx moved this from Ready for review to Easy to review / merge / close in @xrmx's Python PR digest Aug 28, 2025
@xrmx
Copy link
Contributor

xrmx commented Aug 29, 2025

@StefanoOvus please run tox -e ruff and commit the fixes

@StefanoOvus StefanoOvus force-pushed the psycopg-instrumentation-capture-params branch from 8f6bd0d to ec2d85b Compare September 22, 2025 09:54
@StefanoOvus
Copy link
Author

@StefanoOvus please run tox -e ruff and commit the fixes

@xrmx done

@tammy-baylis-swi
Copy link
Contributor

There is a typecheck failure but I don't think it's related to changes made in this PR:

typecheck: commands[0]> pyright
/home/runner/work/opentelemetry-python-contrib/opentelemetry-python-contrib/instrumentation-genai/opentelemetry-instrumentation-langchain/src/opentelemetry/instrumentation/langchain/span_manager.py
  /home/runner/work/opentelemetry-python-contrib/opentelemetry-python-contrib/instrumentation-genai/opentelemetry-instrumentation-langchain/src/opentelemetry/instrumentation/langchain/span_manager.py:34:5 - error: Type of "children" is partially unknown
    Type of "children" is "list[Unknown]" (reportUnknownVariableType)
1 error, 0 warnings, 0 informations

Copy link
Contributor

@tammy-baylis-swi tammy-baylis-swi left a comment

Choose a reason for hiding this comment

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

Lgtm!

@StefanoOvus StefanoOvus force-pushed the psycopg-instrumentation-capture-params branch from ec2d85b to b99746f Compare September 23, 2025 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Easy to review / merge / close
Development

Successfully merging this pull request may close these issues.

PsycopgInstrumentor capture_parameters
3 participants