Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP semantic convention stability migration for httplib #2648

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

zhihali
Copy link
Contributor

@zhihali zhihali commented Jun 30, 2024

Description

Part of this #2453

Fixes # (issue)

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?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

tox -e py312-test-util-http

Does This PR Require a Core Repo Change?

  • 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

@zhihali zhihali requested a review from a team June 30, 2024 14:15
@zhihali zhihali changed the title [wip]HTTP semantic convention stability migration for httplib HTTP semantic convention stability migration for httplib Jun 30, 2024
active_requests_count_attrs = {
key: req_attrs[key]
for key in _active_requests_count_attrs.intersection(req_attrs.keys())
def _parse_active_request_count_attrs(
Copy link
Contributor

Choose a reason for hiding this comment

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

opentelemetry-util-http is a utility package used only for http helper functions. We do not want to mix semantic convention logic in here. I suggest creating a method in the instrumentation file itself and calling the helper method within opentelemetry-instrumentation like we did in asgi.

@@ -104,8 +110,15 @@ def trysetip(conn: http.client.HTTPConnection, loglevel=logging.DEBUG) -> bool:
stack_info=True,
)
else:
_OpenTelemetrySemanticConventionStability._initialize()
Copy link
Contributor

Choose a reason for hiding this comment

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

We should call the initialize logic in the instrument() function.

for span in spanlist:
span.set_attribute(SpanAttributes.NET_PEER_IP, ip)
if _report_old(stability_mode):
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use the helper function here instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have tried to use this one, but in _set_http_peer_ip, it use this function

def set_string_attribute(result, key, value):
    if value:
        result[key] = value

but span do not support set attributes like this, so I write it like this

@lzchen
Copy link
Contributor

lzchen commented Jul 22, 2024

@zhihali

Hi are you still working on this?

@zhihali
Copy link
Contributor Author

zhihali commented Jul 22, 2024 via email

@zhihali
Copy link
Contributor Author

zhihali commented Jul 23, 2024

@zhihali

Hi are you still working on this?

Hey @lzchen, should I work on this? I have checked the original issue, found the httplib is deleted. Not sure if this one still on the priority?

@lzchen
Copy link
Contributor

lzchen commented Aug 21, 2024

@zhihali

I don't believe httplib was ever part of the required http migration libraries. We won't stop you from continuing this PR but it is not a necessity so feel free to close if you'd like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants