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

Implement new HTTP semantic convention opt-in for Falcon #2790

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

Conversation

FilipNikolovski
Copy link
Contributor

@FilipNikolovski FilipNikolovski commented Aug 9, 2024

Description

This change updates the falcon instrumentor to adhere to the new HTTP semantic conventions, according to the migration plan outlined here:

also fixes #1532

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Updated the tests to assert that the new span and duration attributes have been added.

@FilipNikolovski FilipNikolovski requested a review from a team August 9, 2024 15:22
Copy link
Member

@emdneto emdneto left a comment

Choose a reason for hiding this comment

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

A big thanks for working on this one. Just some comments

CHANGELOG.md Show resolved Hide resolved
@emdneto emdneto mentioned this pull request Aug 14, 2024
7 tasks
@FilipNikolovski FilipNikolovski requested a review from a team as a code owner December 2, 2024 14:37
@xrmx
Copy link
Contributor

xrmx commented Dec 3, 2024

@FilipNikolovski tox -e generate step is failing, adding _semconv_status = "migration" in package.py should be enough

@FilipNikolovski
Copy link
Contributor Author

@FilipNikolovski tox -e generate step is failing, adding _semconv_status = "migration" in package.py should be enough

Thanks for the feedback. I've updated the file, but that step is still failing 🤷. Not sure if I need to run tox -e generate locally or not?

@xrmx
Copy link
Contributor

xrmx commented Dec 3, 2024

@FilipNikolovski tox -e generate step is failing, adding _semconv_status = "migration" in package.py should be enough

Thanks for the feedback. I've updated the file, but that step is still failing 🤷. Not sure if I need to run tox -e generate locally or not?

You need to run it locally and commit the updated files so it will match on CI

