Skip to content

make span attribute available to urllib #1014

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

Merged
merged 7 commits into from
Apr 12, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- `opentelemetry-instrumentation-urllib` make spam attribute available to urllib
Copy link
Member

@srikanthccv srikanthccv Mar 21, 2022

Choose a reason for hiding this comment

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

Suggested change
- `opentelemetry-instrumentation-urllib` make spam attribute available to urllib
- `opentelemetry-instrumentation-urllib` make span attributes available to sampler

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

([1014](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1014))
- `opentelemetry-instrumentation-psycopg2` extended the sql commenter support of dbapi into psycopg2
([#940](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/940))
- `opentelemetry-instrumentation-flask` Fix non-recording span bug
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,16 +182,18 @@ def _instrumented_open_call(
SpanAttributes.HTTP_METHOD: method,
SpanAttributes.HTTP_URL: url,
}

span_attributes = {
Copy link
Contributor

@lzchen lzchen Mar 21, 2022

Choose a reason for hiding this comment

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

There is already a dict with the exact same fields called labels right above. Maybe we can just use that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed it , I thought we needed a new dict for span attributes

SpanAttributes.HTTP_METHOD: method,
SpanAttributes.HTTP_URL: url,
}

with tracer.start_as_current_span(
span_name, kind=SpanKind.CLIENT
span_name, kind=SpanKind.CLIENT, attributes=span_attributes
) as span:
exception = None
if callable(request_hook):
request_hook(span, request)
if span.is_recording():
span.set_attribute(SpanAttributes.HTTP_METHOD, method)
span.set_attribute(SpanAttributes.HTTP_URL, url)

headers = get_or_create_headers()
inject(headers)
Expand Down