Skip to content

tw default dir and --clean - #222

Merged
scott-cotton merged 11 commits into
tw-continuous-ready-matchfrom
tw-default-dir
Oct 16, 2025
Merged

scott-cotton merged 11 commits into
tw-continuous-ready-matchfrom
tw-default-dir

Conversation

@scott-cotton

Copy link
Copy Markdown
Member

Following slack discussion

summary

25-10-15 scott@air cli % ./signadot traffic watch --sandbox sbr
Traffic will be written to /Users/scott/.signadot/traffic/watch.json.  # <========= new
Waiting (up to --wait-timeout=30s) for sandbox to be ready...
✓ Sandbox status: Ready: All desired workloads are available.
msg="watching sandbox request activity and content" sandbox=sbr watch-options=+stream/+stream output-dir=/Users/scott/.signadot/traffic/watch.json
25-10-15 scott@air cli % ./signadot traffic watch -h
watch
Provide a sandbox with --sandbox and watch its traffic.

With --short, watch only reports request activity. If --to specifies a file,
request activity is sent in a json (or yaml) stream to it.  Otherwise, no
stream is recorded.

Without --short, watch produces output in a directory will be populated with a
meta.jsons (or .yamls) file and subdirectories named by middleware request ids.

By default, this directory is either $HOME/.signadot/traffic/watch.json
or $HOME/.signadot/traffic/watch.yaml, depending on the output format.

Each subdirectory in turn will contain the files

- meta.json (or .yaml)
- request
- response

The request (and response) contains the wire format

- the protocol line which is terminated with '\r\n'.
- the headers each terminated  by '\r\n'
- the separator '\r\n'
- the body, unless run with --headers-only

Usage:
  signadot traffic watch --sandbox SANDBOX [ --short | --headers-only  ] [flags]

Flags:
      --clean                   remove old data from output directory first, unless --short
      --headers-only            do not record request and response bodies
  -h, --help                    help for watch
      --no-instrument           do not instrument sandbox
      --sandbox string          sandbox whose traffic to watch
      --short                   only watch request metadata
      --to string               output to specified file or directory as needed
      --wait-timeout duration   time to wait for intial sandbox readiness (default 30s)

Global Flags:
      --config string   config file (default is $HOME/.signadot/config.yaml)
      --debug           enable debug output
  -o, --output string   output format (json|yaml)

also,
- improve help
- improve signal handling
@scott-cotton
scott-cotton requested a review from davixcky October 15, 2025 12:14
@gitar-bot

gitar-bot Bot commented Oct 15, 2025

Copy link
Copy Markdown

Gitar automatically fixes CI failures and addresses comments starting with Gitar.

⚙️ Options:

  • Fix CI failures*

🔄 To revert changes, post a comment:

Gitar revert to commit <desired commit SHA>

📚 Docs

* Gitar never force pushes to your branch

@davixcky

Copy link
Copy Markdown
Contributor

I think By default, this directory is either $HOME/.signadot/traffic/watch.json is not correct given you are saying directory but indicating the file.

Comment thread internal/trafficwatch/constants.go Resolved
Comment thread internal/utils/system/system.go Resolved

- the protocol line which is terminated with '\r\n'.
- the headers each terminated by '\r\n'
- the separator '\r\n'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add some examples? Like one for to when relative path

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having thought about it during implementation, I think it is simpler for us and the user to just have --to refer a path without automagically placing certain things in the signadot dir.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have renamed it here acbf6fe

@scott-cotton

Copy link
Copy Markdown
Member Author

I think By default, this directory is either $HOME/.signadot/traffic/watch.json is not correct given you are saying directory but indicating the file.

But it is the name of the directory. Maybe it would be clearer if it said

By default the directory is either $HOME/.signadot/traffic/watch-json ?

@davixcky

Copy link
Copy Markdown
Contributor

I think By default, this directory is either $HOME/.signadot/traffic/watch.json is not correct given you are saying directory but indicating the file.

But it is the name of the directory. Maybe it would be clearer if it said

By default the directory is either $HOME/.signadot/traffic/watch-json ?

Yes better, however what about .../traffic/watch/{json | yaml}?

@scott-cotton

Copy link
Copy Markdown
Member Author

I think By default, this directory is either $HOME/.signadot/traffic/watch.json is not correct given you are saying directory but indicating the file.

But it is the name of the directory. Maybe it would be clearer if it said
By default the directory is either $HOME/.signadot/traffic/watch-json ?

Yes better, however what about .../traffic/watch/{json | yaml}?

Personally I don't like adding a level there because it is harder to interact with.

@davixcky

Copy link
Copy Markdown
Contributor

LGTM

@scott-cotton
scott-cotton merged commit 8feeb4b into tw-continuous-ready-match Oct 16, 2025
@scott-cotton
scott-cotton deleted the tw-default-dir branch October 16, 2025 11:13
scott-cotton added a commit that referenced this pull request Oct 16, 2025
* add continuous readiness and match checking

* adds doneAt reporting

in terminal logs and directory output meta.jsons, this will
output a json

```
{"middlewareRequestID":"c3e36c64","doneAt":"2025-10-13T17:06:32.026094+02:00"}
{"middlewareRequestID":"777bfc30","doneAt":"2025-10-13T17:06:38.413933+02:00"}
{"middlewareRequestID":"777bfc30","watchOptions":"-trunc(0)/-trunc(0)","when":"2025-10-13T15:06:38.385144025Z","normHost":"location.hotrod-devmesh.svc.cluster.local:8081","routingKey":"g9wqf90gqw9mj","destWorkload":"Deployment/hotrod-devmesh/location","requestURI":"http://sbr-dep-location-2c37fc13.hotrod-devmesh.svc:8081/locations","method":"GET","proto":"HTTP/1.1","userAgent":"curl/8.7.1"}
```

