chore: add semantic conventions pkg (#118)
Co-authored-by: Tristan Sloughter <t@crashfast.com>
This commit is contained in:
parent
0c509f4ebc
commit
ed49b0c4bb
|
@ -14,7 +14,12 @@ defmodule Tesla.Middleware.OpenTelemetry do
|
||||||
or a function that takes the `Tesla.Env` and returns a `String`
|
or a function that takes the `Tesla.Env` and returns a `String`
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
alias OpenTelemetry.SemanticConventions.Trace
|
||||||
|
|
||||||
require OpenTelemetry.Tracer
|
require OpenTelemetry.Tracer
|
||||||
|
require Trace
|
||||||
|
|
||||||
@behaviour Tesla.Middleware
|
@behaviour Tesla.Middleware
|
||||||
|
|
||||||
def call(env, next, opts) do
|
def call(env, next, opts) do
|
||||||
|
@ -87,12 +92,12 @@ defmodule Tesla.Middleware.OpenTelemetry do
|
||||||
uri = URI.parse(url)
|
uri = URI.parse(url)
|
||||||
|
|
||||||
attrs = %{
|
attrs = %{
|
||||||
"http.method": http_method(method),
|
Trace.http_method() => http_method(method),
|
||||||
"http.url": url,
|
Trace.http_url() => url,
|
||||||
"http.target": uri.path,
|
Trace.http_target() => uri.path,
|
||||||
"http.host": uri.host,
|
Trace.net_host_name() => uri.host,
|
||||||
"http.scheme": uri.scheme,
|
Trace.http_scheme() => uri.scheme,
|
||||||
"http.status_code": status_code
|
Trace.http_status_code() => status_code
|
||||||
}
|
}
|
||||||
|
|
||||||
maybe_append_content_length(attrs, headers)
|
maybe_append_content_length(attrs, headers)
|
||||||
|
@ -104,7 +109,7 @@ defmodule Tesla.Middleware.OpenTelemetry do
|
||||||
attrs
|
attrs
|
||||||
|
|
||||||
{_key, content_length} ->
|
{_key, content_length} ->
|
||||||
Map.put(attrs, :"http.response_content_length", content_length)
|
Map.put(attrs, Trace.http_response_content_length(), content_length)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,7 @@ defmodule OpentelemetryTesla.MixProject do
|
||||||
{:opentelemetry, "~> 1.0", only: :test},
|
{:opentelemetry, "~> 1.0", only: :test},
|
||||||
{:opentelemetry_api, "~> 1.0"},
|
{:opentelemetry_api, "~> 1.0"},
|
||||||
{:opentelemetry_telemetry, "~> 1.0.0"},
|
{:opentelemetry_telemetry, "~> 1.0.0"},
|
||||||
|
{:opentelemetry_semantic_conventions, "~> 0.1.0"},
|
||||||
{:tesla, "~> 1.4"},
|
{:tesla, "~> 1.4"},
|
||||||
{:ex_doc, "~> 0.24", only: :dev, runtime: false},
|
{:ex_doc, "~> 0.24", only: :dev, runtime: false},
|
||||||
{:bypass, "~> 2.1", only: :test},
|
{:bypass, "~> 2.1", only: :test},
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
"nimble_parsec": {:hex, :nimble_parsec, "1.2.0", "b44d75e2a6542dcb6acf5d71c32c74ca88960421b6874777f79153bbbbd7dccc", [:mix], [], "hexpm", "52b2871a7515a5ac49b00f214e4165a40724cf99798d8e4a65e4fd64ebd002c1"},
|
"nimble_parsec": {:hex, :nimble_parsec, "1.2.0", "b44d75e2a6542dcb6acf5d71c32c74ca88960421b6874777f79153bbbbd7dccc", [:mix], [], "hexpm", "52b2871a7515a5ac49b00f214e4165a40724cf99798d8e4a65e4fd64ebd002c1"},
|
||||||
"opentelemetry": {:hex, :opentelemetry, "1.0.0", "6e98f4a9230681b2e4c88d45783ce1c02d671ffc0b5ac0cba69a34a3f5ada8d8", [:rebar3], [{:opentelemetry_api, "~> 1.0.0", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}], "hexpm", "08d8697740f70594d05067cb62a0a8845ff568b2d47e1f8c78c46708ab58a74f"},
|
"opentelemetry": {:hex, :opentelemetry, "1.0.0", "6e98f4a9230681b2e4c88d45783ce1c02d671ffc0b5ac0cba69a34a3f5ada8d8", [:rebar3], [{:opentelemetry_api, "~> 1.0.0", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}], "hexpm", "08d8697740f70594d05067cb62a0a8845ff568b2d47e1f8c78c46708ab58a74f"},
|
||||||
"opentelemetry_api": {:hex, :opentelemetry_api, "1.0.2", "91353ee40583b1d4f07d7b13ed62642abfec6aaa0d8a2114f07edafb2df781c5", [:mix, :rebar3], [], "hexpm", "2a8247f85c44216b883900067478d59955d11e58e5cfca7c884cd4f203ace3ac"},
|
"opentelemetry_api": {:hex, :opentelemetry_api, "1.0.2", "91353ee40583b1d4f07d7b13ed62642abfec6aaa0d8a2114f07edafb2df781c5", [:mix, :rebar3], [], "hexpm", "2a8247f85c44216b883900067478d59955d11e58e5cfca7c884cd4f203ace3ac"},
|
||||||
|
"opentelemetry_semantic_conventions": {:hex, :opentelemetry_semantic_conventions, "0.1.0", "0a7463c0ec4541d9c8e09ee99bd7b5480fa6f90f40313a6d071fd7521b5a712f", [:mix, :rebar3], [], "hexpm", "eccf41bc7afec299484075aff570bf504a2f7e5c38fbcdaceb33a6d6b901448d"},
|
||||||
"opentelemetry_telemetry": {:hex, :opentelemetry_telemetry, "1.0.0", "d5982a319e725fcd2305b306b65c18a86afdcf7d96821473cf0649ff88877615", [:mix, :rebar3], [{:opentelemetry_api, "~> 1.0", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:telemetry_registry, "~> 0.3.0", [hex: :telemetry_registry, repo: "hexpm", optional: false]}], "hexpm", "3401d13a1d4b7aa941a77e6b3ec074f0ae77f83b5b2206766ce630123a9291a9"},
|
"opentelemetry_telemetry": {:hex, :opentelemetry_telemetry, "1.0.0", "d5982a319e725fcd2305b306b65c18a86afdcf7d96821473cf0649ff88877615", [:mix, :rebar3], [{:opentelemetry_api, "~> 1.0", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:telemetry_registry, "~> 0.3.0", [hex: :telemetry_registry, repo: "hexpm", optional: false]}], "hexpm", "3401d13a1d4b7aa941a77e6b3ec074f0ae77f83b5b2206766ce630123a9291a9"},
|
||||||
"plug": {:hex, :plug, "1.12.1", "645678c800601d8d9f27ad1aebba1fdb9ce5b2623ddb961a074da0b96c35187d", [:mix], [{:mime, "~> 1.0 or ~> 2.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.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "d57e799a777bc20494b784966dc5fbda91eb4a09f571f76545b72a634ce0d30b"},
|
"plug": {:hex, :plug, "1.12.1", "645678c800601d8d9f27ad1aebba1fdb9ce5b2623ddb961a074da0b96c35187d", [:mix], [{:mime, "~> 1.0 or ~> 2.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.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "d57e799a777bc20494b784966dc5fbda91eb4a09f571f76545b72a634ce0d30b"},
|
||||||
"plug_cowboy": {:hex, :plug_cowboy, "2.5.2", "62894ccd601cf9597e2c23911ff12798a8a18d237e9739f58a6b04e4988899fe", [:mix], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:cowboy_telemetry, "~> 0.3", [hex: :cowboy_telemetry, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "ea6e87f774c8608d60c8d34022a7d073bd7680a0a013f049fc62bf35efea1044"},
|
"plug_cowboy": {:hex, :plug_cowboy, "2.5.2", "62894ccd601cf9597e2c23911ff12798a8a18d237e9739f58a6b04e4988899fe", [:mix], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:cowboy_telemetry, "~> 0.3", [hex: :cowboy_telemetry, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "ea6e87f774c8608d60c8d34022a7d073bd7680a0a013f049fc62bf35efea1044"},
|
||||||
|
|
Loading…
Reference in New Issue