{"id":16024263,"url":"https://github.com/axelson/data_tracer","last_synced_at":"2025-03-17T16:30:45.548Z","repository":{"id":66428840,"uuid":"182834693","full_name":"axelson/data_tracer","owner":"axelson","description":"Elixir library to facilitate debugging data flow, helps capture terms for later inspection","archived":false,"fork":false,"pushed_at":"2024-08-17T21:20:56.000Z","size":54,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-11T08:54:44.806Z","etag":null,"topics":["elixir"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/axelson.png","metadata":{"files":{"readme":"README.md","changelog":"Changelog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-22T17:24:38.000Z","updated_at":"2025-01-05T14:00:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"7a664e31-d65e-4788-89aa-0c9c9b2823ed","html_url":"https://github.com/axelson/data_tracer","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axelson%2Fdata_tracer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axelson%2Fdata_tracer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axelson%2Fdata_tracer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axelson%2Fdata_tracer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/axelson","download_url":"https://codeload.github.com/axelson/data_tracer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243871336,"owners_count":20361332,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elixir"],"created_at":"2024-10-08T19:06:20.204Z","updated_at":"2025-03-17T16:30:45.119Z","avatar_url":"https://github.com/axelson.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DataTracer\n\nElixir debug tool to facilitate inspection of data flow by capturing terms for\ninspection in IEx.\n\nThe primary intended usecase for DataTracer is to capture Elixir\nterms—especially terms that are not printable or span many lines—and bringing\nthem into your IEx REPL. And yes, DataTracer is effectively global variables for\nElixir.\n\nDataTracer doesn't have any dependencies.\n\n**Warning** Not intended for use in production, may cause runaway memory use!\n\n## Why create this?\n\nI've found that when writing code I find it much easier to work with real data\nand then quickly iterate in a REPL. But quite often the bit of data that I'm\ninterested in is \"far\" away from the command I run in IEx or could even only be\naccessible from within the context of a Phoenix request. However, since\neverything is happening within the same BEAM instance with a bit of plumbing\n(enter DataTracer!) we can expose those values in a usable way.\n\nDataTracer also helps with cases where code that you inspect is either too long\n(or you forgot to include `limit: :infinity` when calling `IO.inspect`) or\ncontains a printout that can't be converted back to elixir terms, such as PIDs,\noften only one part of a struct in a printout will be invalid, but that means\nyou can't simply copy the result to IEx, instead you have to first remove the\ninvalid bits which is time consuming and error prone.\n\n## Installation\n\n`DataTracer` can be installed by adding `data_tracer` to your list of\ndependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:data_tracer, \"~\u003e 0.1\", only: [:dev]},\n  ]\nend\n```\n\nI recommend `only: [:dev]` because DataTracer is not intended for use in\nproduction.\n\n## Usage\n\nFor general usage of DataTracer I recommend starting your application with\n`iex -S mix` (or `iex -S mix phx.server` for a Phoenix application)\n\n``` elixir\n# Somewhere in your code (such as a Phoenix Controller or LiveView)\nDataTracer.store(\"earlier-value\", key: \"my-term\")\nDataTracer.store(\"some-value\", key: \"my-term\")\n\n# In IEx\niex\u003e DataTracer.last(key: \"my-term\")\n\"some-value\"\niex\u003e DataTracer.lookup(\"my-term\")\n[\"some-value\", \"earlier-value\"]\n\n# Somewhere in your code (e.g. in a Phoenix Controller)\nDataTracer.store(conn)\n# Then access that controller by making a request to it, for example visit:\n# http://localhost:4000/page?a_query_param=my_val\n\n# In IEx\niex\u003e conn = DataTracer.last()\nconn = %Plug.Conn{\n  adapter: {Plug.Cowboy.Conn, :...},\n  assigns: %{flash: %{}},\n  body_params: %{},\n  cookies: %{},\n  halted: false,\n  ...\n}\n# Now you can inspect specific values of the `conn`\niex\u003e conn.params\n%{\"a_query_param\" =\u003e \"my_val\"}\n```\n\nUse cases:\n- Capture a `pid`\n- Capture values from a Phoenix request\n- Collect many values over time so you can debug\n\n## How it Works\n\nDataTracer saves received terms to ETS and then looks them up from there. The\nlookup should generally be fast because it's based on a key in an ordered set\ntable in ETS.\n\nInsertion happens via a GenServer (`DataTracer.Server`) to ensure that race\nconditions are handled.\n\nNote: I've spent some effort to make DataTracer fast at lookups while not\ncompromising storage speed but I haven't done any benhcmarks and there's likely\nlots of room for improvement.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxelson%2Fdata_tracer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faxelson%2Fdata_tracer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxelson%2Fdata_tracer/lists"}