Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add flag categories #260

Merged
merged 2 commits into from
May 22, 2024
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
26 changes: 16 additions & 10 deletions log.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,29 @@ const (
FlagLogCtx = "log.ctx"
)

// CategoryLog is the log flag category.
var CategoryLog = "Logging"

// LogFlags are flags that configure logging.
var LogFlags = Flags{
&cli.StringFlag{
Name: FlagLogFormat,
Usage: "Specify the format of logs. Supported formats: 'logfmt', 'json', 'console'",
EnvVars: []string{"LOG_FORMAT"},
Name: FlagLogFormat,
Category: CategoryLog,
Usage: "Specify the format of logs. Supported formats: 'logfmt', 'json', 'console'",
EnvVars: []string{"LOG_FORMAT"},
},
&cli.StringFlag{
Name: FlagLogLevel,
Value: "info",
Usage: "Specify the log level. e.g. 'trace', 'debug', 'info', 'error'.",
EnvVars: []string{"LOG_LEVEL"},
Name: FlagLogLevel,
Category: CategoryLog,
Value: "info",
Usage: "Specify the log level. e.g. 'trace', 'debug', 'info', 'error'.",
EnvVars: []string{"LOG_LEVEL"},
},
&cli.StringSliceFlag{
Name: FlagLogCtx,
Usage: "A list of context field appended to every log. Format: key=value.",
EnvVars: []string{"LOG_CTX"},
Name: FlagLogCtx,
Category: CategoryLog,
Usage: "A list of context field appended to every log. Format: key=value.",
EnvVars: []string{"LOG_CTX"},
},
}

Expand Down
29 changes: 18 additions & 11 deletions profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,36 @@ const (
FlagProfilingTypes = "profiling.types"
)

// CategoryProfiling is the profiling category.
var CategoryProfiling = "Profiling"

// ProfilingFlags are flags that configure profiling.
var ProfilingFlags = Flags{
&cli.StringFlag{
Name: FlagProfilingDSN,
Name: FlagProfilingDSN,
Category: CategoryProfiling,
Usage: "The address to the Pyroscope server, in the format " +
"'http://basic:auth@server:port?token=auth-token&tenantid=tenant-id'.",
EnvVars: []string{"PROFILING_DSN"},
},
&cli.DurationFlag{
Name: FlagProfileUploadRate,
Usage: "The rate at which profiles are uploaded.",
Value: 15 * time.Second,
EnvVars: []string{"PROFILING_UPLOAD_RATE"},
Name: FlagProfileUploadRate,
Category: CategoryProfiling,
Usage: "The rate at which profiles are uploaded.",
Value: 15 * time.Second,
EnvVars: []string{"PROFILING_UPLOAD_RATE"},
},
&cli.StringSliceFlag{
Name: FlagProfilingTags,
Usage: "A list of tags appended to every profile. Format: key=value.",
EnvVars: []string{"PROFILING_TAGS"},
Name: FlagProfilingTags,
Category: CategoryProfiling,
Usage: "A list of tags appended to every profile. Format: key=value.",
EnvVars: []string{"PROFILING_TAGS"},
},
&cli.StringSliceFlag{
Name: FlagProfilingTypes,
Usage: "The type of profiles to include. Defaults to all.",
EnvVars: []string{"PROFILING_TYPES"},
Name: FlagProfilingTypes,
Category: CategoryProfiling,
Usage: "The type of profiles to include. Defaults to all.",
EnvVars: []string{"PROFILING_TYPES"},
},
}

Expand Down
33 changes: 20 additions & 13 deletions stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,35 @@ const (
FlagStatsTags = "stats.tags"
)

// CategoryStats is the stats flag category.
var CategoryStats = "Stats"

