Skip to content

Commit

Permalink
Apply Alex comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Kludex committed Jul 19, 2024
1 parent 926b054 commit f492cfe
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 50 deletions.
47 changes: 3 additions & 44 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,47 +49,6 @@ jobs:
test:
name: test on ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
env:
PYTHON: ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v4
- name: Ensure requests to production domains fail
if: runner.os == 'Linux'
run: |
echo "203.0.113.0 logfire.dev" | sudo tee -a /etc/hosts
echo "203.0.113.0 logfire-api.pydantic.dev" | sudo tee -a /etc/hosts
echo "203.0.113.0 logfire.pydantic.dev" | sudo tee -a /etc/hosts
- name: set up python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: eifinger/[email protected]
- name: Pin python-version ${{ matrix.python-version }}
run: rye pin ${{ matrix.python-version }}
- run: rye config --set-bool behavior.use-uv=true
# Update all dependencies to the latest version possible
- run: rye sync --update-all
- run: |
pip install uv
uv pip install "logfire-api @ file://logfire-api"
- run: rye show
- run: mkdir coverage
- run: make test
env:
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}
- name: store coverage files
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.python-version }}
path: coverage

test-integration:
name: integration test on ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -121,18 +80,18 @@ jobs:
uv pip install "logfire-api @ file://logfire-api"
- run: rye show
- run: mkdir coverage
- run: make test-integration
- run: make test
env:
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}
- name: store coverage files
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.python-version }}-integration
name: coverage-${{ matrix.python-version }}
path: coverage

coverage:
runs-on: ubuntu-latest
needs: [test, test-integration]
needs: [test]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand Down
6 changes: 4 additions & 2 deletions docs/integrations/celery.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Celery

The [OpenTelemetry Instrumentation Celery][opentelemetry-celery] package can be used to instrument [Celery][celery].
The [`logfire.instrument_celery()`][logfire.Logfire.instrument_celery] method will create a span for every task
executed by your Celery workers.

## Installation

Expand Down Expand Up @@ -46,7 +47,8 @@ add.delay(42, 50)

1. Install `pyamqp` with `pip install pyamqp`.

You can read more about the Celery OpenTelemetry package [here][opentelemetry-celery].
The keyword arguments of [`logfire.instrument_celery()`][logfire.Logfire.instrument_celery] are passed to the
[`CeleryInstrumentor().instrument()`][opentelemetry.instrumentation.celery.CeleryInstrumentor] method.

[celery]: https://docs.celeryq.dev/en/stable/
[opentelemetry-celery]: https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/celery/celery.html
Expand Down
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,6 @@ exclude = [
venvPath = ".venv"

[tool.pytest.ini_options]
# By default, we don't run integration tests.
addopts = ["-m", "not integration"]
xfail_strict = true
markers = ['integration: mark a test as an integration test']
filterwarnings = [
Expand Down
5 changes: 3 additions & 2 deletions tests/otel_integrations/test_celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def celery_app() -> Celery:

@app.task(name='tasks.say_hello') # type: ignore
def say_hello(): # type: ignore
...
return 'hello'

return app

Expand All @@ -53,7 +53,8 @@ def test_instrument_celery(celery_app: Celery, exporter: TestExporter) -> None:

# Send and wait for the task to be executed
result = celery_app.send_task('tasks.say_hello') # type: ignore
result.get(timeout=10) # type: ignore
value = result.get(timeout=10) # type: ignore
assert value == 'hello'

# There are two spans:
# 1. Trigger the task with `send_task`.
Expand Down

0 comments on commit f492cfe

Please sign in to comment.