Skip to content

Conversation

@tammy-baylis-swi
Copy link
Contributor

@tammy-baylis-swi tammy-baylis-swi commented Dec 2, 2025

Description

Adds HTTP semantic convention stability migration / opt-in for opentelemetry-instrumentation-tornado

Removes reason, description, and Status because opt-in util _set_status doesn't accept them. Changes the signatures of several helpers not used by other instrumentors: _create_client_histograms, _create_server_histograms, _get_attributes_from_request.

Fixes #3991

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

  • Added unit test
  • Instrumentation with Tornado test app with opt-in as default, http, and http/dup

Default span attributes

-> http.method: Str(GET)
-> http.scheme: Str(http)
-> http.host: Str(localhost:8080)
-> http.target: Str(/latency/)
-> http.flavor: Str(HTTP/1.1)
-> http.client_ip: Str(127.0.0.1)
-> net.peer.ip: Str(127.0.0.1)
-> tornado.handler: Str(__main__.LatencyHandler)
-> http.status_code: Int(200)

http span attributes

-> http.request.method: Str(GET)
-> url.scheme: Str(http)
-> server.address: Str(localhost:8080)
-> network.protocol.version: Str(HTTP/1.1)
-> client.address: Str(127.0.0.1)
-> network.peer.address: Str(127.0.0.1)
-> tornado.handler: Str(__main__.LatencyHandler)
-> http.response.status_code: Int(200)

http/dup has both sets.

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • 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

@tammy-baylis-swi tammy-baylis-swi marked this pull request as ready for review December 2, 2025 22:26
@tammy-baylis-swi tammy-baylis-swi requested a review from a team as a code owner December 2, 2025 22:26
@JWinermaSplunk
Copy link

Looks good to me!

@xrmx xrmx moved this to Ready for review in @xrmx's Python PR digest Dec 5, 2025
tammy-baylis-swi and others added 2 commits December 22, 2025 10:52
…telemetry/instrumentation/tornado/__init__.py

Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
…telemetry/instrumentation/tornado/__init__.py

Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
Note that the patch does not apply on every single __init__ call, only the first one for the entire
process lifetime.
"""
global _sem_conv_opt_in_mode # pylint: disable=global-statement
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think we can make this an attribute of TornadoInstrumentor instead of being global?

if handler.request.path:
# Parse query from path if present
path = handler.request.path
if "?" in path:
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd use urllib.parse.urlparse instead of doing things manually

HTTP_TARGET: request.path,
}
# Add target (path) for active requests
if request.path:
Copy link
Contributor

Choose a reason for hiding this comment

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

Are there cases where this is falsy?

return
start_time = otel_handler_state.get(_START_TIME, None) or default_timer()
elapsed_time = round((default_timer() - start_time) * 1000)
elapsed_time_ms = round((default_timer() - start_time) * 1000)
Copy link
Contributor

Choose a reason for hiding this comment

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

If you calculate the elapsed_time_s first we can reuse that and then have the same value :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Ready for review

Development

Successfully merging this pull request may close these issues.

opentelemetry-instrumentation-tornado: HTTP semantic convention stability migration

3 participants