From 72d946398fd5d1f34e108a942f13d8dc50f2fe09 Mon Sep 17 00:00:00 2001 From: Michelangelo Morrillo Date: Wed, 8 Jul 2020 16:57:08 +0200 Subject: [PATCH] CI and auto publish on hex (#1) --- .credo.exs | 137 ++++++++++++++++ .drone.yml | 285 ++++++++++++++++++++++++++++++++++ Dockerfile | 16 ++ deploy/deploy | 12 ++ deploy/wait_for_stack | 3 + entrypoint | 7 + lib/instrumentation.ex | 10 ++ mix.exs | 22 ++- mix.lock | 9 ++ test/instrumentation_test.exs | 6 +- test/test_helper.exs | 2 +- 11 files changed, 503 insertions(+), 6 deletions(-) create mode 100644 .credo.exs create mode 100644 .drone.yml create mode 100644 Dockerfile create mode 100755 deploy/deploy create mode 100755 deploy/wait_for_stack create mode 100755 entrypoint diff --git a/.credo.exs b/.credo.exs new file mode 100644 index 0000000..78319a4 --- /dev/null +++ b/.credo.exs @@ -0,0 +1,137 @@ +# This file contains the configuration for Credo and you are probably reading +# this after creating it with `mix credo.gen.config`. +# +# If you find anything wrong or unclear in this file, please report an +# issue on GitHub: https://github.com/rrrene/credo/issues +# +%{ + # + # You can have as many configs as you like in the `configs:` field. + configs: [ + %{ + # + # Run any config using `mix credo -C `. If no config name is given + # "default" is used. + name: "default", + # + # These are the files included in the analysis: + files: %{ + # + # You can give explicit globs or simply directories. + # In the latter case `**/*.{ex,exs}` will be used. + included: ["lib/", "test/"], + excluded: [~r"/_build/", ~r"/deps/"] + }, + # + # If you create your own checks, you must specify the source files for + # them here, so they can be loaded by Credo before running the analysis. + requires: [], + # + # Credo automatically checks for updates, like e.g. Hex does. + # You can disable this behaviour below: + check_for_updates: true, + # + # If you want to enforce a style guide and need a more traditional linting + # experience, you can change `strict` to `true` below: + strict: true, + # + # If you want to use uncolored output by default, you can change `color` + # to `false` below: + color: true, + # + # You can customize the parameters of any check by adding a second element + # to the tuple. + # + # To disable a check put `false` as second element: + # + # {Credo.Check.Design.DuplicatedCode, false} + # + checks: [ + {Credo.Check.Consistency.ExceptionNames}, + {Credo.Check.Consistency.LineEndings}, + {Credo.Check.Consistency.MultiAliasImportRequireUse, false}, + {Credo.Check.Consistency.ParameterPatternMatching}, + {Credo.Check.Consistency.SpaceAroundOperators}, + {Credo.Check.Consistency.SpaceInParentheses}, + {Credo.Check.Consistency.TabsOrSpaces}, + {Credo.Check.Refactor.MapInto, false}, + + # For some checks, like AliasUsage, you can only customize the priority + # Priority values are: `low, normal, high, higher` + {Credo.Check.Design.AliasUsage, priority: :low, if_nested_deeper_than: 10}, + + # For others you can set parameters + + # If you don't want the `setup` and `test` macro calls in ExUnit tests + # or the `schema` macro in Ecto schemas to trigger DuplicatedCode, just + # set the `excluded_macros` parameter to `[:schema, :setup, :test]`. + {Credo.Check.Design.DuplicatedCode, mass_threshold: 60}, + + # You can also customize the exit_status of each check. + # If you don't want TODO comments to cause `mix credo` to fail, just + # set this value to 0 (zero). + {Credo.Check.Design.TagTODO, exit_status: 0}, + {Credo.Check.Design.TagFIXME}, + {Credo.Check.Readability.AliasOrder, false}, + {Credo.Check.Readability.FunctionNames}, + {Credo.Check.Readability.LargeNumbers}, + {Credo.Check.Readability.MaxLineLength, false}, + {Credo.Check.Readability.ModuleAttributeNames}, + {Credo.Check.Readability.ModuleDoc}, + {Credo.Check.Readability.ModuleNames}, + # https://github.com/rrrene/credo/issues/308 + {Credo.Check.Readability.ParenthesesOnZeroArityDefs, false}, + {Credo.Check.Readability.ParenthesesInCondition}, + {Credo.Check.Readability.PredicateFunctionNames}, + {Credo.Check.Readability.PreferImplicitTry, false}, + {Credo.Check.Readability.RedundantBlankLines}, + {Credo.Check.Readability.SinglePipe}, + {Credo.Check.Readability.StringSigils}, + {Credo.Check.Readability.TrailingBlankLine}, + {Credo.Check.Readability.TrailingWhiteSpace}, + {Credo.Check.Readability.VariableNames}, + {Credo.Check.Readability.Semicolons}, + {Credo.Check.Readability.SpaceAfterCommas}, + {Credo.Check.Refactor.DoubleBooleanNegation}, + {Credo.Check.Refactor.CondStatements}, + {Credo.Check.Refactor.MatchInCondition}, + {Credo.Check.Refactor.PipeChainStart}, + {Credo.Check.Refactor.CyclomaticComplexity}, + {Credo.Check.Refactor.FunctionArity, max_arity: 7, ignore_defp: true}, + {Credo.Check.Refactor.LongQuoteBlocks}, + {Credo.Check.Refactor.MatchInCondition}, + {Credo.Check.Refactor.NegatedConditionsInUnless}, + {Credo.Check.Refactor.NegatedConditionsWithElse}, + {Credo.Check.Refactor.Nesting}, + {Credo.Check.Refactor.UnlessWithElse}, + {Credo.Check.Warning.BoolOperationOnSameValues}, + {Credo.Check.Warning.IExPry}, + {Credo.Check.Warning.IoInspect}, + {Credo.Check.Warning.OperationOnSameValues}, + {Credo.Check.Warning.OperationWithConstantResult}, + {Credo.Check.Warning.UnusedEnumOperation}, + {Credo.Check.Warning.UnusedFileOperation}, + {Credo.Check.Warning.UnusedKeywordOperation}, + {Credo.Check.Warning.UnusedListOperation}, + {Credo.Check.Warning.UnusedPathOperation}, + {Credo.Check.Warning.UnusedRegexOperation}, + {Credo.Check.Warning.UnusedStringOperation}, + {Credo.Check.Warning.UnusedTupleOperation}, + {Credo.Check.Warning.RaiseInsideRescue}, + + # Controversial and experimental checks (opt-in, just remove `, false`) + {Credo.Check.Warning.LazyLogging, false}, + {Credo.Check.Refactor.ABCSize, false}, + {Credo.Check.Refactor.AppendSingleItem, false}, + {Credo.Check.Refactor.VariableRebinding, false}, + {Credo.Check.Warning.MapGetUnsafePass, false}, + + # Deprecated checks (these will be deleted after a grace period) + {Credo.Check.Readability.Specs, false} + + # Custom checks can be created using `mix credo.gen.check`. + # + ] + } + ] +} diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..c707faf --- /dev/null +++ b/.drone.yml @@ -0,0 +1,285 @@ +--- +kind: pipeline +name: default + +platform: + os: linux + arch: amd64 + +clone: + depth: 1 + +steps: +- name: pre-start + image: prima/drone-tools:1.17.6 + commands: + - pre-start-scripts + +- name: cache-restore + image: prima/drone-tools:1.17.6 + commands: + - . /etc/profile.d/ecs-credentials-endpoint + - cache-restore + volumes: + - name: ecs + path: /etc/profile.d/ecs-credentials-endpoint + - name: docker + path: /var/run/docker.sock + +- name: check-secrets + image: prima/drone-tools:1.17.6 + commands: + - . /etc/profile.d/ecs-credentials-endpoint + - check-secrets-grants + volumes: + - name: ecs + path: /etc/profile.d/ecs-credentials-endpoint + +- name: build-image + image: prima/drone-tools:1.17.6 + commands: + - sed -i 's/USER app/USER root/g' ./Dockerfile + - docker build -t prima/opentelemetry_absinthe-ci:1 ./ + volumes: + - name: docker + path: /var/run/docker.sock + depends_on: + - cache-restore + +- name: elixir-dependencies + image: prima/opentelemetry_absinthe-ci:1 + commands: + - mix deps.get + depends_on: + - build-image + +- name: elixir-compile + image: prima/opentelemetry_absinthe-ci:1 + commands: + - mix compile --all-warnings --warnings-as-errors --ignore-module-conflict --debug-info + environment: + MIX_ENV: test + depends_on: + - elixir-dependencies + +- name: elixir-format + image: prima/opentelemetry_absinthe-ci:1 + commands: + - mix format --check-formatted mix.exs "lib/**/*.{ex,exs}" "test/**/*.{ex,exs}" "config/**/*.{ex,exs}" + environment: + MIX_ENV: test + depends_on: + - elixir-compile + +- name: elixir-test + image: prima/opentelemetry_absinthe-ci:1 + commands: + - mix test + environment: + MIX_ENV: test + depends_on: + - elixir-compile + +- name: elixir-credo + image: prima/opentelemetry_absinthe-ci:1 + commands: + - mix credo -a --strict + environment: + MIX_ENV: test + depends_on: + - elixir-compile + +- name: elixir-dialyzer + image: prima/opentelemetry_absinthe-ci:1 + commands: + - mix dialyzer + environment: + MIX_ENV: test + depends_on: + - elixir-compile + +- name: cache-save + image: prima/drone-tools:1.17.6 + commands: + - . /etc/profile.d/ecs-credentials-endpoint + - cache-save _build deps + volumes: + - name: ecs + path: /etc/profile.d/ecs-credentials-endpoint + - name: docker + path: /var/run/docker.sock + when: + branch: + - master + depends_on: + - elixir-compile + - elixir-format + - elixir-test + - elixir-credo + - elixir-dialyzer + +volumes: +- name: docker + host: + path: /var/run/docker.sock +- name: ecs + host: + path: /etc/profile.d/ecs-credentials-endpoint + +trigger: + event: + - push + +--- +kind: pipeline +name: deploy + +platform: + os: linux + arch: amd64 + +clone: + depth: 1 + +steps: +- name: pre-start + image: prima/drone-tools:1.17.6 + commands: + - pre-start-scripts + +- name: cache-restore + image: prima/drone-tools:1.17.6 + commands: + - . /etc/profile.d/ecs-credentials-endpoint + - cache-restore + volumes: + - name: ecs + path: /etc/profile.d/ecs-credentials-endpoint + - name: docker + path: /var/run/docker.sock + +- name: check-secrets + image: prima/drone-tools:1.17.6 + commands: + - . /etc/profile.d/ecs-credentials-endpoint + - check-secrets-grants + volumes: + - name: ecs + path: /etc/profile.d/ecs-credentials-endpoint + +- name: build-image + image: prima/drone-tools:1.17.6 + commands: + - sed -i 's/USER app/USER root/g' ./Dockerfile + - docker build -t prima/opentelemetry_absinthe-ci:1 ./ + volumes: + - name: docker + path: /var/run/docker.sock + depends_on: + - cache-restore + +- name: deploy-production + image: prima/opentelemetry_absinthe-ci:1 + commands: + - . /etc/profile.d/ecs-credentials-endpoint + - ./deploy/deploy production ${DRONE_TAG} + environment: + HEX_AUTH_KEY: + from_secret: hex_auth_key + MIX_ENV: dev + volumes: + - name: ecs + path: /etc/profile.d/ecs-credentials-endpoint + depends_on: + - check-secrets + - build-image + +- name: wait-for-stack-production + image: prima/drone-tools:1.17.6 + commands: + - . /etc/profile.d/ecs-credentials-endpoint + - ./deploy/wait_for_stack production ${DRONE_TAG} + volumes: + - name: ecs + path: /etc/profile.d/ecs-credentials-endpoint + depends_on: + - deploy-production + +volumes: +- name: docker + host: + path: /var/run/docker.sock +- name: ecs + host: + path: /etc/profile.d/ecs-credentials-endpoint + +trigger: + event: + - tag + +--- +kind: pipeline +name: email-failure + +platform: + os: linux + arch: amd64 + +clone: + disable: true + +steps: +- name: email-failure + image: drillster/drone-email + settings: + from: noreply@prima.it + host: email-smtp.eu-west-1.amazonaws.com + environment: + PLUGIN_PASSWORD: + from_secret: email_password + PLUGIN_USERNAME: + from_secret: email_username + +trigger: + event: + - push + status: + - failure + +depends_on: +- default + +--- +kind: pipeline +name: notify-captainhook-production + +platform: + os: linux + arch: amd64 + +clone: + disable: true + +steps: +- name: send + image: plugins/webhook + settings: + signature-secret: + from_secret: captainhook_secret + urls: http://captainhook-internal.prima.it/drone/deploy + +trigger: + event: + - tag + status: + - success + - failure + +depends_on: +- deploy + +--- +kind: signature +hmac: 0ccbbdf6b0cfca75d5d7baddbd546a1b6364131ebaee6df5cb692b93e54d95e2 + +... diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2e86af3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM prima/elixir-official:1.10.2-1 + +WORKDIR /code + +RUN groupadd -g 1000 app && \ + useradd -g 1000 -u 1000 --system --create-home app && \ + mix local.hex --force && \ + mix local.rebar --force && \ + cp -rp /root/.mix /home/app/ && \ + chown -R app:app /home/app/.mix + +USER app + +COPY ["entrypoint", "/entrypoint"] + +ENTRYPOINT ["/entrypoint"] diff --git a/deploy/deploy b/deploy/deploy new file mode 100755 index 0000000..99a88e1 --- /dev/null +++ b/deploy/deploy @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e + +# Authentication +mix hex.config api_key $HEX_AUTH_KEY + +# Verify +mix hex.user whoami + +# Publish +mix hex.publish --yes diff --git a/deploy/wait_for_stack b/deploy/wait_for_stack new file mode 100755 index 0000000..351d178 --- /dev/null +++ b/deploy/wait_for_stack @@ -0,0 +1,3 @@ +#!/bin/bash + +echo "Success!" diff --git a/entrypoint b/entrypoint new file mode 100755 index 0000000..507bc00 --- /dev/null +++ b/entrypoint @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +if [ "$1" == "mix" ]; then + exec "$@" +else [ -n "$1" ]; + sh -c "$@" +fi \ No newline at end of file diff --git a/lib/instrumentation.ex b/lib/instrumentation.ex index 9001301..c64293c 100644 --- a/lib/instrumentation.ex +++ b/lib/instrumentation.ex @@ -1,4 +1,14 @@ defmodule OpentelemetryAbsinthe.Instrumentation do + @moduledoc """ + Module for automatic instrumentation of Absinthe resolution. + + It works by listening to [:absinthe, :execute, :operation, :start/:stop] telemetry events, + which are emitted by Absinthe only since v1.5; therefore it won't work on previous versions. + + (you can still call `OpentelemetryAbsinthe.Instrumentation.setup()` in your application startup + code, it just won't do anything.) + """ + require OpenTelemetry.Tracer require OpenTelemetry.Span diff --git a/mix.exs b/mix.exs index eb2eb0f..91050b8 100644 --- a/mix.exs +++ b/mix.exs @@ -7,7 +7,9 @@ defmodule OpentelemetryAbsinthe.MixProject do version: "0.2.1", elixir: "~> 1.10", start_permanent: Mix.env() == :prod, - deps: deps() + deps: deps(), + package: package(), + description: description() ] end @@ -24,7 +26,23 @@ defmodule OpentelemetryAbsinthe.MixProject do {:opentelemetry_api, "~> 0.3.1"}, {:absinthe_plug, "~> 1.5", only: :test}, {:opentelemetry, "~> 0.4.0", only: :test}, - {:plug_cowboy, "~> 2.2", only: :test} + {:plug_cowboy, "~> 2.2", only: :test}, + {:credo, "~> 1.4", only: [:dev, :test]}, + {:dialyxir, "~> 1.0", only: [:dev, :test], runtime: false}, + {:ex_doc, ">= 0.0.0", only: :dev, runtime: false} ] end + + def package do + [ + name: "opentelemetry_absinthe", + maintainers: ["Leonardo Donelli"], + licenses: ["MIT"], + links: %{"Github" => "https://github.com/primait/opentelemetry_absinthe"} + ] + end + + def description do + "OpentelemetryAbsinthe is a OpenTelemetry instrumentation library for Absinthe." + end end diff --git a/mix.lock b/mix.lock index b6ae21f..b31a0a3 100644 --- a/mix.lock +++ b/mix.lock @@ -1,9 +1,18 @@ %{ "absinthe": {:hex, :absinthe, "1.5.1", "2f462f5849b2a4f72889d5a131ca6760b47ca8c5de2ba21c1dca3889634f2277", [:mix], [{:dataloader, "~> 1.0.0", [hex: :dataloader, repo: "hexpm", optional: true]}, {:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}, {:nimble_parsec, "~> 0.5", [hex: :nimble_parsec, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "b264eeb69605c6012f563e240edcca3d8abc5a725cab6f58ad82510a0283618b"}, "absinthe_plug": {:hex, :absinthe_plug, "1.5.0", "018ef544cf577339018d1f482404b4bed762e1b530c78be9de4bbb88a6f3a805", [:mix], [{:absinthe, "~> 1.5.0", [hex: :absinthe, repo: "hexpm", optional: false]}, {:plug, "~> 1.3.2 or ~> 1.4", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "4c160f4ce9a1233a4219a42de946e4e05d0e8733537cd5d8d20e7d4ef8d4b7c7"}, + "bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm", "7af5c7e09fe1d40f76c8e4f9dd2be7cebd83909f31fee7cd0e9eadc567da8353"}, "cowboy": {:hex, :cowboy, "2.8.0", "f3dc62e35797ecd9ac1b50db74611193c29815401e53bac9a5c0577bd7bc667d", [:rebar3], [{:cowlib, "~> 2.9.1", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "~> 1.7.1", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "4643e4fba74ac96d4d152c75803de6fad0b3fa5df354c71afdd6cbeeb15fac8a"}, "cowlib": {:hex, :cowlib, "2.9.1", "61a6c7c50cf07fdd24b2f45b89500bb93b6686579b069a89f88cb211e1125c78", [:rebar3], [], "hexpm", "e4175dc240a70d996156160891e1c62238ede1729e45740bdd38064dad476170"}, + "credo": {:hex, :credo, "1.4.0", "92339d4cbadd1e88b5ee43d427b639b68a11071b6f73854e33638e30a0ea11f5", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "1fd3b70dce216574ce3c18bdf510b57e7c4c85c2ec9cad4bff854abaf7e58658"}, + "dialyxir": {:hex, :dialyxir, "1.0.0", "6a1fa629f7881a9f5aaf3a78f094b2a51a0357c843871b8bc98824e7342d00a5", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "aeb06588145fac14ca08d8061a142d52753dbc2cf7f0d00fc1013f53f8654654"}, + "earmark": {:hex, :earmark, "1.4.9", "837e4c1c5302b3135e9955f2bbf52c6c52e950c383983942b68b03909356c0d9", [:mix], [{:earmark_parser, ">= 1.4.9", [hex: :earmark_parser, repo: "hexpm", optional: false]}], "hexpm", "0d72df7d13a3dc8422882bed5263fdec5a773f56f7baeb02379361cb9e5b0d8e"}, + "earmark_parser": {:hex, :earmark_parser, "1.4.9", "819bda2049e6ee1365424e4ced1ba65806eacf0d2867415f19f3f80047f8037b", [:mix], [], "hexpm", "8bf54fddabf2d7e137a0c22660e71b49d5a0a82d1fb05b5af62f2761cd6485c4"}, + "erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"}, + "ex_doc": {:hex, :ex_doc, "0.22.1", "9bb6d51508778193a4ea90fa16eac47f8b67934f33f8271d5e1edec2dc0eee4c", [:mix], [{:earmark, "~> 1.4.0", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "d957de1b75cb9f78d3ee17820733dc4460114d8b1e11f7ee4fd6546e69b1db60"}, "jason": {:hex, :jason, "1.2.1", "12b22825e22f468c02eb3e4b9985f3d0cb8dc40b9bd704730efa11abd2708c44", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "b659b8571deedf60f79c5a608e15414085fa141344e2716fbd6988a084b5f993"}, + "makeup": {:hex, :makeup, "1.0.3", "e339e2f766d12e7260e6672dd4047405963c5ec99661abdc432e6ec67d29ef95", [:mix], [{:nimble_parsec, "~> 0.5", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "2e9b4996d11832947731f7608fed7ad2f9443011b3b479ae288011265cdd3dad"}, + "makeup_elixir": {:hex, :makeup_elixir, "0.14.1", "4f0e96847c63c17841d42c08107405a005a2680eb9c7ccadfd757bd31dabccfb", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "f2438b1a80eaec9ede832b5c41cd4f373b38fd7aa33e3b22d9db79e640cbde11"}, "mime": {:hex, :mime, "1.3.1", "30ce04ab3175b6ad0bdce0035cba77bba68b813d523d1aac73d9781b4d193cf8", [:mix], [], "hexpm", "6cbe761d6a0ca5a31a0931bf4c63204bceb64538e664a8ecf784a9a6f3b875f1"}, "nimble_parsec": {:hex, :nimble_parsec, "0.6.0", "32111b3bf39137144abd7ba1cce0914533b2d16ef35e8abc5ec8be6122944263", [:mix], [], "hexpm", "27eac315a94909d4dc68bc07a4a83e06c8379237c5ea528a9acff4ca1c873c52"}, "opentelemetry": {:hex, :opentelemetry, "0.4.0", "293729f014009b03a1a2c47e6367db6f280b41412faa5639f06dcce9733d18a6", [:rebar3], [{:opentelemetry_api, "~> 0.3.1", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}], "hexpm", "f0eb4281f26879147322b0a6f1c457c57f3f1c4121cbff1f6056e4c98b1647a7"}, diff --git a/test/instrumentation_test.exs b/test/instrumentation_test.exs index dd47f91..3d9185c 100644 --- a/test/instrumentation_test.exs +++ b/test/instrumentation_test.exs @@ -30,7 +30,7 @@ defmodule OpentelemetryAbsintheTest.Instrumentation do describe "trace configuration" do test "by default all graphql stuff is recorded in attributes" do OpentelemetryAbsinthe.Instrumentation.setup() - {:ok, a} = Absinthe.run(@query, Schema, variables: %{"isbn" => "A1"}) + {:ok, _} = Absinthe.run(@query, Schema, variables: %{"isbn" => "A1"}) assert_receive {:span, span(attributes: attributes)}, 5000 assert [ @@ -48,7 +48,7 @@ defmodule OpentelemetryAbsintheTest.Instrumentation do ) OpentelemetryAbsinthe.Instrumentation.setup() - {:ok, a} = Absinthe.run(@query, Schema, variables: %{"isbn" => "A1"}) + {:ok, _} = Absinthe.run(@query, Schema, variables: %{"isbn" => "A1"}) assert_receive {:span, span(attributes: attributes)}, 5000 assert [ @@ -64,7 +64,7 @@ defmodule OpentelemetryAbsintheTest.Instrumentation do ) OpentelemetryAbsinthe.Instrumentation.setup(trace_request_query: true) - {:ok, a} = Absinthe.run(@query, Schema, variables: %{"isbn" => "A1"}) + {:ok, _} = Absinthe.run(@query, Schema, variables: %{"isbn" => "A1"}) assert_receive {:span, span(attributes: attributes)}, 5000 assert [ diff --git a/test/test_helper.exs b/test/test_helper.exs index 420f229..df77d82 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -30,7 +30,7 @@ defmodule AbsinthePlug.Test.Schema do field :book, :book do arg(:isbn, non_null(:string)) # middleware OpentelemetryAbsinthe.Middleware - resolve(fn _parent, args, resolution -> + resolve(fn _parent, args, _resolution -> {:ok, get_book_by_isbn(args.isbn)} end) end