Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cli/cmd/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const (
cloudquery sync ./directory
# Sync resources from directories and files
cloudquery sync ./directory ./aws.yml ./pg.yml
# Log tables metrics to a file
cloudquery sync ./directory ./aws.yml ./pg.yml --tables-metrics-location metrics.txt
`
)

Expand All @@ -37,8 +39,6 @@ func NewCmdSync() *cobra.Command {
cmd.Flags().String("license", "", "set offline license file")
cmd.Flags().String("summary-location", "", "Sync summary file location. This feature is in Preview. Please provide feedback to help us improve it.")
cmd.Flags().String("tables-metrics-location", "", "Tables metrics file location. This feature is in Preview. Please provide feedback to help us improve it.")
// Hide the flag until we release all plugins with https://github.com/cloudquery/plugin-sdk/releases/tag/v4.49.0
_ = cmd.Flags().MarkHidden("tables-metrics-location")

return cmd
}
Expand Down
18 changes: 14 additions & 4 deletions cli/internal/otel/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func newDefaultMetricConsumer(metricsFile *os.File, quit chan any) ConsumeMetric
}
t := table.NewWriter()
t.SetOutputMirror(metricsFile)
t.AppendHeader(table.Row{"Table", "Client ID", "Start Time", "End Time", "Resources", "Errors", "Panics"})
t.AppendHeader(table.Row{"Table", "Client ID", "Start Time", "End Time", "Duration", "Resources", "Errors", "Panics"})
sort.SliceStable(metrics, func(i, j int) bool {
m1 := metrics[i]
m2 := metrics[j]
Expand All @@ -110,18 +110,29 @@ func newDefaultMetricConsumer(metricsFile *os.File, quit chan any) ConsumeMetric
return m1.Table+m1.ClientId < m2.Table+m2.ClientId
})
for _, metrics := range metrics {
var duration time.Duration
switch {
case metrics.StartTime != nil && metrics.EndTime != nil:
duration = metrics.EndTime.Sub(*metrics.StartTime)
case metrics.StartTime != nil:
duration = time.Since(*metrics.StartTime)
}
row := table.Row{
metrics.Table,
metrics.ClientId,
metrics.StartTime,
metrics.EndTime,
duration,
metrics.Resources,
metrics.Errors,
metrics.Panics,
}
if metrics.EndTime == nil {
row[3] = "N/A"
}
if duration == 0 {
row[4] = "N/A"
}
t.AppendRow(row)
}
t.Render()
Expand Down Expand Up @@ -242,7 +253,7 @@ type OtelReceiver struct {
Endpoint string
}

func getPort() (int, error) {
func getFreePort() (int, error) {
listener, err := net.Listen("tcp", ":0")
if err != nil {
return 0, err
Expand Down Expand Up @@ -298,8 +309,7 @@ func StartOtelReceiver(ctx context.Context, opts ...OtelReceiverOption) (*OtelRe
factory := otlpreceiver.NewFactory()
config := factory.CreateDefaultConfig().(*otlpreceiver.Config)
config.GRPC = nil
// This will list on the first available port
port, err := getPort()
port, err := getFreePort()
if err != nil {
return nil, err
}
Expand Down
11 changes: 7 additions & 4 deletions website/pages/docs/reference/cli/cloudquery_sync.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,19 @@ cloudquery sync [files or directories] [flags]
cloudquery sync ./directory
# Sync resources from directories and files
cloudquery sync ./directory ./aws.yml ./pg.yml
# Log tables metrics to a file
cloudquery sync ./directory ./aws.yml ./pg.yml --tables-metrics-location metrics.txt

```

### Options

```
-h, --help help for sync
--license string set offline license file
--no-migrate Disable auto-migration before sync. By default, sync runs a migration before syncing resources.
--summary-location string Sync summary file location. This feature is in Preview. Please provide feedback to help us improve it.
-h, --help help for sync
--license string set offline license file
--no-migrate Disable auto-migration before sync. By default, sync runs a migration before syncing resources.
--summary-location string Sync summary file location. This feature is in Preview. Please provide feedback to help us improve it.
--tables-metrics-location string Tables metrics file location. This feature is in Preview. Please provide feedback to help us improve it.
```

### Options inherited from parent commands
Expand Down