nathanl
I see this error locally when running my application. mix deps shows versions:
- oban 2.19.1
- oban_met 0.1.11
- oban_pro 1.5.0
- oban_web 2.10.2
- telemetry 1.3.0
- telemetry_metrics 1.1.0
- telemetry_poller 1.1.0
[error] GenServer {Oban.Registry, {Oban, Oban.Met.Listener}} terminating
** (Protocol.UndefinedError) protocol JSON.Encoder not implemented for type Oban.Met.Values.Gauge (a struct), the protocol must be explicitly implemented.
If you have a struct, you can derive the implementation specifying which fields should be encoded to JSON:
@derive {JSON.Encoder, only: [....]}
defstruct ...
It is also possible to encode all fields, although this should be used carefully to avoid accidentally leaking private information when new fields are added:
@derive JSON.Encoder
defstruct ...
Finally, if you don't own the struct you want to encode to JSON, you may use Protocol.derive/3 placed outside of any module:
Protocol.derive(JSON.Encoder, NameOfTheStruct, only: [...])
Protocol.derive(JSON.Encoder, NameOfTheStruct). This protocol is implemented for the following type(s): Atom, BitString, Date, DateTime, Decimal, Duration, Float, Integer, List, Map, NaiveDateTime, Oban.Pro.Producer, Oban.Pro.Producer.Meta.GlobalLimit, Oban.Pro.Producer.Meta.GlobalLimit.Partition, Oban.Pro.Producer.Meta.RateLimit, Oban.Pro.Producer.Meta.RateLimit.Partition, Time
Got value:
%Oban.Met.Values.Gauge{data: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]}
(elixir 1.18.2) lib/json.ex:1: JSON.Encoder.impl_for!/1
(elixir 1.18.2) lib/json.ex:109: JSON.Encoder.encode/2
(elixir 1.18.2) src/elixir_json.erl:323: :elixir_json."-do_encode_map/2-lc$^0/1-0-"/2
(elixir 1.18.2) src/elixir_json.erl:323: :elixir_json.do_encode_map/2
(elixir 1.18.2) src/elixir_json.erl:308: :elixir_json.do_encode_list/2
(elixir 1.18.2) src/elixir_json.erl:323: :elixir_json."-do_encode_map/2-lc$^0/1-0-"/2
(elixir 1.18.2) src/elixir_json.erl:323: :elixir_json."-do_encode_map/2-lc$^0/1-0-"/2
(elixir 1.18.2) src/elixir_json.erl:323: :elixir_json.do_encode_map/2
(oban 2.19.1) lib/oban/notifier.ex:307: Oban.Notifier.encode/1
(elixir 1.18.2) lib/enum.ex:1714: Enum."-map/2-lists^map/1-1-"/2
(oban 2.19.1) lib/oban/notifier.ex:202: anonymous fn/4 in Oban.Notifier.notify/3
(telemetry 1.3.0) /Users/me/code/myapp/deps/telemetry/src/telemetry.erl:324: :telemetry.span/3
(oban_met 0.1.11) lib/oban/met/listener.ex:82: Oban.Met.Listener.handle_info/2
(stdlib 6.2) gen_server.erl:2345: :gen_server.try_handle_info/3
(stdlib 6.2) gen_server.erl:2433: :gen_server.handle_msg/6
(stdlib 6.2) proc_lib.erl:329: :proc_lib.init_p_do_apply/3
Last message: :report
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
apply_graft/2 doesn’t rewrite an add_many sub-workflow’s deps on an add step. Grafted jobs cancel with “upstream job was deleted”
Version...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #blog-post
- #ai
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 7- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
sorentwo
Oban added a transparent switch between
JasonandJSON, which must also be respected by the other packages. In this case,oban_metis behind a version.Upgrading
oban_web(Changelog — Oban Web v2.12.5) andoban_met(Changelog — Oban Met v1.0.1) to the latest versions will fix the issue:nathanl
Understood. The newer
oban_webrequiresphoenix_live_view 1.0, which is a bigger lift to upgrade to. (We even have a couple of deps that require an older version of LV.) I guess we’ll have to prioritize that or else use an older version of Oban until we can.sorentwo
There are minimal changes in Web v2.11 to support LV 1.0. The newer
oban_webmay work with a slightly older version ofphoenix_live_viewif you want to try anoverride: true.nathanl
Thanks, that will let us limp along for a bit. Specifying the oban versions you showed and
{:phoenix_live_view, "~> 0.20.17", override: true}fixes the decoding errors. It means that the Oban Web dashboard just displays{@inner_content}, but we can work to get on LiveView 1.0 before the next deploy.thiagogsr
It seems I cannot use Oban 2.19 on Elixir 1.18 with
oban_web2.10.2 andoban_met0.1.11 becauseoban_metonly encodes toJason. I can’t updateoban_webyet because we are onphoenix_live_view0.20.17 it doesn’t work.Is there a workaround for this? I had to uninstall
oban_webtemporarily until I find a solution for this without Oban downgrade.Have you considered a config option on Oban to select the json library?
sorentwo
You can use
oban_metv1.0 withoverride: trueto force it. There aren’t any API changes between v0.1.11 and v1.0.0 andoban_webcan use it just fine.thiagogsr
Thank you!