Skip to content

fix(sdk/trace): cache TracerMetrics on TracerProvider to prevent memory leak#5027

Closed
ravitheja4531-cell wants to merge 4 commits intoopen-telemetry:mainfrom
ravitheja4531-cell:fix-memory-leak
Closed

fix(sdk/trace): cache TracerMetrics on TracerProvider to prevent memory leak#5027
ravitheja4531-cell wants to merge 4 commits intoopen-telemetry:mainfrom
ravitheja4531-cell:fix-memory-leak

Conversation

@ravitheja4531-cell
Copy link
Copy Markdown

Description

Fixes #5016

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

All 230 existing SDK trace tests pass locally.

Does This PR Require a Contrib Repo Change?

  • No.

Checklist

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

Copy link
Copy Markdown
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.

Thanks for the PR. I feel that instead of complicating the tracer we should probably make get_meter cheap instead. Now that the tracer is cached also this should be an issue anymore.

@xrmx xrmx moved this to Reviewed PRs that need fixes in Python PR digest Apr 1, 2026
@ravitheja4531-cell ravitheja4531-cell requested a review from xrmx April 6, 2026 17:50
@ravitheja4531-cell
Copy link
Copy Markdown
Author

Hi @xrmx ,
Thank you for the review and your suggestion. I understand your point about simplifying the approach by making "get_meter" more efficient instead of adding additional complexity. I will revisit the implementation and update the PR accordingly.

Also, I noticed there are merge conflicts in the current branch — I will resolve them and push the updated changes soon.

Please let me know if you have any additional suggestions in the meantime.

@xrmx
Copy link
Copy Markdown
Contributor

xrmx commented Apr 10, 2026

@ravitheja4531-cell sdk's MeterProvider.get_meter is already using a cache so not sure there's much to do anymore. Also yesterday we've released a newer version with the cached tracer.

@xrmx
Copy link
Copy Markdown
Contributor

xrmx commented Apr 14, 2026

Closing this, the added complexity does not make sense after #5007

@xrmx xrmx closed this Apr 14, 2026
@github-project-automation github-project-automation bot moved this from Reviewed PRs that need fixes to Done in Python PR digest Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Repeated calls to get_tracer results in memory leak in 1.40.0

2 participants