Skip to content

Commit

Permalink
Merge branch 'main' into unavail-test
Browse files Browse the repository at this point in the history
  • Loading branch information
emdneto authored Jul 15, 2024
2 parents acf919c + b79a965 commit 93bf0ee
Show file tree
Hide file tree
Showing 144 changed files with 745 additions and 359 deletions.
2 changes: 1 addition & 1 deletion .codespellrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[codespell]
# skipping auto generated folders
skip = ./.tox,./.mypy_cache,./docs/_build,./target,*/LICENSE,./venv,.git,./opentelemetry-semantic-conventions
skip = ./.tox,./.mypy_cache,./docs/_build,./target,*/LICENSE,./venv,.git,./opentelemetry-semantic-conventions,*-requirements*.txt
ignore-words-list = ans,ue,ot,hist,ro
27 changes: 5 additions & 22 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,25 @@ on:
jobs:
sdk-benchmarks:
env:
py312: "3.12"
RUN_MATRIX_COMBINATION: ${{ matrix.python-version }}-sdk-${{ matrix.os }}
runs-on: self-hosted
strategy:
# Ensures the entire test matrix is run, even if one permutation fails
fail-fast: false
matrix:
python-version: [py312]
os: [ubuntu-20.04, windows-2019]
steps:
- name: Checkout Core Repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4
- name: Set up Python ${{ env[matrix.python-version] }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env[matrix.python-version] }}
python-version: "3.12"
architecture: 'x64'
- name: Install tox
run: pip install tox
- name: Cache tox environment
# Preserves .tox directory between runs for faster installs
uses: actions/cache@v4
with:
path: |
.tox
~/.cache/pip
key: v3-tox-cache-${{ env.RUN_MATRIX_COMBINATION }}-${{ hashFiles('tox.ini',
'dev-requirements.txt') }}-core
- name: Run tox
run: tox -f ${{ matrix.python-version }}-sdk -- -k opentelemetry-sdk/tests/performance/benchmarks --benchmark-json=opentelemetry-sdk/tests/output.json
run: tox -e benchmark-opentelemetry-sdk -- -k opentelemetry-sdk/benchmarks --benchmark-json=opentelemetry-sdk/output.json
- name: Report on SDK benchmark results
uses: benchmark-action/github-action-benchmark@v1
with:
name: OpenTelemetry Python SDK Benchmarks - Python ${{ env[matrix.python-version ]}} - SDK
name: OpenTelemetry Python SDK Benchmarks
tool: pytest
output-file-path: opentelemetry-sdk/tests/output.json
output-file-path: opentelemetry-sdk/output.json
gh-pages-branch: gh-pages
github-token: ${{ secrets.GITHUB_TOKEN }}
# Make a commit on `gh-pages` with benchmarks from previous step
Expand Down
54 changes: 54 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Lint tests

on:
push:
branches-ignore:
- 'release/*'
pull_request:

jobs:
lint-3_12:
strategy:
fail-fast: false # ensures the entire test matrix is run, even if one permutation fails
matrix:
package:
- "opentelemetry-api"
- "opentelemetry-proto"
- "opentelemetry-sdk"
- "opentelemetry-semantic-conventions"
- "opentelemetry-getting-started"
- "opentelemetry-opentracing-shim"
- "opentelemetry-opencensus-shim"
- "opentelemetry-exporter-opencensus"
- "opentelemetry-exporter-otlp-proto-common"
- "opentelemetry-exporter-otlp-combined"
- "opentelemetry-exporter-otlp-proto-grpc"
- "opentelemetry-exporter-otlp-proto-http"
- "opentelemetry-exporter-otlp-proto-prometheus"
- "opentelemetry-exporter-otlp-proto-zipkin-combined"
- "opentelemetry-exporter-otlp-proto-zipkin-proto-http"
- "opentelemetry-exporter-otlp-proto-zipkin-json"
- "opentelemetry-propagator-b3"
- "opentelemetry-propagator-jaeger"
- "opentelemetry-test-utils"
os: [ubuntu-20.04]
runs-on: ubuntu-20.04
steps:
- name: Checkout Core Repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install tox
run: pip install tox
- name: Cache tox environment
# Preserves .tox directory between runs for faster installs
uses: actions/cache@v4
with:
path: |
.tox
~/.cache/pip
key: v7-build-tox-cache-${{ matrix.package }}-${{ hashFiles('tox.ini', 'gen-requirements.txt', 'dev-requirements.txt') }}
- name: run tox
run: tox -e lint-${{ matrix.package }}
14 changes: 6 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
- "exporter-zipkin-combined"
- "exporter-zipkin-proto-http"
- "exporter-zipkin-json"
- "protobuf"
- "proto"
- "propagator-b3"
- "propagator-jaeger"
os: [ubuntu-20.04, windows-2019]
Expand All @@ -69,6 +69,8 @@ jobs:
package: "exporter-otlp-combined"
- python-version: pypy3
package: "exporter-otlp-proto-grpc"
- python-version: pypy3
package: "getting-started"

