-
Notifications
You must be signed in to change notification settings - Fork 93
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
Add [default] option to default the project_id label for exemplars #449
base: main
Are you sure you want to change the base?
Conversation
@@ -170,6 +170,12 @@ type ExporterOpts struct { | |||
Location string | |||
Cluster string | |||
|
|||
// If true, automatically populate the project id in an exemplar labelset. | |||
PopulateExemplarProjectID bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say let's avoid bools flag. They are not flexible and scalable. What about empty ExemplarProjectID
stopping this to populate that extra label?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the semantics of this would get confusing since this is supposed to be both overridable and disableable.
An empty ExemplarProjectID
seems to make sense as the case where you would not autopopulate the project_id
, but not passing something in seems to imply that it is the default state which is not what we want. We want the default state to be to autopopulate the exemplar projectID.
Unless you mean empty as in the literal empty string (""
) which also seems to be semantically confusing.
I'll defer to you, @pintohutch and @lyanco on this one.
pkg/export/setup/setup.go
Outdated
@@ -133,6 +133,12 @@ func FromFlags(a *kingpin.Application, userAgentProduct string) func(log.Logger, | |||
a.Flag("export.label.project-id", fmt.Sprintf("Default project ID set for all exported data. Prefer setting the external label %q in the Prometheus configuration if not using the auto-discovered default.", export.KeyProjectID)). | |||
Default(opts.ProjectID).StringVar(&opts.ProjectID) | |||
|
|||
a.Flag("export.exemplars.populate-exemplar-project-id", "If true, automatically populate the 'project_id' label in an exemplar labelset."). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, proposed a small simplification of UX, otherwise good 👍🏽
This PR allows some defaulting logic for the label project_id for exemplars. This is so users only have to supply a span_id and trace_id for traces to be compatible with Cloud Trace since Cloud Trace traces need a spanID, traceID, and projectID that is stored as a SpanContext. See https://cloud.google.com/trace/docs/setup#create-exemplars
If
export.exemplars.populate-exemplar-project-id
is explicitly set to false, then we will not auto-populate project_id, but the user can still explicitly attach the label to the exemplar if they choose. This will happen regardless of whether or notexport.exemplars.project-id
is set.If
export.exemplars.project-id
is set ANDexport.exemplars.populate-exemplar-project-id
is set to true (the default value) then we will auto-populate project_id with what they supplied.If
export.exemplars.populate-exemplar-project-id
is set to true andexport.exemplars.project-id
is not supplied, then we will use the user's projectId that they are sending metrics to. This will be the default state if nothing is done by the user.If the user ever explicitly provides project_id in the
LabelSet
of an exemplar, then we will always use the provided value here, regardless of the new options.