duration_attrs[SpanAttributes.HTTP_STATUS_CODE] = (
span.attributes.get(SpanAttributes.HTTP_STATUS_CODE)
duration_s = default_timer() - start
if self.duration_histogram_old:
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I think you can use add_response_attributes instead to populate duration attributes with status.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if we'll be able to use this one, since it returns early if span is not recording.

Copy link
Contributor

Choose a reason for hiding this comment

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

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've made the necessary updates.

@FilipNikolovski
Copy link
Contributor Author

@xrmx running tox -e generate throws an error for me:

Could not get hatch version from path /opentelemetry-python-contrib/instrumentation/opentelemetry-instrumentation-sklearn
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /opentelemetry-python-contrib/.tox/generate/lib/python3.12/site-pack │
│ ages/hatch/cli/__init__.py:221 in main                                                           │
│                                                                                                  │
│   218                                                                                            │
│   219 def main():  # no cov                                                                      │
│   220 │   try:                                                                                   │
    main()
  File "/opentelemetry-python-contrib/scripts/generate_instrumentation_bootstrap.py", line 70, in main
    for pkg in get_instrumentation_packages():
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opentelemetry-python-contrib/scripts/otel_packaging.py", line 51, in get_instrumentation_packages
    raise exc
  File "/opentelemetry-python-contrib/scripts/otel_packaging.py", line 42, in get_instrumentation_packages
    version = subprocess.check_output(
              ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.pyenv/versions/3.12.7/lib/python3.12/subprocess.py", line 466, in check_output
│ ❱ 221 │   │   hatch(prog_name='hatch', windows_expand_args=False)                                │
│   222 │   except Exception:  # noqa: BLE001                                                      │
│   223 │   │   import sys                                                                         │
│   224                                                                                            │
│                                                                                                  │
│ /opentelemetry-python-contrib/.tox/generate/lib/python3.12/site-pack │
│ ages/click/core.py:1157 in __call__                                                              │
│                                                                                                  │
│ /opentelemetry-python-contrib/.tox/generate/lib/python3.12/site-pack │
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.pyenv/versions/3.12.7/lib/python3.12/subprocess.py", line 571, in run
│ ages/click/core.py:1078 in main                                                                  │
│                                                                                                  │
│ /opentelemetry-python-contrib/.tox/generate/lib/python3.12/site-pack │
│ ages/click/core.py:1688 in invoke                                                                │
│                                                                                                  │
│ /opentelemetry-python-contrib/.tox/generate/lib/python3.12/site-pack │
│ ages/click/core.py:1434 in invoke                                                                │
│                                                                                                  │
│ /opentelemetry-python-contrib/.tox/generate/lib/python3.12/site-pack │
│ ages/click/core.py:783 in invoke                                                                 │
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command 'hatch version' returned non-zero exit status 1.
│                                                                                                  │
│ /opentelemetry-python-contrib/.tox/generate/lib/python3.12/site-pack │
│ ages/click/decorators.py:45 in new_func                                                          │
│                                                                                                  │
│ /opentelemetry-python-contrib/.tox/generate/lib/python3.12/site-pack │
│ ages/hatch/cli/version/__init__.py:35 in version                                                 │
│                                                                                                  │
│   32 │   │   if not (                                                                            │
│   33 │   │   │   'version' in app.project.metadata.dynamic or app.project.metadata.hatch.meta    │
│   34 │   │   ) or dependencies_in_sync(app.project.metadata.build.requires_complex):             │
│ ❱ 35 │   │   │   source = app.project.metadata.hatch.version.source                              │
│   36 │   │   │                                                                                   │
│   37 │   │   │   version_data = source.get_version_data()                                        │
│   38 │   │   │   original_version = version_data['version']                                      │
│                                                                                                  │
│ /opentelemetry-python-contrib/.tox/generate/lib/python3.12/site-pack │
│ ages/hatchling/metadata/core.py:1425 in version                                                  │
│                                                                                                  │
│   1422 │   │   if self._version is None:                                                         │
│   1423 │   │   │   if 'version' not in self.config:                                              │
│   1424 │   │   │   │   message = 'Missing `tool.hatch.version` configuration'                    │
│ ❱ 1425 │   │   │   │   raise ValueError(message)                                                 │
│   1426 │   │   │                                                                                 │
│   1427 │   │   │   options = self.config['version']                                              │
│   1428 │   │   │   if not isinstance(options, dict):                                             │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
ValueError: Missing `tool.hatch.version` configuration

@emdneto
Copy link
Member

emdneto commented Dec 10, 2024

@xrmx running tox -e generate throws an error for me:

That's weird, because /opentelemetry-python-contrib/instrumentation/opentelemetry-instrumentation-sklearn is deprecated for a while

@FilipNikolovski
Copy link
Contributor Author

@xrmx running tox -e generate throws an error for me:

That's weird, because /opentelemetry-python-contrib/instrumentation/opentelemetry-instrumentation-sklearn is deprecated for a while

Turns out I still had the sklearn directory 🤦, the command ran successfully after I deleted it.

CHANGELOG.md Outdated
@@ -51,6 +51,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#2942](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2942))
- `opentelemetry-instrumentation-click`: new instrumentation to trace click commands
([#2994](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2994))
- `opentelemetry-instrumentation-falcon` Implement new HTTP semantic convention opt-in for Falcon
Copy link
Contributor

@xrmx xrmx Dec 31, 2024

Choose a reason for hiding this comment

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

You have to move this to the unreleased section above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah thanks, i've made the update.

@FilipNikolovski FilipNikolovski requested a review from xrmx January 2, 2025 08:35
@emdneto emdneto self-requested a review January 2, 2025 16:00
self.client().simulate_get("/hello/756")
duration = max(round((default_timer() - start) * 1000), 0)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe I missed something in the discussion, but why are you removing the duration itself check?

Copy link
Contributor Author

@FilipNikolovski FilipNikolovski Jan 2, 2025

Choose a reason for hiding this comment

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

Good catch, that probably got lost in the refactor of the tests, I can re-add that check.

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've re-added the checks.

SpanAttributes.HTTP_ROUTE: "/hello",
}
expected_attributes_new = {
SpanAttributes.HTTP_REQUEST_METHOD: method,
Copy link
Member

Choose a reason for hiding this comment

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

In other instrumentations we are using the symbols from opentelemetry.semconv.attributes.http_attributes

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'll make the change.

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.

Falcon exceptions should not always be masked as 500 and marked as error
4 participants