steps:
- name: Checkout Core Repo @ SHA - ${{ github.sha }}
Expand All @@ -92,17 +94,13 @@ jobs:
- name: Windows does not let git check out files with long names
if: ${{ matrix.os == 'windows-2019'}}
run: git config --system core.longpaths true
- name: run pytest with --benchmark-skip
if: ${{ matrix.package == 'sdk' || matrix.package == 'exporter-otlp-proto-grpc' }}
run: tox -f ${{ matrix.python-version }}-${{ matrix.package }} -- -ra --benchmark-skip
- name: run pytest without --benchmark-skip
if: ${{ !(matrix.package == 'sdk' || matrix.package == 'exporter-otlp-proto-grpc') }}
- name: run tox
run: tox -f ${{ matrix.python-version }}-${{ matrix.package }} -- -ra
misc:
strategy:
fail-fast: false
matrix:
tox-environment: ["docker-tests-proto3", "docker-tests-proto4", "lint", "spellcheck",
tox-environment: ["docker-tests-proto3", "docker-tests-proto4", "spellcheck",
"docs", "mypy", "mypyinstalled", "tracecontext"]
name: ${{ matrix.tox-environment }}
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -217,4 +215,4 @@ jobs:
key: v3-tox-cache-${{ matrix.python-version }}-${{ matrix.package }}-${{ matrix.os
}}-${{ hashFiles('tox.ini', 'dev-requirements.txt') }}-contrib
- name: run tox
run: tox -f ${{ matrix.python-version }}-${{ matrix.package }} -- -ra --benchmark-skip
run: tox -f ${{ matrix.python-version }}-${{ matrix.package }} -- -ra
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,6 @@ docs/examples/django/db.sqlite3

# Semantic conventions
scripts/semconv/semantic-conventions

# Benchmark result files
*-benchmark.json
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

- OTLP exporter is encoding invalid span/trace IDs in the logs fix
([#4006](https://github.com/open-telemetry/opentelemetry-python/pull/4006))
- Update sdk process resource detector `process.command_args` attribute to also include the executable itself
([#4032](https://github.com/open-telemetry/opentelemetry-python/pull/4032))
- Fix `start_time_unix_nano` for delta collection for explicit bucket histogram aggregation
([#4009](https://github.com/open-telemetry/opentelemetry-python/pull/4009))
- Fix `start_time_unix_nano` for delta collection for sum aggregation
Expand Down Expand Up @@ -40,6 +44,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#3965](https://github.com/open-telemetry/opentelemetry-python/pull/3965))
- Validate links at span creation
([#3991](https://github.com/open-telemetry/opentelemetry-python/pull/3991))
- Add attributes field in `MeterProvider.get_meter` and `InstrumentationScope`
([#4015](https://github.com/open-telemetry/opentelemetry-python/pull/4015))

## Version 1.25.0/0.46b0 (2024-05-30)

Expand Down
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ You can run `tox` with the following arguments:
- `tox -e py312-opentelemetry-api` to e.g. run the API unit tests under a specific
Python version
- `tox -e spellcheck` to run a spellcheck on all the code
- `tox -e lint` to run lint checks on all code
- `tox -e lint-some-package` to run lint checks on `some-package`

`black` and `isort` are executed when `tox -e lint` is run. The reported errors can be tedious to fix manually.
An easier way to do so is:
Expand Down Expand Up @@ -126,7 +126,7 @@ The continuation integration overrides that environment variable with as per the

### Benchmarks

Running the `tox` tests also runs the performance tests if any are available. Benchmarking tests are done with `pytest-benchmark` and they output a table with results to the console.
Some packages have benchmark tests. To run them, run `tox -f benchmark`. Benchmark tests use `pytest-benchmark` and they output a table with results to the console.

To write benchmarks, simply use the [pytest benchmark fixture](https://pytest-benchmark.readthedocs.io/en/latest/usage.html#usage) like the following:

Expand All @@ -142,10 +142,10 @@ def test_simple_start_span(benchmark):
benchmark(benchmark_start_as_current_span, "benchmarkedSpan", 42)
```

Make sure the test file is under the `tests/performance/benchmarks/` folder of
Make sure the test file is under the `benchmarks/` folder of
the package it is benchmarking and further has a path that corresponds to the
file in the package it is testing. Make sure that the file name begins with
`test_benchmark_`. (e.g. `opentelemetry-sdk/tests/performance/benchmarks/trace/propagation/test_benchmark_b3_format.py`)
`test_benchmark_`. (e.g. `opentelemetry-sdk/benchmarks/trace/propagation/test_benchmark_b3_format.py`)

## Pull Requests

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ Meeting notes are available as a public [Google doc](https://docs.google.com/doc
Approvers ([@open-telemetry/python-approvers](https://github.com/orgs/open-telemetry/teams/python-approvers)):

- [Aaron Abbott](https://github.com/aabmass), Google
- [Emídio Neto](https://github.com/emdneto), Zenvia
- [Jeremy Voss](https://github.com/jeremydvoss), Microsoft
- [Owais Lone](https://github.com/owais), Splunk
- [Pablo Collins](https://github.com/pmcollins), Splunk
Expand Down
3 changes: 3 additions & 0 deletions docs/examples/metrics/instruments/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
opentelemetry-api~=1.25
opentelemetry-sdk~=1.25
opentelemetry-exporter-otlp~=1.25
8 changes: 4 additions & 4 deletions docs/examples/opencensus-shim/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ Start Jaeger
.. code-block:: sh
docker run --rm \
-p 6831:6831/udp \
-p 6832:6832/udp \
-p 4317:4317 \
-p 4318:4318 \
-p 16686:16686 \
jaegertracing/all-in-one:1.13 \
jaegertracing/all-in-one:latest \
--log-level=debug
Python Dependencies
Expand All @@ -43,7 +43,7 @@ Alternatively, you can install the Python dependencies separately:
pip install \
opentelemetry-api \
opentelemetry-sdk \
opentelemetry-exporter-jaeger \
opentelemetry-exporter-otlp \
opentelemetry-opencensus-shim \
opentelemetry-instrumentation-sqlite3 \
opencensus \
Expand Down
9 changes: 5 additions & 4 deletions docs/examples/opencensus-shim/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
from opencensus.ext.flask.flask_middleware import FlaskMiddleware

from opentelemetry import trace
from opentelemetry.exporter.jaeger.thrift import JaegerExporter
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import (
OTLPSpanExporter,
)
from opentelemetry.instrumentation.sqlite3 import SQLite3Instrumentor
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.trace import TracerProvider
Expand All @@ -40,9 +42,8 @@
# Configure OTel to export traces to Jaeger
tracer_provider.add_span_processor(
BatchSpanProcessor(
JaegerExporter(
agent_host_name="localhost",
agent_port=6831,
OTLPSpanExporter(
endpoint="localhost:4317",
)
)
)
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/opencensus-shim/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
opentelemetry-api
opentelemetry-sdk
opentelemetry-exporter-jaeger
opentelemetry-exporter-otlp
opentelemetry-opencensus-shim
opentelemetry-instrumentation-sqlite3
opencensus
Expand Down
8 changes: 4 additions & 4 deletions docs/examples/opentracing/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ Start Jaeger
.. code-block:: sh
docker run --rm \
-p 6831:6831/udp \
-p 6832:6832/udp \
-p 4317:4317 \
-p 4318:4318 \
-p 16686:16686 \
jaegertracing/all-in-one:1.13 \
jaegertracing/all-in-one:latest \
--log-level=debug
Redis
Expand Down Expand Up @@ -61,7 +61,7 @@ Alternatively, you can install the Python dependencies separately:
pip install \
opentelemetry-api \
opentelemetry-sdk \
opentelemetry-exporter-jaeger \
opentelemetry-exporter-otlp \
opentelemetry-opentracing-shim \
redis \
redis_opentracing
Expand Down
19 changes: 12 additions & 7 deletions docs/examples/opentracing/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
from rediscache import RedisCache

from opentelemetry import trace
from opentelemetry.exporter.jaeger.thrift import JaegerExporter
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import (
OTLPSpanExporter,
)
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry.shim import opentracing_shim
Expand All @@ -12,13 +14,16 @@
trace.set_tracer_provider(TracerProvider())
tracer_provider = trace.get_tracer_provider()

# Configure the tracer to export traces to Jaeger
jaeger_exporter = JaegerExporter(
agent_host_name="localhost",
agent_port=6831,
# Create an OTLP gRPC span exporter
otlp_exporter = OTLPSpanExporter(
endpoint="http://localhost:4317",
# For insecure connection, useful for testing
insecure=True,
)
# Add the exporter to the tracer provider
trace.get_tracer_provider().add_span_processor(
BatchSpanProcessor(otlp_exporter)
)
span_processor = BatchSpanProcessor(jaeger_exporter)
tracer_provider.add_span_processor(span_processor)

# Create an OpenTracing shim. This implements the OpenTracing tracer API, but
# forwards calls to the underlying OpenTelemetry tracer.
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/opentracing/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
opentelemetry-api
opentelemetry-sdk
opentelemetry-exporter-jaeger
opentelemetry-exporter-otlp
opentelemetry-opentracing-shim
redis
redis_opentracing
File renamed without changes.
2 changes: 1 addition & 1 deletion docs/getting_started/flask_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
@app.route("/")
def hello():
with tracer.start_as_current_span("example-request"):
requests.get("http://www.example.com")
requests.get("http://www.example.com", timeout=10)
return "hello"


Expand Down
7 changes: 5 additions & 2 deletions docs/getting_started/tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
asgiref==3.7.2
attrs==23.1.0
certifi==2023.7.22
certifi==2024.7.4
charset-normalizer==2.0.12
click==8.1.7
Deprecated==1.2.14
Expand All @@ -21,7 +21,10 @@ typing_extensions==4.8.0
urllib3==1.26.19
Werkzeug==3.0.3
wrapt==1.15.0
zipp==3.17.0
zipp==3.19.2
-e opentelemetry-semantic-conventions
-e opentelemetry-proto
-e exporter/opentelemetry-exporter-otlp-proto-common
-e exporter/opentelemetry-exporter-otlp-proto-grpc
-e opentelemetry-api
-e opentelemetry-sdk
6 changes: 4 additions & 2 deletions docs/getting_started/tests/test_flask.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@

import requests
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry
from requests.packages.urllib3.util.retry import ( # pylint: disable=import-error
Retry,
)


class TestFlask(unittest.TestCase):
def test_flask(self):
dirpath = os.path.dirname(os.path.realpath(__file__))
server_script = f"{dirpath}/../flask_example.py"
server = subprocess.Popen(
server = subprocess.Popen( # pylint: disable=consider-using-with
[sys.executable, server_script],
stdout=subprocess.PIPE,
)
Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pytest==7.4.4
tomli==2.0.1
typing_extensions==4.10.0
wrapt==1.16.0
zipp==3.17.0
zipp==3.19.2
-e opentelemetry-api
-e opentelemetry-sdk
-e tests/opentelemetry-test-utils
Expand Down
Empty file.
Loading

0 comments on commit 93bf0ee

Please sign in to comment.