Skip to content

Comments

Fix Resource constructor examples to use Resource.create()#4925

Merged
xrmx merged 3 commits intoopen-telemetry:mainfrom
rohansood10:fix/4554-fix-resource-examples
Feb 23, 2026
Merged

Fix Resource constructor examples to use Resource.create()#4925
xrmx merged 3 commits intoopen-telemetry:mainfrom
rohansood10:fix/4554-fix-resource-examples

Conversation

@rohansood10
Copy link
Contributor

Fixes #4554

Example code in the docs uses Resource(...) directly instead of the recommended Resource.create(...) factory method. Using the constructor directly skips merging with default resources (like telemetry SDK attributes), giving users incorrect guidance.

Changed Resource( to Resource.create( in:

  • docs/examples/opencensus-shim/app.py
  • docs/exporter/prometheus/prometheus.rst

@rohansood10 rohansood10 requested a review from a team as a code owner February 19, 2026 10:47
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Feb 19, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

Signed-off-by: Rohan Sood <rohansood10@users.noreply.github.com>
@rohansood10 rohansood10 force-pushed the fix/4554-fix-resource-examples branch from e4282fe to 04f41fe Compare February 19, 2026 10:48
Signed-off-by: Rohan Sood <rohansood10@users.noreply.github.com>
@xrmx xrmx added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Feb 19, 2026
@xrmx xrmx moved this to Easy to review / merge / close in @xrmx's Python PR digest Feb 19, 2026
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.

I think we at least two more entries:

exporter/opentelemetry-exporter-otlp-proto-grpc/src/opentelemetry/exporter/otlp/proto/grpc/__init__.py:    resource = Resource(attributes={
exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/__init__.py:    resource = Resource(attributes={

@xrmx xrmx moved this from Easy to review / merge / close to Reviewed PRs that need fixes in @xrmx's Python PR digest Feb 19, 2026
Address review feedback: also update Resource(attributes=...) to
Resource.create(...) in otlp-proto-grpc and otlp-proto-http exporter
module docstrings.
@rohansood10
Copy link
Contributor Author

Good catch! Updated both otlp-proto-grpc and otlp-proto-http exporter module docstrings to use Resource.create() as well.

@rohansood10
Copy link
Contributor Author

@xrmx Updated both OTLP gRPC and HTTP exporter docstrings as you suggested. Could you take another look when you get a chance? Thanks!

@xrmx xrmx merged commit f0451bd into open-telemetry:main Feb 23, 2026
549 of 551 checks passed
@github-project-automation github-project-automation bot moved this from Reviewed PRs that need fixes to Done in @xrmx's Python PR digest Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Skip Changelog PRs that do not require a CHANGELOG.md entry

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Fix Resource constructor examples

3 participants