Skip to content

Commit

Permalink
Merge pull request #1 from open-telemetry/main
Browse files Browse the repository at this point in the history
bring in sync
  • Loading branch information
abhinav283 authored Jan 30, 2024
2 parents 42faa1a + a93bd74 commit efc69c8
Show file tree
Hide file tree
Showing 11 changed files with 127 additions and 111 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/instrumentations_0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
- "logging"
- "mysql"
- "mysqlclient"
- "pika"
- "sio-pika"
- "psycopg2"
- "pymemcache"
- "pymongo"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/instrumentations_1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
python-version: [py37, py38, py39, py310, py311, pypy3]
package:
- "urllib"
- "urllib3"
- "urllib3v"
- "wsgi"
- "distro"
- "richconsole"
Expand Down
4 changes: 4 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

- `opentelemetry-resource-detector-azure` Added 10s timeout to VM Resource Detector
([#2119](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2119))
- `opentelemetry-resource-detector-azure` Changed timeout to 4 seconds due to [timeout bug](https://github.com/open-telemetry/opentelemetry-python/issues/3644)
([#2136](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2136))

## Version 1.22.0/0.43b0 (2023-12-14)

Expand Down Expand Up @@ -72,6 +74,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- `opentelemetry-resource-detector-azure` Add resource detectors for Azure App Service and VM
([#1901](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1901))
- `opentelemetry-instrumentation-flask` Add support for Flask 3.0.0
([#152](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2013))

## Version 1.19.0/0.40b0 (2023-07-13)
- `opentelemetry-instrumentation-asgi` Add `http.server.request.size` metric
Expand Down
2 changes: 1 addition & 1 deletion instrumentation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
| [opentelemetry-instrumentation-elasticsearch](./opentelemetry-instrumentation-elasticsearch) | elasticsearch >= 2.0 | No
| [opentelemetry-instrumentation-falcon](./opentelemetry-instrumentation-falcon) | falcon >= 1.4.1, < 4.0.0 | Yes
| [opentelemetry-instrumentation-fastapi](./opentelemetry-instrumentation-fastapi) | fastapi ~= 0.58 | Yes
| [opentelemetry-instrumentation-flask](./opentelemetry-instrumentation-flask) | flask >= 1.0, < 3.0 | Yes
| [opentelemetry-instrumentation-flask](./opentelemetry-instrumentation-flask) | flask >= 1.0 | Yes
| [opentelemetry-instrumentation-grpc](./opentelemetry-instrumentation-grpc) | grpcio ~= 1.27 | No
| [opentelemetry-instrumentation-httpx](./opentelemetry-instrumentation-httpx) | httpx >= 0.18.0 | No
| [opentelemetry-instrumentation-jinja2](./opentelemetry-instrumentation-jinja2) | jinja2 >= 2.7, < 4.0 | No
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ dependencies = [

[project.optional-dependencies]
instruments = [
"flask >= 1.0, < 3.0",
"werkzeug < 3.0.0"
"werkzeug < 3.0.0",
"flask >= 1.0",
]
test = [
"opentelemetry-instrumentation-flask[instruments]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,16 @@ def response_hook(span: Span, status: str, response_headers: List):
from opentelemetry import context, trace
from opentelemetry.instrumentation.flask.package import _instruments
from opentelemetry.instrumentation.flask.version import __version__

try:
flask_version = flask.__version__
except AttributeError:
try:
from importlib import metadata
except ImportError:
import importlib_metadata as metadata
flask_version = metadata.version("flask")

from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
from opentelemetry.instrumentation.propagators import (
get_global_response_propagator,
Expand All @@ -271,7 +281,7 @@ def response_hook(span: Span, status: str, response_headers: List):

_excluded_urls_from_env = get_excluded_urls("FLASK")

if package_version.parse(flask.__version__) >= package_version.parse("2.2.0"):
if package_version.parse(flask_version) >= package_version.parse("2.2.0"):

def _request_ctx_ref() -> weakref.ReferenceType:
return weakref.ref(flask.globals.request_ctx._get_current_object())
Expand Down Expand Up @@ -420,7 +430,7 @@ def _before_request():
# https://flask.palletsprojects.com/en/1.1.x/api/#flask.has_request_context
if flask and flask.request:
if commenter_options.get("framework", True):
flask_info["framework"] = f"flask:{flask.__version__}"
flask_info["framework"] = f"flask:{flask_version}"
if (
commenter_options.get("controller", True)
and flask.request.endpoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
# limitations under the License.


_instruments = ("flask >= 1.0, < 3.0",)
_instruments = ("flask >= 1.0",)

_supports_metrics = True
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@
"instrumentation": "opentelemetry-instrumentation-fastapi==0.44b0.dev",
},
{
"library": "flask >= 1.0, < 3.0",
"library": "werkzeug < 3.0.0",
"instrumentation": "opentelemetry-instrumentation-flask==0.44b0.dev",
},
{
"library": "werkzeug < 3.0.0",
"library": "flask >= 1.0",
"instrumentation": "opentelemetry-instrumentation-flask==0.44b0.dev",
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = "0.1.1"
__version__ = "0.1.2"
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ def get_azure_vm_metadata(self): # pylint: disable=no-self-use
request = Request(_AZURE_VM_METADATA_ENDPOINT)
request.add_header("Metadata", "True")
try:
with urlopen(request, timeout=10) as response:
# TODO: Changed to 4s to fit into OTel SDK's 5 second timeout.
# Lengthen or allow user input if issue is resolved.
# See https://github.com/open-telemetry/opentelemetry-python/issues/3644
with urlopen(request, timeout=4) as response:
return loads(response.read())
except URLError:
# Not on Azure VM
Expand Down
Loading

0 comments on commit efc69c8

Please sign in to comment.