Skip to content

Commit

Permalink
Merge pull request #4308 from tloncorp/mp/lure-logs
Browse files Browse the repository at this point in the history
Enable lure flow logging in %grouper
  • Loading branch information
mikolajpp authored Jan 13, 2025
2 parents e5f8d9e + fbf8da8 commit d4c5e11
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 26 deletions.
3 changes: 2 additions & 1 deletion desk/app/activity.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
|_ =bowl:gall
+* this .
def ~(. (default-agent this %|) bowl)
log ~(. logs [our.bowl /logs])
cor ~(. +> [bowl ~])
::
++ on-init
Expand Down Expand Up @@ -112,7 +113,7 @@
|= [=term =tang]
^- (quip card _this)
:_ this
[(log-fail:logs /logs our.bowl (fail-event:logs term tang))]~
[(fail:log term tang)]~
--
|_ [=bowl:gall cards=(list card)]
++ abet [(flop cards) state]
Expand Down
3 changes: 2 additions & 1 deletion desk/app/channels-server.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
|_ =bowl:gall
+* this .
def ~(. (default-agent this %|) bowl)
log ~(. logs [our.bowl /logs])
cor ~(. +> [bowl ~])
++ on-init
^- (quip card _this)
Expand Down Expand Up @@ -64,7 +65,7 @@
|= [=term =tang]
^- (quip card _this)
:_ this
[(log-fail:logs /logs our.bowl (fail-event:logs term tang))]~
[(fail:log term tang)]~
::
++ on-agent
|= [=wire =sign:agent:gall]
Expand Down
3 changes: 2 additions & 1 deletion desk/app/channels.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
|_ =bowl:gall
+* this .
def ~(. (default-agent this %|) bowl)
log ~(. logs [our.bowl /logs])
cor ~(. +> [bowl ~])
++ on-init
^- (quip card _this)
Expand Down Expand Up @@ -82,7 +83,7 @@
|= [=term =tang]
^- (quip card _this)
:_ this
[(log-fail:logs /logs our.bowl (fail-event:logs term tang))]~
[(fail:log term tang)]~
::
++ on-agent
|= [=wire =sign:agent:gall]
Expand Down
34 changes: 18 additions & 16 deletions desk/app/grouper.hoon
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/- reel, groups, c=chat, ch=channels
/+ gj=groups-json, default-agent, verb, dbug
/+ gj=groups-json, default-agent, verb, logs, dbug
::
|%
++ dev-mode |
++ enabled-groups (set cord)
++ outstanding-pokes (set (pair ship cord))
++ bite-subscribe
Expand All @@ -27,6 +26,7 @@
|_ =bowl:gall
+* this .
def ~(. (default-agent this %.n) bowl)
log ~(. logs [our.bowl /logs])
::
++ on-init
:_ this
Expand Down Expand Up @@ -138,7 +138,7 @@
:_ this
=; caz=(list card)
?~ inviter=(~(get by fields.metadata.bite) 'inviter')
~&("no inviter field for token: {<token.bite>}" ~)
~[(tell:log `token.bite %crit 'inviter field missing' ~)]
?. =((slav %p u.inviter) our.bowl) ~
=/ wir=^wire /dm/(scot %p joiner.bite)
=/ =dock [our.bowl %chat]
Expand All @@ -149,43 +149,45 @@
:- joiner.bite
[id %add memo [%notice ~] ~]
=/ =cage chat-dm-action+!>(`action:dm:c`action)
(snoc caz [%pass wir %agent dock %poke cage])
=* dez %^ tell:log `token.bite %info
~[leaf+"{<joiner.bite>} invited to DM"]
(snoc [dez caz] [%pass wir %agent dock %poke cage])
?~ group=(~(get by fields.metadata.bite) 'group')
~&("no group field for token: {<token.bite>}" ~)
~[(tell:log `token.bite %warn 'group field missing' ~)]
=/ =flag:groups (flag:dejs:gj s+u.group)
~? dev-mode [bite (~(has in enabled-groups) q.flag)]
?. (~(has in enabled-groups) q.flag)
~&("group lure not enabled: {<flag>}" ~)
~? dev-mode 'inviting'
~[(tell:log `token.bite %warn 'group {<p.flag>}/{<q.flag>} lure disabled' ~)]
=/ =invite:groups [flag joiner.bite]
=/ prefix /(scot %p our.bowl)/groups/(scot %da now.bowl)
?. .^(? %gu (weld prefix /$))
~?(dev-mode "groups not running" ~)
~[(tell:log `token.bite %warn '%groups not running' ~)]
=/ gnat=path /(scot %p p.flag)/[q.flag]/noun
?. .^(? %gx :(weld prefix /exists gnat))
~?(dev-mode "group doesn't exist" ~)
~[(tell:log `token.bite %warn 'group {<p.flag>}/{<q.flag>} not found' ~)]
=+ .^(=group:groups %gx :(weld prefix /groups gnat))
~? dev-mode cordon.group
?+ -.cordon.group ~
%open
~? dev-mode ['inviting to public' joiner.bite]
:- %^ tell:log `token.bite %info
~[leaf+"{<joiner.bite>} invited to public group {<p.flag>}/{<q.flag>}"]
~[[%pass /invite %agent [our.bowl %groups] %poke %group-invite !>(invite)]]
::
%shut
~? dev-mode ['inviting to private/secret' joiner.bite]
=/ =action:groups
:- flag
:- now.bowl
:- %cordon
[%shut [%add-ships %pending (~(gas in *(set ship)) ~[joiner.bite])]]
:_ ~
[%pass /invite %agent [our.bowl %groups] %poke act:mar:groups !>(action)]
:- %^ tell:log `token.bite %info
~[leaf+"{<joiner.bite>} invited to restricted group {<p.flag>}/{<q.flag>}"]
~[[%pass /invite %agent [our.bowl %groups] %poke act:mar:groups !>(action)]]
==
==
::
++ on-fail
|= [=term =tang]
(mean ':sub +on-fail' term tang)
^- (quip card _this)
:_ this
[(fail:log (fail-event:logs term tang))]~
::
++ on-leave
|= =path
Expand Down
3 changes: 2 additions & 1 deletion desk/app/groups.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
|_ =bowl:gall
+* this .
def ~(. (default-agent this %|) bowl)
log ~(. logs [our.bowl /logs])
cor ~(. +> [bowl ~])
++ on-init
^- (quip card _this)
Expand Down Expand Up @@ -73,7 +74,7 @@
|= [=term =tang]
^- (quip card _this)
:_ this
[(log-fail:logs /logs our.bowl (fail-event:logs term tang))]~
[(fail:log term tang)]~
::
++ on-agent
|= [=wire =sign:agent:gall]
Expand Down
44 changes: 39 additions & 5 deletions desk/lib/logs.hoon
Original file line number Diff line number Diff line change
@@ -1,15 +1,37 @@
/- *logs
=<
|_ [our=ship =wire]
::
++ fail
|= [desc=term trace=tang]
^- card:agent:gall
=/ event=$>(%fail log-event)
[%fail desc trace]
(pass event)
::
++ tell
|= [id=(unit @ta) vol=volume =echo]
^- card:agent:gall
=/ event=$>(%tell log-event)
[%tell id vol echo]
(pass event)
::
++ pass
|= event=log-event
^- card:agent:gall
[%pass wire %agent [our %logs] %poke log-action+!>([%log event])]
--
|%
::
++ fail-event
|= [=term =tang]
^- $>(%fail log-event)
[%fail term tang]
::
++ log-fail
|= [=wire our=ship event=$>(%fail log-event)]
^- card:agent:gall
[%pass wire %agent [our %logs] %poke log-action+!>([%log event])]
++ tell-event
|= [id=(unit @ta) vol=volume =echo]
^- $>(%tell log-event)
[%tell id vol echo]
::
++ enjs
=, format
Expand All @@ -34,7 +56,19 @@
%- pairs:enjs
:~ type/s+event-type
description/s+desc.e
stacktrace/(tang crash.e)
stacktrace/(tang trace.e)
==
::
%tell
=- ?>(?=(%o -.-) -)
%- pairs:enjs
::
:: insert tell id if present
=- ?~ id.e -
[id/s+u.id.e -]
:~ type/s+event-type
message/(tang echo.e)
volume/s+vol.e
==
==
--
Expand Down
8 changes: 7 additions & 1 deletion desk/sur/logs.hoon
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
/+ mp=mop-extensions
::
|%
:: $echo: formatted message
+$ echo (list tank)
:: $volume: echo volume
+$ volume ?(%info %warn %crit)
:: $log-event
::
:: %fail: agent failure
:: %tell: agent message
::
+$ log-event
$% [%fail desc=term crash=tang]
$% [%fail desc=term trace=tang]
[%tell id=(unit @ta) vol=volume =echo]
==
::
:: $log-item: event with timestamp
Expand Down
5 changes: 5 additions & 0 deletions desk/ted/posthog.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,18 @@
=* log-item q.u.arg
;< =bowl:strand bind:m get-bowl:io
=/ log-event-json=$>(%o json) (log-event:enjs:l event.log-item)
:: retrieve desk hash
::
;< hash=@uv bind:m (scry:io @uv %cz q.byk.bowl ~)
::
=/ props=json
:- %o
%- ~(uni by p.log-event-json)
^- (map @t json)
%- my
:~ 'distinct_id'^s+(scot %p our.bowl)
'origin'^s+(spat origin)
'hash'^s+(crip ((v-co:co 5) (end [0 25] hash)))
==
=/ event=json
%- pairs:enjs:format
Expand Down

0 comments on commit d4c5e11

Please sign in to comment.