Skip to content

Conversation

Copy link

Copilot AI commented Jan 8, 2026

The README documented a --prefix argument for setting the directory prefix for parquet files, but the flag was removed from the CLI implementation.

Changes

  • Added prefix field to options struct
  • Registered --prefix flag in rootCmd with empty string default
  • Updated prefix resolution logic in sendTimeseries:
    • Uses prom2parquet_prefix label if present
    • Falls back to CLI --prefix if label absent/empty
    • Uses metric name only if both are empty

Behavior

// Priority order for prefix determination:
// 1. prom2parquet_prefix label value (if present and non-empty)
// 2. CLI --prefix argument (if provided)
// 3. No prefix (metric name only)

channelName := prefix + "/" + nameLabel.Value
if prefix == "" {
    channelName = nameLabel.Value
}

The implementation maintains backward compatibility for existing deployments using the label-based approach while restoring the documented CLI functionality.

Original prompt

The README mentions --prefix agrument which is no longer there, restore it and make it work as described.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Restore and implement --prefix argument functionality Restore --prefix CLI argument Jan 8, 2026
Copilot AI requested a review from xDarksome January 8, 2026 12:02
@xDarksome xDarksome marked this pull request as ready for review January 8, 2026 13:16
Copilot AI review requested due to automatic review settings January 8, 2026 13:16
@xDarksome xDarksome merged commit 1fee3c3 into master Jan 8, 2026
10 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR restores the documented --prefix CLI argument that was missing from the implementation. The --prefix flag allows users to set a directory prefix for parquet files via the command line, complementing the existing label-based approach (prom2parquet_prefix label).

Key Changes

  • Added prefix field to the options struct to store the CLI argument value
  • Registered the --prefix flag in the root command with an empty string default
  • Updated prefix resolution logic to prioritize label-based prefix over CLI prefix, with fallback to no prefix

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
cmd/args.go Added prefix field to options struct to store CLI argument
cmd/root.go Registered --prefix flag with appropriate help text and default value
cmd/server.go Updated sendTimeseries to use label prefix first, then CLI prefix, then no prefix
cmd/server_test.go Added tests for CLI prefix usage and no-prefix scenarios
.gitignore Added build directory to ignore list

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +125 to +189
func TestSendTimeseriesWithCLIPrefix(t *testing.T) {
cliPrefix := "cli-prefix"
srv := newServer(&options{prefix: cliPrefix})
expectedChannelName := cliPrefix + "/" + metricName
srv.channels[expectedChannelName] = make(chan prompb.TimeSeries)

ts := prompb.TimeSeries{
Labels: []prompb.Label{
{
Name: model.MetricNameLabel,
Value: metricName,
},
{
Name: "foo",
Value: "bar",
},
},
Samples: []prompb.Sample{
{
Value: 1.0,
Timestamp: 0,
},
},
}

go func() {
err := srv.sendTimeseries(context.TODO(), []prompb.TimeSeries{ts})
assert.Nil(t, err)
}()

val := <-srv.channels[expectedChannelName]
assert.Equal(t, ts, val)
}

func TestSendTimeseriesWithoutPrefix(t *testing.T) {
srv := newServer(&options{})
srv.channels[metricName] = make(chan prompb.TimeSeries)

ts := prompb.TimeSeries{
Labels: []prompb.Label{
{
Name: model.MetricNameLabel,
Value: metricName,
},
{
Name: "foo",
Value: "bar",
},
},
Samples: []prompb.Sample{
{
Value: 1.0,
Timestamp: 0,
},
},
}

go func() {
err := srv.sendTimeseries(context.TODO(), []prompb.TimeSeries{ts})
assert.Nil(t, err)
}()

val := <-srv.channels[metricName]
assert.Equal(t, ts, val)
}
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

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

Missing test case for label priority: The implementation correctly prioritizes the prom2parquet_prefix label over the CLI --prefix argument (lines 122-125 in server.go), but there is no test verifying this behavior. Consider adding a test case that provides both a CLI prefix and a label prefix to ensure the label takes precedence as documented.

Copilot uses AI. Check for mistakes.
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