Skip to content

Commit

Permalink
Merge branch 'main' into issue_2053
Browse files Browse the repository at this point in the history
  • Loading branch information
ocelotl authored Jan 11, 2024
2 parents 8a6922a + 42faa1a commit 7e30340
Show file tree
Hide file tree
Showing 8 changed files with 165 additions and 92 deletions.
95 changes: 95 additions & 0 deletions .github/workflows/instrumentations_0.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Contrib Repo Tests

on:
push:
branches-ignore:
- 'release/*'
pull_request:
env:
CORE_REPO_SHA: 84c0e4f38d4fcdb8c13fd3988469fbb8cda28150

jobs:
instrumentations-0:
env:
# We use these variables to convert between tox and GHA version literals
py37: 3.7
py38: 3.8
py39: 3.9
py310: "3.10"
py311: "3.11"
pypy3: pypy-3.7
RUN_MATRIX_COMBINATION: ${{ matrix.python-version }}-${{ matrix.package }}-${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false # ensures the entire test matrix is run, even if one permutation fails
matrix:
python-version: [py37, py38, py39, py310, py311, pypy3]
package:
# Do not add more instrumentations here, add them in instrumentations_1.yml.
# The reason for this separation of instrumentations into more than one YAML file is
# the limit of jobs that can be run from a Github actions matrix:
# https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
# "A matrix will generate a maximum of 256 jobs per workflow run. This limit applies
# to both GitHub-hosted and self-hosted runners."
- "aiohttp-client"
- "aiohttp-server"
- "aiopg"
- "aio-pika"
- "asgi"
- "asyncpg"
- "aws-lambda"
- "boto"
- "boto3sqs"
- "botocore"
- "cassandra"
- "celery"
- "confluent-kafka"
- "dbapi"
- "django"
- "elasticsearch"
- "falcon"
- "fastapi"
- "flask"
- "grpc"
- "httpx"
- "jinja2"
- "kafka-python"
- "logging"
- "mysql"
- "mysqlclient"
- "pika"
- "psycopg2"
- "pymemcache"
- "pymongo"
- "pymysql"
- "pyramid"
- "redis"
- "remoulade"
- "requests"
- "sklearn"
- "sqlalchemy"
- "sqlite3"
- "starlette"
- "system-metrics"
- "tornado"
- "tortoiseorm"
os: [ubuntu-20.04]
steps:
- name: Checkout Contrib Repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v2
- name: Set up Python ${{ env[matrix.python-version] }}
uses: actions/setup-python@v4
with:
python-version: ${{ env[matrix.python-version] }}
- name: Install tox
run: pip install tox==3.27.1 tox-factor
- name: Cache tox environment
# Preserves .tox directory between runs for faster installs
uses: actions/cache@v1
with:
path: |
.tox
~/.cache/pip
key: v7-build-tox-cache-${{ env.RUN_MATRIX_COMBINATION }}-${{ hashFiles('tox.ini', 'gen-requirements.txt', 'dev-requirements.txt') }}
- name: run tox
run: tox -f ${{ matrix.python-version }}-${{ matrix.package }} -- -ra --benchmark-json=${{ env.RUN_MATRIX_COMBINATION }}-benchmark.json
57 changes: 57 additions & 0 deletions .github/workflows/instrumentations_1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Contrib Repo Tests

on:
push:
branches-ignore:
- 'release/*'
pull_request:
env:
CORE_REPO_SHA: 84c0e4f38d4fcdb8c13fd3988469fbb8cda28150

jobs:
instrumentations-1:
env:
# We use these variables to convert between tox and GHA version literals
py37: 3.7
py38: 3.8
py39: 3.9
py310: "3.10"
py311: "3.11"
pypy3: pypy-3.7
RUN_MATRIX_COMBINATION: ${{ matrix.python-version }}-${{ matrix.package }}-${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false # ensures the entire test matrix is run, even if one permutation fails
matrix:
python-version: [py37, py38, py39, py310, py311, pypy3]
package:
- "urllib"
- "urllib3"
- "wsgi"
- "distro"
- "richconsole"
- "prometheus-remote-write"
- "sdkextension-aws"
- "propagator-aws-xray"
- "propagator-ot-trace"
- "resource-detector-container"
os: [ubuntu-20.04]
steps:
- name: Checkout Contrib Repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v2
- name: Set up Python ${{ env[matrix.python-version] }}
uses: actions/setup-python@v4
with:
python-version: ${{ env[matrix.python-version] }}
- name: Install tox
run: pip install tox==3.27.1 tox-factor
- name: Cache tox environment
# Preserves .tox directory between runs for faster installs
uses: actions/cache@v1
with:
path: |
.tox
~/.cache/pip
key: v7-build-tox-cache-${{ env.RUN_MATRIX_COMBINATION }}-${{ hashFiles('tox.ini', 'gen-requirements.txt', 'dev-requirements.txt') }}
- name: run tox
run: tox -f ${{ matrix.python-version }}-${{ matrix.package }} -- -ra --benchmark-json=${{ env.RUN_MATRIX_COMBINATION }}-benchmark.json
83 changes: 0 additions & 83 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,89 +9,6 @@ env:
CORE_REPO_SHA: 84c0e4f38d4fcdb8c13fd3988469fbb8cda28150

jobs:
build:
env:
# We use these variables to convert between tox and GHA version literals
py37: 3.7
py38: 3.8
py39: 3.9
py310: "3.10"
py311: "3.11"
pypy3: "pypy3.7"
RUN_MATRIX_COMBINATION: ${{ matrix.python-version }}-${{ matrix.package }}-${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false # ensures the entire test matrix is run, even if one permutation fails
matrix:
python-version: [ py37, py38, py39, py310, py311, pypy3 ]
package: ["instrumentation", "distro", "exporter", "sdkextension", "propagator", "resource"]
os: [ ubuntu-20.04 ]
steps:
- name: Checkout Contrib Repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v2
- name: Set up Python ${{ env[matrix.python-version] }}
uses: actions/setup-python@v4
with:
python-version: ${{ env[matrix.python-version] }}
- name: Install tox
run: pip install tox==3.27.1 tox-factor
- name: Cache tox environment
# Preserves .tox directory between runs for faster installs
uses: actions/cache@v1
with:
path: |
.tox
~/.cache/pip
key: v7-build-tox-cache-${{ env.RUN_MATRIX_COMBINATION }}-${{ hashFiles('tox.ini', 'gen-requirements.txt', 'dev-requirements.txt') }}
- name: run tox
run: tox -f ${{ matrix.python-version }}-${{ matrix.package }} -- -ra --benchmark-json=${{ env.RUN_MATRIX_COMBINATION }}-benchmark.json
# - name: Find and merge ${{ matrix.package }} benchmarks
# # TODO: Add at least one benchmark to every package type to remove this (#249)
# if: matrix.package == 'sdkextension' || matrix.package == 'propagator'
# run: >-
# mkdir -p benchmarks;
# jq -s '.[0].benchmarks = ([.[].benchmarks] | add)
# | if .[0].benchmarks == null then null else .[0] end'
# **/**/tests/*${{ matrix.package }}*-benchmark.json > benchmarks/output_${{ matrix.package }}.json
# - name: Upload all benchmarks under same key as an artifact
# if: ${{ success() }}
# uses: actions/upload-artifact@v2
# with:
# name: benchmarks
# path: benchmarks/output_${{ matrix.package }}.json
# combine-benchmarks:
# runs-on: ubuntu-latest
# needs: build
# if: ${{ always() }}
# name: Combine benchmarks from previous build job
# steps:
# - name: Checkout Contrib Repo @ SHA - ${{ github.sha }}
# uses: actions/checkout@v2
# - name: Download all benchmarks as artifact using key
# uses: actions/download-artifact@v2
# with:
# name: benchmarks
# path: benchmarks
# - name: Find and merge all benchmarks
# run: >-
# jq -s '.[0].benchmarks = ([.[].benchmarks] | add)
# | if .[0].benchmarks == null then null else .[0] end'
# benchmarks/output_*.json > output.json;
# - name: Report on benchmark results
# uses: benchmark-action/github-action-benchmark@v1
# with:
# name: OpenTelemetry Python Benchmarks - Python ${{ env[matrix.python-version ]}} - ${{ matrix.package }}
# tool: pytest
# output-file-path: output.json
# github-token: ${{ secrets.GITHUB_TOKEN }}
# max-items-in-chart: 100
# # Alert with a commit comment on possible performance regression
# alert-threshold: 200%
# fail-on-alert: true
# # Make a commit on `gh-pages` with benchmarks from previous step
# auto-push: ${{ github.ref == 'refs/heads/main' }}
# gh-pages-branch: gh-pages
# benchmark-data-dir-path: benchmarks
misc:
strategy:
fail-fast: false
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

- `opentelemetry-resource-detector-azure` Added 10s timeout to VM Resource Detector
([#2119](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2119))

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

### Added
Expand Down
1 change: 1 addition & 0 deletions _template/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This library allows tracing requests made by the <REPLACE ME> library.
Installation
------------


::

pip install opentelemetry-instrumentation-<REPLACE ME>
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.0"
__version__ = "0.1.1"
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ 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).read() as response:
return loads(response)
with urlopen(request, timeout=10) as response:
return loads(response.read())
except URLError:
# Not on Azure VM
return None
Expand Down
12 changes: 6 additions & 6 deletions resource/opentelemetry-resource-detector-azure/tests/test_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,18 +363,18 @@
class TestAzureVMResourceDetector(unittest.TestCase):
@patch("opentelemetry.resource.detector.azure.vm.urlopen")
def test_linux(self, mock_urlopen):
mock_open = Mock()
mock_urlopen.return_value = mock_open
mock_open.read.return_value = LINUX_JSON
mock_response = Mock()
mock_urlopen.return_value = mock_response
mock_response.read.return_value = LINUX_JSON
attributes = AzureVMResourceDetector().detect().attributes
for attribute_key, attribute_value in LINUX_ATTRIBUTES.items():
self.assertEqual(attributes[attribute_key], attribute_value)

@patch("opentelemetry.resource.detector.azure.vm.urlopen")
def test_windows(self, mock_urlopen):
mock_open = Mock()
mock_urlopen.return_value = mock_open
mock_open.read.return_value = WINDOWS_JSON
mock_response = Mock()
mock_urlopen.return_value = mock_response
mock_response.read.return_value = WINDOWS_JSON
attributes = AzureVMResourceDetector().detect().attributes
for attribute_key, attribute_value in LINUX_ATTRIBUTES.items():
self.assertEqual(attributes[attribute_key], attribute_value)

0 comments on commit 7e30340

Please sign in to comment.