From 2a9987c8f898226a4642bb243d65d73fe6113206 Mon Sep 17 00:00:00 2001 From: Matteo Busi Date: Thu, 30 Sep 2021 09:11:45 +0200 Subject: [PATCH] Remove service_name tag (#7) --- .drone.yml | 84 ++---------------------------------------- README.md | 5 --- lib/teleplug.ex | 15 ++------ mix.exs | 13 +++++-- mix.lock | 4 +- test/teleplug_test.exs | 3 +- 6 files changed, 18 insertions(+), 106 deletions(-) diff --git a/.drone.yml b/.drone.yml index 25717aa..bfdfcb6 100644 --- a/.drone.yml +++ b/.drone.yml @@ -163,86 +163,6 @@ volumes: trigger: event: - push - ---- -kind: pipeline -name: build-production - -platform: - os: linux - arch: amd64 - -clone: - disable: true - -steps: -- name: git-clone - image: public.ecr.aws/prima/drone-git:1.3-3 - environment: - PLUGIN_DEPTH: 5 - -- name: cache-restore - image: public.ecr.aws/prima/drone-tools:1.20.1 - commands: - - . /etc/profile.d/ecs-credentials-endpoint - - cache-restore - environment: - BUCKET_NAME: prima-ci-cache - volumes: - - name: ecs - path: /etc/profile.d/ecs-credentials-endpoint - - name: docker - path: /var/run/docker.sock - - name: docker-conf - path: /root/.docker - depends_on: - - git-clone - -- name: build-image - image: public.ecr.aws/prima/drone-tools:1.20.1 - commands: - - sed -i 's/USER app/USER root/g' ./Dockerfile - - docker build -t prima/teleplug-ci:${DRONE_COMMIT} ./ - volumes: - - name: docker - path: /var/run/docker.sock - - name: docker-conf - path: /root/.docker - depends_on: - - cache-restore - -- name: build-production - image: prima/teleplug-ci:${DRONE_COMMIT} - commands: - - . /etc/profile.d/ecs-credentials-endpoint - - ./deploy/build production - environment: - HEX_AUTH_KEY: - from_secret: hex_auth_key - MIX_ENV: dev - volumes: - - name: ecs - path: /etc/profile.d/ecs-credentials-endpoint - depends_on: - - build-image - -volumes: -- name: docker - host: - path: /var/run/docker.sock -- name: ecs - host: - path: /etc/profile.d/ecs-credentials-endpoint -- name: docker-conf - host: - path: /home/ec2-user/.docker - -trigger: - event: - - tag - ref: - - refs/tags/*.*.* - --- kind: pipeline name: email-failure @@ -276,6 +196,8 @@ trigger: depends_on: - default -- build-production +--- +kind: signature +hmac: 88f93324a280a88872d5f15cc630ca631b3398cb6a014d657c6c29f9be6a917e ... diff --git a/README.md b/README.md index 8d84cc1..c676f0f 100644 --- a/README.md +++ b/README.md @@ -27,8 +27,3 @@ In your pipeline add ``` plug TelePlug ``` - -or -``` -plug TelePlug, service_name: "my_name" -``` diff --git a/lib/teleplug.ex b/lib/teleplug.ex index 379386d..6325318 100644 --- a/lib/teleplug.ex +++ b/lib/teleplug.ex @@ -1,10 +1,6 @@ defmodule Teleplug do @moduledoc """ Simple opentelementry instrumented plug. - - ## Options - - The only option that can be passed is the `service_name`, defaults on the application name """ alias Plug.Conn @@ -25,17 +21,16 @@ defmodule Teleplug do def init(opts), do: opts @impl true - def call(conn, opts) do + def call(conn, _opts) do :otel_propagator.text_map_extract(conn.req_headers) attributes = - [{"service.name", service_name(opts)}] ++ - http_common_attributes(conn) ++ + http_common_attributes(conn) ++ http_server_attributes(conn) ++ network_attributes(conn) parent_ctx = Tracer.current_span_ctx() - + new_ctx = Tracer.start_span( conn.request_path, @@ -61,10 +56,6 @@ defmodule Teleplug do end) end - defp service_name(opts) do - Keyword.get(opts, :service_name) || Application.get_application(__MODULE__) - end - # see https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/semantic_conventions/http.md#common-attributes defp http_common_attributes( %Conn{ diff --git a/mix.exs b/mix.exs index 621ed41..a246dad 100644 --- a/mix.exs +++ b/mix.exs @@ -4,7 +4,7 @@ defmodule Teleplug.MixProject do def project do [ app: :teleplug, - version: "1.0.0-rc.1", + version: "1.0.0-rc.2", elixir: "~> 1.10", start_permanent: Mix.env() == :prod, deps: deps(), @@ -23,11 +23,16 @@ defmodule Teleplug.MixProject do defp deps do [ {:opentelemetry_api, "~> 1.0.0-rc.2"}, - {:opentelemetry, "~> 1.0.0-rc.2", only: :test}, - {:plug, "~> 1.11"}, + {:plug, "~> 1.11"} + ] ++ dev_deps() + end + + def dev_deps do + [ {:credo, "~> 1.5", only: [:dev, :test], runtime: false}, {:dialyxir, "~> 1.1", only: [:dev, :test], runtime: false}, - {:ex_doc, ">= 0.0.0", only: :dev, runtime: false} + {:ex_doc, ">= 0.0.0", only: :dev, runtime: false}, + {:opentelemetry, "~> 1.0.0-rc.2", only: :test} ] end diff --git a/mix.lock b/mix.lock index 5069ebf..5714b8b 100644 --- a/mix.lock +++ b/mix.lock @@ -12,8 +12,8 @@ "makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"}, "mime": {:hex, :mime, "1.6.0", "dabde576a497cef4bbdd60aceee8160e02a6c89250d6c0b29e56c0dfb00db3d2", [:mix], [], "hexpm", "31a1a8613f8321143dde1dafc36006a17d28d02bdfecb9e95a880fa7aabd19a7"}, "nimble_parsec": {:hex, :nimble_parsec, "1.1.0", "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89", [:mix], [], "hexpm", "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"}, - "opentelemetry": {:hex, :opentelemetry, "0.6.0", "7e7d5a9a66f047dad3ae7613fc7cef25af3c19692663c2f8c00b015e4845592a", [:rebar3], [{:opentelemetry_api, "~>0.6.0", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}], "hexpm", "91f486315f7c4183245e1ec146563ae1073ec2044f4d186fabe9cb4841005200"}, - "opentelemetry_api": {:hex, :opentelemetry_api, "0.6.0", "749ccbfc68b3c8347e52492503a67f85da61ed898e42a592e62db88d3bcedf19", [:mix, :rebar3], [], "hexpm", "01d6a2455b42cf3aa225692210510c39727ff92f9612aea657d1395b642ad44f"}, + "opentelemetry": {:hex, :opentelemetry, "1.0.0-rc.2", "d3e1fd9debfd73e00b0241cac464be7cd6ca6ac2bd38ab2ebe0c92401c76a342", [:rebar3], [{:opentelemetry_api, "~> 1.0.0-rc.2", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}], "hexpm", "2f810e2eed70a9ea0c9b6943969b59e37f96a2f9e10920045a6c7676c2ab8181"}, + "opentelemetry_api": {:hex, :opentelemetry_api, "1.0.0-rc.2", "a0ec5b242bb7ce7563b4891e77dcfa529defc9e42c19a5a702574c5ac3d0c6e7", [:mix, :rebar3], [], "hexpm", "426a969c8ee2afa8ab55b58e6e40e81c1f934c064459a1acb530f54042f9a9a3"}, "plug": {:hex, :plug, "1.11.1", "f2992bac66fdae679453c9e86134a4201f6f43a687d8ff1cd1b2862d53c80259", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "23524e4fefbb587c11f0833b3910bfb414bf2e2534d61928e920f54e3a1b881f"}, "plug_crypto": {:hex, :plug_crypto, "1.2.2", "05654514ac717ff3a1843204b424477d9e60c143406aa94daf2274fdd280794d", [:mix], [], "hexpm", "87631c7ad914a5a445f0a3809f99b079113ae4ed4b867348dd9eec288cecb6db"}, "telemetry": {:hex, :telemetry, "0.4.2", "2808c992455e08d6177322f14d3bdb6b625fbcfd233a73505870d8738a2f4599", [:rebar3], [], "hexpm", "2d1419bd9dda6a206d7b5852179511722e2b18812310d304620c7bd92a13fcef"}, diff --git a/test/teleplug_test.exs b/test/teleplug_test.exs index c2c84ac..88b86dc 100644 --- a/test/teleplug_test.exs +++ b/test/teleplug_test.exs @@ -29,7 +29,7 @@ defmodule TeleplugTest do end test "teleplug attributes " do - opts = Teleplug.init(service_name: :name) + opts = Teleplug.init([]) Tracer.with_span "test" do conn = @@ -50,7 +50,6 @@ defmodule TeleplugTest do assert Enum.all?( [ {"http.status_code", nil}, - {"service.name", :name}, {"http.method", "GET"}, {"http.route", "/"}, {"http.target", "/"},