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

[PRW-2.0] New config surface allowing content-type and encoding preferences for both sending and receiving. #13968

Draft
wants to merge 1 commit into
base: remote-write-2.0
Choose a base branch
from

Conversation

bwplotka
Copy link
Member

TODO(bwplotka):

…ces for both sending and receiving.

Signed-off-by: bwplotka <bwplotka@gmail.com>
@bwplotka bwplotka changed the title [PRW-2.0] Changed the configuration allowing content-type and encoding preferences for both sending and receiving (updated content neg.) [PRW-2.0] New config surface allowing content-type and encoding preferences for both sending and receiving. Apr 22, 2024
Comment on lines 312 to +320
a.Flag("web.enable-remote-write-receiver", "Enable API endpoint accepting remote write requests.").
Default("false").BoolVar(&cfg.web.EnableRemoteWriteReceiver)

a.Flag("web.remote-write-receiver.protobuf-types", fmt.Sprintf("List of accepted remote write 2.0 content types to advertise to senders, ordered by the preference. Note that the final decision is on the sender. Supported list values: %v", config.DefaultRemoteWriteProtoTypes.String())).
Default(config.DefaultRemoteWriteProtoTypes.Strings()...).SetValue(rwProtoTypeFlagValue(&cfg.web.RemoteWriteReceiverProtoTypes))

a.Flag("web.remote-write-receiver.compressions", fmt.Sprintf("List of accepted remote write 2.0 content encodings (compressions) to advertise to senders, ordered by the preference. Note that the final decision is on the sender. Supported list values: %v", config.DefaultRemoteWriteCompressions.String())).
Default(config.DefaultRemoteWriteCompressions.Strings()...).SetValue(rwCompressionFlagValue(&cfg.web.RemoteWriteReceiverCompressions))

Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we can make a case for moving all of this, including the flag to enable the receiver, to the config file

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice, totally possible. But it's hard to do in our feature - it's too many changes.

Perhaps NOT exposing any flags for now and adding TODO + issue would be fine for now?

// TODO(bwplotka): Consider an util for "preference enums" as it's similar code for rw compression, proto type and scrape protocol.

// RemoteWriteProtoType represents the supported protobuf types for the remote write.
type RemoteWriteProtoType string
Copy link
Member

Choose a reason for hiding this comment

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

ProtoType feels awkward, can we call it RemoteWriteProtoVersion ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried ProtoMessages, ProtoVersion etc but they might be worse options.

ProtoVersion feels like Protocol Version, so spec version? But it represent protobuf type, to in short prototype, not protocol version and I want to make it explicit. Or do you think ProtoVersion would not mislead?

Perhaps RemoteWriteProtobufType would be better?

Copy link
Member

Choose a reason for hiding this comment

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

RemoteWriteProtobufType or RemoteWriteProtobufVersion, or maybe RemoteWriteWireType/Format/Version since we've discussed implementing and allow usage of something like Arrow in the future?

// ServerAcceptEncodingHeaderValue returns server Accept-Encoding header value for
// given list of compressions as per RFC 9110 https://www.rfc-editor.org/rfc/rfc9110.html#name-accept-encoding
func (cs RemoteWriteCompressions) ServerAcceptEncodingHeaderValue() string {
// TODO(bwplotka): Consider implementing an optional quality factor.
Copy link
Member

Choose a reason for hiding this comment

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

by not doing so yet we're just interpreting the order as the preference ordering, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, which is part of RFC 9110 spec, q is optional and allow to tell "weight" of the ordering.

contentEncoding := r.Header.Get("Content-Encoding")
protoVer := r.Header.Get(RemoteWriteVersionHeader)
func (h *writeHandler) parseType(contentType string) (config.RemoteWriteProtoType, error) {
// TODO(bwplotka): TBD
Copy link
Member

Choose a reason for hiding this comment

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

?

Copy link
Member Author

Choose a reason for hiding this comment

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

I gave up and figured out we need HTTP util pkg for preferences (: TBD, IF we want to go this way (Accet + Accept-Encoding)

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.

None yet

2 participants