Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,17 @@ updates:
directory: /
schedule:
interval: weekly
- package-ecosystem: pip
directories:
- /example/*
schedule:
interval: weekly
open-pull-requests-limit: 10
# uptrace and OpenTelemetry pins are bumped on release by scripts/sync_examples.py.
ignore:
- dependency-name: uptrace
- dependency-name: opentelemetry-*
groups:
examples:
patterns:
- '*'
74 changes: 74 additions & 0 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: examples

on:
push:
branches: [master]
pull_request:
branches: [master]
schedule:
# Weekly, to catch breakage from new releases of unpinned dependencies.
- cron: '0 6 * * 1'
workflow_dispatch:

permissions:
contents: read

jobs:
sync:
name: versions in sync
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: '3.12'
- run: python scripts/sync_examples.py --check

list:
name: list examples
runs-on: ubuntu-latest
outputs:
examples: ${{ steps.list.outputs.examples }}
steps:
- uses: actions/checkout@v7
- id: list
run: |
echo "examples=$(python3 scripts/run_example.py --list | python3 -c 'import json,sys; print(json.dumps(sys.stdin.read().split()))')" >> "$GITHUB_OUTPUT"

run:
name: ${{ matrix.example }}
needs: list
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
example: ${{ fromJSON(needs.list.outputs.examples) }}

services:
# Only django-postgresql uses it; starting it for every job is cheap.
postgres:
image: postgres:16
env:
POSTGRES_USER: uptrace
POSTGRES_PASSWORD: uptrace
POSTGRES_DB: uptrace
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 5s
--health-timeout 5s
--health-retries 10

steps:
- uses: actions/checkout@v7

- uses: actions/setup-python@v7
with:
python-version: '3.12'

- name: Install dependencies
run: python scripts/run_example.py --install ${{ matrix.example }}

- name: Run example
run: python scripts/run_example.py ${{ matrix.example }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ __pycache__
*.pyc
*.egg-info
db.sqlite3
.venv-examples/
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: all test
.PHONY: all test examples

install:
pip install -r dev-requirements.txt
Expand All @@ -14,3 +14,12 @@ publish: test
rm -rf build dist
python -m build
twine upload --skip-existing --verbose dist/*

# Smoke-test all examples, each in its own virtualenv under .venv-examples/.
examples:
python3 scripts/sync_examples.py --check
for ex in $$(python3 scripts/run_example.py --list); do \
python3 -m venv .venv-examples/$$ex \
&& .venv-examples/$$ex/bin/python scripts/run_example.py --install $$ex \
&& .venv-examples/$$ex/bin/python scripts/run_example.py $$ex || exit 1; \
done
13 changes: 12 additions & 1 deletion RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,18 @@ Also check `requires-python` against the upstream packages (e.g. OpenTelemetry 1
Python >= 3.10) and update the classifiers accordingly.

Update `requirements.txt` in each `example/` directory to use the new versions (`uptrace`,
`opentelemetry-sdk`, `opentelemetry-exporter-otlp`, and `opentelemetry-instrumentation-*`).
`opentelemetry-sdk`, `opentelemetry-exporter-otlp`, and `opentelemetry-instrumentation-*`):

```shell
python scripts/sync_examples.py
```

CI runs `python scripts/sync_examples.py --check` and smoke-tests every example (see
`.github/workflows/examples.yml`). To run one example locally:

```shell
python scripts/run_example.py --install flask && python scripts/run_example.py flask
```

Then reinstall dependencies and check that nothing is left on the old versions:

Expand Down
2 changes: 1 addition & 1 deletion example/django-postgresql/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
uptrace==1.45.0
django==5.2.17
psycopg2==2.9.5
psycopg2-binary==2.9.13
opentelemetry-instrumentation-logging==0.66b0
opentelemetry-instrumentation-django==0.66b0
opentelemetry-instrumentation-psycopg2==0.66b0
1 change: 1 addition & 0 deletions example/fastapi/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ requests
opentelemetry-instrumentation-fastapi==0.66b0
opentelemetry-instrumentation-requests==0.66b0
uptrace==1.45.0
opentelemetry-instrumentation-logging==0.66b0
2 changes: 1 addition & 1 deletion example/otlp-traces-http/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
exporter = OTLPSpanExporter(
endpoint="https://otlp.uptrace.dev/v1/traces",
# Set the Uptrace dsn here or use UPTRACE_DSN env var.
headers=(("uptrace-dsn", dsn),),
headers={"uptrace-dsn": dsn},
timeout=10,
compression=Compression.Gzip,
)
Expand Down
3 changes: 2 additions & 1 deletion example/pyramid/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
uptrace==1.45.0
pyramid==2.0.2
pyramid==2.1
opentelemetry-instrumentation-pyramid==0.66b0
opentelemetry-instrumentation-logging==0.66b0
Loading
Loading