// StatsFlags are flags that configure stats.
var StatsFlags = Flags{
&cli.StringFlag{
Name: FlagStatsDSN,
Usage: "The DSN of a stats backend.",
EnvVars: []string{"STATS_DSN"},
Name: FlagStatsDSN,
Category: CategoryStats,
Usage: "The DSN of a stats backend.",
EnvVars: []string{"STATS_DSN"},
},
&cli.DurationFlag{
Name: FlagStatsInterval,
Usage: "The frequency at which the stats are reported.",
Value: time.Second,
EnvVars: []string{"STATS_INTERVAL"},
Name: FlagStatsInterval,
Category: CategoryStats,
Usage: "The frequency at which the stats are reported.",
Value: time.Second,
EnvVars: []string{"STATS_INTERVAL"},
},
&cli.StringFlag{
Name: FlagStatsPrefix,
Usage: "The prefix of the measurements names.",
EnvVars: []string{"STATS_PREFIX"},
Name: FlagStatsPrefix,
Category: CategoryStats,
Usage: "The prefix of the measurements names.",
EnvVars: []string{"STATS_PREFIX"},
},
&cli.StringSliceFlag{
Name: FlagStatsTags,
Usage: "A list of tags appended to every measurement. Format: key=value.",
EnvVars: []string{"STATS_TAGS"},
Name: FlagStatsTags,
Category: CategoryStats,
Usage: "A list of tags appended to every measurement. Format: key=value.",
EnvVars: []string{"STATS_TAGS"},
},
}

Expand Down
47 changes: 28 additions & 19 deletions trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,38 +26,47 @@ const (
FlagTracingRatio = "tracing.ratio"
)

// CategoryTracing is the tracing flag category.
var CategoryTracing = "Tracing"

// TracingFlags are flags that configure tracing.
var TracingFlags = Flags{
&cli.StringFlag{
Name: FlagTracingExporter,
Usage: "The tracing backend. Supported: 'zipkin', 'otlphttp', 'otlpgrpc'.",
EnvVars: []string{"TRACING_EXPORTER"},
Name: FlagTracingExporter,
Category: CategoryTracing,
Usage: "The tracing backend. Supported: 'zipkin', 'otlphttp', 'otlpgrpc'.",
EnvVars: []string{"TRACING_EXPORTER"},
},
&cli.StringFlag{
Name: FlagTracingEndpoint,
Usage: "The tracing backend endpoint.",
EnvVars: []string{"TRACING_ENDPOINT"},
Name: FlagTracingEndpoint,
Category: CategoryTracing,
Usage: "The tracing backend endpoint.",
EnvVars: []string{"TRACING_ENDPOINT"},
},
&cli.BoolFlag{
Name: FlagTracingEndpointInsecure,
Usage: "Determines if the endpoint is insecure.",
EnvVars: []string{"TRACING_ENDPOINT_INSECURE"},
Name: FlagTracingEndpointInsecure,
Category: CategoryTracing,
Usage: "Determines if the endpoint is insecure.",
EnvVars: []string{"TRACING_ENDPOINT_INSECURE"},
},
&cli.StringSliceFlag{
Name: FlagTracingTags,
Usage: "A list of tags appended to every trace. Format: key=value.",
EnvVars: []string{"TRACING_TAGS"},
Name: FlagTracingTags,
Category: CategoryTracing,
Usage: "A list of tags appended to every trace. Format: key=value.",
EnvVars: []string{"TRACING_TAGS"},
},
&cli.StringSliceFlag{
Name: FlagTracingHeaders,
Usage: "A list of headers appended to every trace when supported by the exporter. Format: key=value.",
EnvVars: []string{"TRACING_HEADERS"},
Name: FlagTracingHeaders,
Category: CategoryTracing,
Usage: "A list of headers appended to every trace when supported by the exporter. Format: key=value.",
EnvVars: []string{"TRACING_HEADERS"},
},
&cli.Float64Flag{
Name: FlagTracingRatio,
Usage: "The ratio between 0 and 1 of sample traces to take.",
Value: 0.5,
EnvVars: []string{"TRACING_RATIO"},
Name: FlagTracingRatio,
Category: CategoryTracing,
Usage: "The ratio between 0 and 1 of sample traces to take.",
Value: 0.5,
EnvVars: []string{"TRACING_RATIO"},
},
}

Expand Down
Loading