Note the order between doneAt and the initial request is not guaranteed
(I think it would be hard and likely buggy to do so...)

In request directories, the meta.jsons gets updated to include "doneAt":

* fixes to continuous readiness checking

- overwrite on first apply
- fix retErrs overwrites
- fix a couple of logic issues

* adds doneAt reporting (#220)

* adds doneAt reporting

in terminal logs and directory output meta.jsons, this will
output a json

```
{"middlewareRequestID":"c3e36c64","doneAt":"2025-10-13T17:06:32.026094+02:00"}
{"middlewareRequestID":"777bfc30","doneAt":"2025-10-13T17:06:38.413933+02:00"}
{"middlewareRequestID":"777bfc30","watchOptions":"-trunc(0)/-trunc(0)","when":"2025-10-13T15:06:38.385144025Z","normHost":"location.hotrod-devmesh.svc.cluster.local:8081","routingKey":"g9wqf90gqw9mj","destWorkload":"Deployment/hotrod-devmesh/location","requestURI":"http://sbr-dep-location-2c37fc13.hotrod-devmesh.svc:8081/locations","method":"GET","proto":"HTTP/1.1","userAgent":"curl/8.7.1"}
```

Note the order between doneAt and the initial request is not guaranteed
(I think it would be hard and likely buggy to do so...)

In request directories, the meta.jsons gets updated to include "doneAt":

* fixes to continuous readiness checking

- overwrite on first apply
- fix retErrs overwrites
- fix a couple of logic issues

* cleanup/mw name constant

* add --no-instrument and improve log output

* json/yaml, --to, unified log for session

* add local machine id when appropriate

* retErr-issue-again

* remove debug print

* fixes in yaml support

* use request. uniformly

* tw default dir and --clean (#222)

* implementation of tw directory default

also,
- improve help
- improve signal handling

* add --clean flag

* fix sentence in help

* use -{json,yaml} for directory

* update flags after discussion

- no-instrument is hidden
- --to has become --output-dir, which only applies when !short
- --output-file may be provided with --short

* check match consistency as well.

* rename watch command to record

* add 'r' alias for record

* rename files to reflect 'record' command name

* use trafficwatch.MiddlewareName everywhere

* rename cli mw to trafficwatch from trafficwatch-client

(depends on PR in signadot repo)
scott-cotton added a commit that referenced this pull request Oct 17, 2025
* add continuous readiness and match checking

* adds doneAt reporting

in terminal logs and directory output meta.jsons, this will
output a json

```
{"middlewareRequestID":"c3e36c64","doneAt":"2025-10-13T17:06:32.026094+02:00"}
{"middlewareRequestID":"777bfc30","doneAt":"2025-10-13T17:06:38.413933+02:00"}
{"middlewareRequestID":"777bfc30","watchOptions":"-trunc(0)/-trunc(0)","when":"2025-10-13T15:06:38.385144025Z","normHost":"location.hotrod-devmesh.svc.cluster.local:8081","routingKey":"g9wqf90gqw9mj","destWorkload":"Deployment/hotrod-devmesh/location","requestURI":"http://sbr-dep-location-2c37fc13.hotrod-devmesh.svc:8081/locations","method":"GET","proto":"HTTP/1.1","userAgent":"curl/8.7.1"}
```

Note the order between doneAt and the initial request is not guaranteed
(I think it would be hard and likely buggy to do so...)

In request directories, the meta.jsons gets updated to include "doneAt":

* fixes to continuous readiness checking

- overwrite on first apply
- fix retErrs overwrites
- fix a couple of logic issues

* adds doneAt reporting (#220)

* adds doneAt reporting

in terminal logs and directory output meta.jsons, this will
output a json

```
{"middlewareRequestID":"c3e36c64","doneAt":"2025-10-13T17:06:32.026094+02:00"}
{"middlewareRequestID":"777bfc30","doneAt":"2025-10-13T17:06:38.413933+02:00"}
{"middlewareRequestID":"777bfc30","watchOptions":"-trunc(0)/-trunc(0)","when":"2025-10-13T15:06:38.385144025Z","normHost":"location.hotrod-devmesh.svc.cluster.local:8081","routingKey":"g9wqf90gqw9mj","destWorkload":"Deployment/hotrod-devmesh/location","requestURI":"http://sbr-dep-location-2c37fc13.hotrod-devmesh.svc:8081/locations","method":"GET","proto":"HTTP/1.1","userAgent":"curl/8.7.1"}
```

Note the order between doneAt and the initial request is not guaranteed
(I think it would be hard and likely buggy to do so...)

In request directories, the meta.jsons gets updated to include "doneAt":

* fixes to continuous readiness checking

- overwrite on first apply
- fix retErrs overwrites
- fix a couple of logic issues

* cleanup/mw name constant

* add --no-instrument and improve log output

* json/yaml, --to, unified log for session

* add local machine id when appropriate

* retErr-issue-again

* remove debug print

* fixes in yaml support

* use request. uniformly

* tw default dir and --clean (#222)

* implementation of tw directory default

also,
- improve help
- improve signal handling

* add --clean flag

* fix sentence in help

* use -{json,yaml} for directory

* update flags after discussion

- no-instrument is hidden
- --to has become --output-dir, which only applies when !short
- --output-file may be provided with --short

* check match consistency as well.

* rename watch command to record

* add 'r' alias for record

* rename files to reflect 'record' command name

* use trafficwatch.MiddlewareName everywhere

* rename cli mw to trafficwatch from trafficwatch-client

(depends on PR in signadot repo)

* delay doneAt as needed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants