From 0e6a776ffbe4d2df97755ff700ab4ec2332cf642 Mon Sep 17 00:00:00 2001 From: Bryan Naegele Date: Tue, 15 Nov 2022 16:22:28 -0700 Subject: [PATCH] Fix CI errors, update GHA deps, update versions (#125) * Fix CI errors, update GHA deps, update versions * output syntax * remove OTP 22 tests * set concurrency to cancel in progress * whitespace * incompatible vsns and failed test * Try pulling excludes out * Escaping * Just drop < 1.13 until this can move to workflows * quote --- .formatter.exs | 3 - .github/elixir-test-matrix.json | 25 +++++--- .github/erlang-test-matrix.json | 10 ++-- .github/workflows/elixir.yml | 60 ++++++++++--------- .github/workflows/erlang.yml | 29 +++++---- .../lib/opentelemetry_finch.ex | 7 ++- .../test/opentelemetry_finch_test.exs | 46 +++++++------- .../opentelemetry_tesla/.formatter.exs | 4 ++ .../opentelemetry_tesla_middleware_test.exs | 31 +++++----- 9 files changed, 121 insertions(+), 94 deletions(-) delete mode 100644 .formatter.exs create mode 100644 instrumentation/opentelemetry_tesla/.formatter.exs diff --git a/.formatter.exs b/.formatter.exs deleted file mode 100644 index 7eca31f..0000000 --- a/.formatter.exs +++ /dev/null @@ -1,3 +0,0 @@ -[ - inputs: ["{mix,.formatter}.exs", "{examples,instrumentation,propagators,test}/**/*.{ex,exs}"] -] diff --git a/.github/elixir-test-matrix.json b/.github/elixir-test-matrix.json index 9d701b2..43bcc7c 100644 --- a/.github/elixir-test-matrix.json +++ b/.github/elixir-test-matrix.json @@ -1,18 +1,29 @@ { "otp_version": [ - "24.2", - "23.3.4.10", - "22.3.4.24" + "25.1.2", + "24.3.4.6", + "23.3.4.18" ], "elixir_version": [ - "1.13.1", + "1.14.2", + "1.13.4", "1.12.3", "1.11.4" ], "rebar3_version": [ - "3.16.1" + "3.20" ], "os": [ - "ubuntu-18.04" + "ubuntu-20.04" + ], + "exclude": [ + { + "elixir_version": "1.11.4", + "erlang_version": "25.1.2" + }, + { + "elixir_version": "1.12.3", + "erlang_version": "25.1.2" + } ] -} +} \ No newline at end of file diff --git a/.github/erlang-test-matrix.json b/.github/erlang-test-matrix.json index 0425860..2e2953e 100644 --- a/.github/erlang-test-matrix.json +++ b/.github/erlang-test-matrix.json @@ -1,13 +1,13 @@ { "otp_version": [ - "24.2", - "23.3.4.10", - "22.3.4.24" + "25.1.2", + "24.3.4.6", + "23.3.4.10" ], "rebar3_version": [ - "3.16.1" + "3.20" ], "os": [ - "ubuntu-18.04" + "ubuntu-20.04" ] } diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml index 16b0bb4..be7feee 100644 --- a/.github/workflows/elixir.yml +++ b/.github/workflows/elixir.yml @@ -5,22 +5,28 @@ on: branches: - 'main' types: [opened, reopened, synchronize, labeled] + push: branches: - 'main' +concurrency: + group: ci-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + jobs: test-matrix: runs-on: ubuntu-latest outputs: matrix: ${{ steps.set-matrix.outputs.matrix }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Read file id: set-matrix run: | - matrixStringifiedObject="{\"otp_version\":[\"24.2\",\"23.3.4.10\",\"22.3.4.24\"],\"elixir_version\":[\"1.13.1\",\"1.12.3\",\"1.11.4\"],\"rebar3_version\":[\"3.16.1\"],\"os\":[\"ubuntu-18.04\"]}" - echo "::set-output name=matrix::$matrixStringifiedObject" + matrixStringifiedObject="{\"otp_version\":[\"25.1.2\",\"24.3.4.6\",\"23.3.4.18\"],\"elixir_version\":[\"1.14.2\",\"1.13.4\"],\"rebar3_version\":[\"3.20\"],\"os\":[\"ubuntu-20.04\"]}" + echo "matrix=$matrixStringifiedObject" >> $GITHUB_OUTPUT + echo "matrix_exclude=" opentelemetry-ecto: needs: [test-matrix] if: (contains(github.event.pull_request.labels.*.name, 'elixir') && contains(github.event.pull_request.labels.*.name, 'opentelemetry_ecto')) @@ -29,7 +35,7 @@ jobs: defaults: run: working-directory: instrumentation/${{ env.app }} - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 name: Opentelemetry Ecto test on Elixir ${{ matrix.elixir_version }} (OTP ${{ matrix.otp_version }}) strategy: fail-fast: false @@ -45,14 +51,14 @@ jobs: POSTGRES_DB: opentelemetry_ecto_test steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: erlef/setup-beam@v1 with: otp-version: ${{ matrix.otp_version }} elixir-version: ${{ matrix.elixir_version }} rebar3-version: ${{ matrix.rebar3_version }} - name: Cache - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: | ~/deps @@ -76,20 +82,20 @@ jobs: defaults: run: working-directory: instrumentation/${{ env.app }} - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 name: Opentelemetry Phoenix test on Elixir ${{ matrix.elixir_version }} (OTP ${{ matrix.otp_version }}) strategy: fail-fast: false matrix: ${{ fromJson(needs.test-matrix.outputs.matrix) }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: erlef/setup-beam@v1 with: otp-version: ${{ matrix.otp_version }} elixir-version: ${{ matrix.elixir_version }} rebar3-version: ${{ matrix.rebar3_version }} - name: Cache - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: | ~/deps @@ -113,7 +119,7 @@ jobs: defaults: run: working-directory: instrumentation/${{ env.app }} - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 name: Opentelemetry Redix test on Elixir ${{ matrix.elixir_version }} (OTP ${{ matrix.otp_version }}) strategy: fail-fast: false @@ -123,14 +129,14 @@ jobs: image: redis:alpine ports: ['6379:6379'] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: erlef/setup-beam@v1 with: otp-version: ${{ matrix.otp_version }} elixir-version: ${{ matrix.elixir_version }} rebar3-version: ${{ matrix.rebar3_version }} - name: Cache - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: | ~/deps @@ -154,20 +160,20 @@ jobs: defaults: run: working-directory: instrumentation/${{ env.app }} - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 name: Opentelemetry Finch test on Elixir ${{ matrix.elixir_version }} (OTP ${{ matrix.otp_version }}) strategy: fail-fast: false matrix: ${{ fromJson(needs.test-matrix.outputs.matrix) }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: erlef/setup-beam@v1 with: otp-version: ${{ matrix.otp_version }} elixir-version: ${{ matrix.elixir_version }} rebar3-version: ${{ matrix.rebar3_version }} - name: Cache - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: | ~/deps @@ -191,20 +197,20 @@ jobs: defaults: run: working-directory: utilities/${{ env.app }} - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 name: Opentelemetry Telemetry test on Elixir ${{ matrix.elixir_version }} (OTP ${{ matrix.otp_version }}) strategy: fail-fast: false matrix: ${{ fromJson(needs.test-matrix.outputs.matrix) }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: erlef/setup-beam@v1 with: otp-version: ${{ matrix.otp_version }} elixir-version: ${{ matrix.elixir_version }} rebar3-version: ${{ matrix.rebar3_version }} - name: Cache - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: | ~/deps @@ -228,7 +234,7 @@ jobs: defaults: run: working-directory: instrumentation/${{ env.app }} - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 name: Opentelemetry Oban test on Elixir ${{ matrix.elixir_version }} (OTP ${{ matrix.otp_version }}) strategy: fail-fast: false @@ -243,14 +249,14 @@ jobs: POSTGRES_PASSWORD: postgres POSTGRES_DB: opentelemetry_oban_test steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: erlef/setup-beam@v1 with: otp-version: ${{ matrix.otp_version }} elixir-version: ${{ matrix.elixir_version }} rebar3-version: ${{ matrix.rebar3_version }} - name: Cache - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: | ~/deps @@ -274,20 +280,20 @@ jobs: defaults: run: working-directory: propagators/${{ env.app }} - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 name: Opentelemetry Process Propagator test on Elixir ${{ matrix.elixir_version }} (OTP ${{ matrix.otp_version }}) strategy: fail-fast: false matrix: ${{ fromJson(needs.test-matrix.outputs.matrix) }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: erlef/setup-beam@v1 with: otp-version: ${{ matrix.otp_version }} elixir-version: ${{ matrix.elixir_version }} rebar3-version: ${{ matrix.rebar3_version }} - name: Cache - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: | ~/deps @@ -311,20 +317,20 @@ jobs: defaults: run: working-directory: instrumentation/${{ env.app }} - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 name: Opentelemetry Tesla test on Elixir ${{ matrix.elixir_version }} (OTP ${{ matrix.otp_version }}) strategy: fail-fast: false matrix: ${{ fromJson(needs.test-matrix.outputs.matrix) }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: erlef/setup-beam@v1 with: otp-version: ${{ matrix.otp_version }} elixir-version: ${{ matrix.elixir_version }} rebar3-version: ${{ matrix.rebar3_version }} - name: Cache - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: | ~/deps diff --git a/.github/workflows/erlang.yml b/.github/workflows/erlang.yml index 39eaf24..7567f2e 100644 --- a/.github/workflows/erlang.yml +++ b/.github/workflows/erlang.yml @@ -5,22 +5,27 @@ on: branches: - 'main' types: [opened, reopened, synchronize, labeled] + push: branches: - 'main' +concurrency: + group: ci-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + jobs: test-matrix: runs-on: ubuntu-latest outputs: matrix: ${{ steps.set-matrix.outputs.matrix }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Read file id: set-matrix run: | - matrixStringifiedObject="{\"otp_version\":[\"24.2\",\"23.3.4.10\",\"22.3.4.24\"],\"rebar3_version\":[\"3.16.1\"],\"os\":[\"ubuntu-18.04\"]}" - echo "::set-output name=matrix::$matrixStringifiedObject" + matrixStringifiedObject="{\"otp_version\":[\"25.1.2\",\"24.3.4.6\",\"23.3.4.10\"],\"rebar3_version\":[\"3.20\"],\"os\":[\"ubuntu-20.04\"]}" + echo "matrix=$matrixStringifiedObject" >> $GITHUB_OUTPUT opentelemetry-cowboy: needs: [test-matrix] if: (contains(github.event.pull_request.labels.*.name, 'erlang') && contains(github.event.pull_request.labels.*.name, 'opentelemetry_cowboy')) @@ -29,19 +34,19 @@ jobs: defaults: run: working-directory: instrumentation/${{ env.app }} - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 name: Opentelemetry Cowboy test on OTP ${{ matrix.otp_version }} with Rebar3 ${{ matrix.rebar3_version }} strategy: fail-fast: false matrix: ${{ fromJson(needs.test-matrix.outputs.matrix) }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: erlef/setup-beam@v1 with: otp-version: ${{ matrix.otp_version }} rebar3-version: ${{ matrix.rebar3_version }} - name: Cache - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: | ~/_build @@ -60,19 +65,19 @@ jobs: defaults: run: working-directory: utilities/${{ env.app }} - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 name: Opentelemetry Telemetry test on OTP ${{ matrix.otp_version }} with Rebar3 ${{ matrix.rebar3_version }} strategy: fail-fast: false matrix: ${{ fromJson(needs.test-matrix.outputs.matrix) }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: erlef/setup-beam@v1 with: otp-version: ${{ matrix.otp_version }} rebar3-version: ${{ matrix.rebar3_version }} - name: Cache - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: | ~/_build @@ -91,19 +96,19 @@ jobs: defaults: run: working-directory: utilities/${{ env.app }} - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 name: Opentelemetry AWS X-Ray test on OTP ${{ matrix.otp_version }} with Rebar3 ${{ matrix.rebar3_version }} strategy: fail-fast: false matrix: ${{ fromJson(needs.test-matrix.outputs.matrix) }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: erlef/setup-beam@v1 with: otp-version: ${{ matrix.otp_version }} rebar3-version: ${{ matrix.rebar3_version }} - name: Cache - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: | ~/_build diff --git a/instrumentation/opentelemetry_finch/lib/opentelemetry_finch.ex b/instrumentation/opentelemetry_finch/lib/opentelemetry_finch.ex index 80eb571..fee2297 100644 --- a/instrumentation/opentelemetry_finch/lib/opentelemetry_finch.ex +++ b/instrumentation/opentelemetry_finch/lib/opentelemetry_finch.ex @@ -54,7 +54,7 @@ defmodule OpentelemetryFinch do "net.peer.port": meta.request.port, "http.target": meta.request.path, "http.method": meta.request.method, - "http.status_code": status, + "http.status_code": status } s = @@ -65,7 +65,10 @@ defmodule OpentelemetryFinch do }) if meta.result |> elem(0) == :error do - OpenTelemetry.Span.set_status(s, OpenTelemetry.status(:error, format_error(meta.result |> elem(1)))) + OpenTelemetry.Span.set_status( + s, + OpenTelemetry.status(:error, format_error(meta.result |> elem(1))) + ) end OpenTelemetry.Span.end_span(s) diff --git a/instrumentation/opentelemetry_finch/test/opentelemetry_finch_test.exs b/instrumentation/opentelemetry_finch/test/opentelemetry_finch_test.exs index caf0361..98b44a6 100644 --- a/instrumentation/opentelemetry_finch/test/opentelemetry_finch_test.exs +++ b/instrumentation/opentelemetry_finch/test/opentelemetry_finch_test.exs @@ -36,19 +36,19 @@ defmodule OpentelemetryFinchTest do {:ok, _} = Finch.build(:get, endpoint_url(bypass.port)) |> Finch.request(HttpFinch) assert_receive {:span, - span( - name: "HTTP GET", - kind: :client, - attributes: attributes - )} + span( + name: "HTTP GET", + kind: :client, + attributes: attributes + )} assert %{ - "net.peer.name": "localhost", - "http.method": "GET", - "http.target": "/", - "http.scheme": :http, - "http.status_code": 200 - } = :otel_attributes.map(attributes) + "net.peer.name": "localhost", + "http.method": "GET", + "http.target": "/", + "http.scheme": :http, + "http.status_code": 200 + } = :otel_attributes.map(attributes) end test "records span on requests failed", %{bypass: _} do @@ -59,20 +59,20 @@ defmodule OpentelemetryFinchTest do {:error, _} = Finch.build(:get, endpoint_url(3333)) |> Finch.request(HttpFinch) assert_receive {:span, - span( - name: "HTTP GET", - kind: :client, - status: {:status, :error, "connection refused"}, - attributes: attributes - )} + span( + name: "HTTP GET", + kind: :client, + status: {:status, :error, "connection refused"}, + attributes: attributes + )} assert %{ - "net.peer.name": "localhost", - "http.method": "GET", - "http.target": "/", - "http.scheme": :http, - "http.status_code": 0 - } = :otel_attributes.map(attributes) + "net.peer.name": "localhost", + "http.method": "GET", + "http.target": "/", + "http.scheme": :http, + "http.status_code": 0 + } = :otel_attributes.map(attributes) end defp endpoint_url(port), do: "http://localhost:#{port}/" diff --git a/instrumentation/opentelemetry_tesla/.formatter.exs b/instrumentation/opentelemetry_tesla/.formatter.exs new file mode 100644 index 0000000..d2cda26 --- /dev/null +++ b/instrumentation/opentelemetry_tesla/.formatter.exs @@ -0,0 +1,4 @@ +# Used by "mix format" +[ + inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"] +] diff --git a/instrumentation/opentelemetry_tesla/test/middleware/opentelemetry_tesla_middleware_test.exs b/instrumentation/opentelemetry_tesla/test/middleware/opentelemetry_tesla_middleware_test.exs index c613ebb..097de5f 100644 --- a/instrumentation/opentelemetry_tesla/test/middleware/opentelemetry_tesla_middleware_test.exs +++ b/instrumentation/opentelemetry_tesla/test/middleware/opentelemetry_tesla_middleware_test.exs @@ -27,9 +27,9 @@ defmodule Tesla.Middleware.OpenTelemetryTest do describe "span name" do test "uses generic route name when opentelemetry middleware is configured before path params middleware", - %{ - bypass: bypass - } do + %{ + bypass: bypass + } do defmodule TestClient do def get(client) do params = [id: '3'] @@ -61,9 +61,9 @@ defmodule Tesla.Middleware.OpenTelemetryTest do end test "uses low-cardinality method name when path params middleware is not used", - %{ - bypass: bypass - } do + %{ + bypass: bypass + } do defmodule TestClient do def get(client) do Tesla.get(client, "/users/") @@ -92,9 +92,9 @@ defmodule Tesla.Middleware.OpenTelemetryTest do end test "uses custom span name when passed in middleware opts", - %{ - bypass: bypass - } do + %{ + bypass: bypass + } do defmodule TestClient do def get(client) do params = [id: '3'] @@ -126,9 +126,9 @@ defmodule Tesla.Middleware.OpenTelemetryTest do end test "uses custom span name function when passed in middleware opts", - %{ - bypass: bypass - } do + %{ + bypass: bypass + } do defmodule TestClient do def get(client) do params = [id: '3'] @@ -139,9 +139,10 @@ defmodule Tesla.Middleware.OpenTelemetryTest do def client(url) do middleware = [ {Tesla.Middleware.BaseUrl, url}, - {Tesla.Middleware.OpenTelemetry, span_name: fn env -> - "#{String.upcase(to_string(env.method))} potato" - end}, + {Tesla.Middleware.OpenTelemetry, + span_name: fn env -> + "#{String.upcase(to_string(env.method))} potato" + end}, Tesla.Middleware.PathParams ]