Skip to content

Conversation

@timgrein
Copy link
Contributor

Many systems at Elastic forward their "product origin" (usually the name of the system itself) throughout a specific HTTP header, namely X-Elastic-Product-Origin. It makes sense to also have this metadata on EIS to add it as metadata to the usage API calls and/or to APM attributes for better insights/traceability.

I've implemented it in a way that each new subclass of ElasticInferenceServiceRequest (which we'll have as soon as we support new task types) doesn't need to explicitly add the header to reduce the risk of us forgetting it.

@timgrein timgrein added >non-issue :ml Machine learning Team:ML Meta label for the ML team v9.1.0 labels Feb 21, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/ml-core (Team:ML)

@Override
public final HttpRequest createHttpRequest() {
HttpRequestBase request = createHttpRequestBase();
// TODO: consider moving tracing here, too
Copy link
Contributor Author

@timgrein timgrein Feb 21, 2025

Choose a reason for hiding this comment

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

Wanted to keep it out of scope for this PR, but I think it also makes sense to move the tracing logic here, so we don't risk forgetting it for new subclasses of ElasticInferenceServiceRequest.

}

@Override
public final HttpRequest createHttpRequest() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made this final so it's clear that a new subclass of ElasticInferenceServiceRequest should override createHttpRequestBase and not createHttpRequest.

public final HttpRequest createHttpRequest() {
HttpRequestBase request = createHttpRequestBase();
// TODO: consider moving tracing here, too
request.setHeader(Task.X_ELASTIC_PRODUCT_ORIGIN_HTTP_HEADER, productOrigin);
Copy link
Member

Choose a reason for hiding this comment

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

Is productOrigin null if it isn't present in the inbound header? I can't tell if defaultHeaders would include a default productOrigin, but if it doesn't we may want to either omit the header or send something like "Unknown"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we don't really need to care as EIS handles the case, if this header is absent and/or empty and sets unknown if so. I would like to simply treat this as a forwarding logic without looking into the value.

@timgrein timgrein merged commit 08aa668 into elastic:main Mar 3, 2025
17 checks passed
@timgrein
Copy link
Contributor Author

timgrein commented Mar 4, 2025

💚 All backports created successfully

Status Branch Result
8.x

Questions ?

Please refer to the Backport tool documentation

timgrein added a commit to timgrein/elasticsearch that referenced this pull request Mar 4, 2025
…lasticInferenceServiceRequest (elastic#123141)

(cherry picked from commit 08aa668)
timgrein added a commit that referenced this pull request Mar 4, 2025
georgewallace pushed a commit to georgewallace/elasticsearch that referenced this pull request Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:ml Machine learning >non-issue Team:ML Meta label for the ML team v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants