View Source OpentelemetryReq (Opentelemetry Req v0.2.0)

Wraps the request in an opentelemetry span. Span names must be paramaterized, so the req_path_params module and step should be registered before this step. This step is expected by default and an error will be raised if the path params option is not set for the request.

Spans are not created until the request is completed or errored.

Request Options

  • :span_name - String.t() if provided, overrides the span name. Defaults to nil.
  • :no_path_params - boolean() when set to true no path params are expected for the request. Defaults to false
  • :propagate_trace_ctx - boolean() when set to true, trace headers will be propagated. Defaults to false

Example with path_params

client =
  Req.new()
  |> OpentelemetryReq.attach(
    base_url: "http://localhost:4000",
    propagate_trace_ctx: true
  )

client
|> Req.get(
  url: "/api/users/:user_id",
  path_params: [user_id: user_id]
)

Example without path_params

client =
  Req.new()
  |> OpentelemetryReq.attach(
    base_url: "http://localhost:4000",
    propagate_trace_ctx: true,
    no_path_params: true
  )

client
|> Req.get(
  url: "/api/users"
)

If you don't set path_params the request will raise.

Summary

Functions

Link to this function

attach(request, options \\ [])

View Source