open-telemetry / opentelemetry-python-contrib

OpenTelemetry instrumentation for Python modules
https://opentelemetry.io
Apache License 2.0
648 stars 535 forks source link

Implement migration plan for selected instrumentations #2453

Open lzchen opened 2 months ago

lzchen commented 2 months ago

A followup of https://github.com/open-telemetry/opentelemetry-python-contrib/issues/2351

Tracking issue to track progress of semantic convention stability migration for all instrumentations

Finished:

opentelemetry-instrumentation-requests https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2002 opentelemetry-instrumentation-wsgi https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2425 opentelemetry-instrumentation-flask https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2454 opentelemetry-instrumentation-asgi https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2610 opentelemetry-instrumentation-httpx https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2631

Remaining:

opentelemetry-instrumentation-aiohttp-client opentelemetry-instrumentation-django opentelemetry-instrumentation-fastapi opentelemetry-instrumentation-jinja2 opentelemetry-instrumentation-psycopg2 opentelemetry-instrumentation-sqlalchemy opentelemetry-instrumentation-urllib opentelemetry-instrumentation-urllib3

Charlie-lizhihan commented 1 week ago

Hey, @lzchen

I'm a beginner contributor, just fixed some bugs and would love to contribute more to the community. After discussing with @emdneto, we believe maybe I could try to contribute this one.

I would like to contribute to the opentelemetry-instrumentation-httplib. I read through the previous issues #2351 and #791, and read through your previous PRs: #2002, #2425, and #2454. They are really complex for me, so I think the steps to update httplib are like:

  1. __init__.py under util/opentelemetry-util-http/src/opentelemetry/util/http: Introduce Environment Variable: Add logic to check OTEL_SEMCONV_STABILITY_OPT_IN. Update Attributes: Replace old attributes with new semantic conventions. Conditional Logic: Implement conditional logic to emit old and new attributes based on the environment variable.

  2. Instrumentation File (httplib.py): Introduce Environment Variable: Similar to init.py. Update Span Attributes: Use new semantic conventions. Conditional Logic: Add logic to conditionally emit attributes.

  3. Test Files: Update Tests: Add tests to ensure both old and new conventions are correctly handled based on the environment variable.

I think my next step is to completely understand the httplib instrumentation, as I'm not really familiar with this one yet. May I ask if my steps are correct? Any other resources that could be helpful during my development?

Thank you!

lzchen commented 2 days ago

@Charlie-lizhihan

Thanks a lot of taking an interest in this! The steps you've outlined above sound like a great template! Another thing is to mark the package.py file to indicate the package has been migrated like here.