-
Notifications
You must be signed in to change notification settings - Fork 2
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 traceparent header support #81
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -110,6 +110,12 @@ func Provider() *schema.Provider { | |||||
Optional: true, | ||||||
Description: "ID of an Observe object that serves as the parent (managing) object for all resources created by the provider (internal use).", | ||||||
}, | ||||||
"traceparent": { | ||||||
Type: schema.TypeString, | ||||||
DefaultFunc: schema.EnvDefaultFunc("W3C_TRACEPARENT", nil), | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I'm unable to find any cases where this is used as a configuration input (versus just internally to the code): https://github.com/search?q=%22W3C_TRACEPARENT%22&type=code&p=1 I did find this: |
||||||
Optional: true, | ||||||
Description: "Optional traceparent identifie.", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
}, | ||||||
}, | ||||||
|
||||||
DataSourcesMap: map[string]*schema.Resource{ | ||||||
|
@@ -247,6 +253,11 @@ func getConfigureContextFunc(userAgent func() string) schema.ConfigureContextFun | |||||
config.ManagingObjectID = &managingId | ||||||
} | ||||||
|
||||||
if v, ok := data.GetOk("traceparent"); ok { | ||||||
traceparent := v.(string) | ||||||
config.TraceParent = &traceparent | ||||||
} | ||||||
|
||||||
// by omission, cache client | ||||||
useCache := true | ||||||
if v, ok := config.Flags[flagCacheClient]; ok { | ||||||
|
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.
Wondering whether it's worth adding validation to this field, since traceparent is not just an opaque ID and instead has multiple well-structured parts:
https://www.w3.org/TR/trace-context/#traceparent-header-field-values
The RFC says multiple times that "vendors MUST ignore" the traceparent if any of the fields are invalid.
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.
Thought about this, and leaned against adding validation. Mainly as we are just passing the context through to the server. And the extract logic on the server does validate and ignore if the fields are invalid (essentially starts a new trace).
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.
If it's exposed to users I tend to think more validation is better if it can turn a silent failure into an explicit error. By not officially exposing the option to users that safety/predictability imperative largely goes away. So 👍🏻 to no validation in combo with the move to env only.