Skip to content
Closed
Changes from 1 commit
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
8 changes: 8 additions & 0 deletions source/extensions/filters/http/peer_metadata/filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,14 @@ void FilterConfig::discover(StreamInfo::StreamInfo& info, bool downstream, Http:
const auto result = method->derivePeerInfo(info, headers, ctx);
if (result) {
setFilterState(info, downstream, *result);
// For waypoint case, set dynamic metadata with SOURCE workload name for tracing
// ONLY set for downstream (client) discovery - not upstream (destination).
if (downstream && !result->workload_name_.empty()) {
Copy link
Member

Choose a reason for hiding this comment

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

Is there any reasonable way to expose all the info? Its kind of annoying to just have a subset.

In particular, the 'workload' may be useless info without 'source namespace' as well?

Copy link
Member

Choose a reason for hiding this comment

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

is it already in filter state? with istio/api#3600 can we access it?

Copy link
Author

Choose a reason for hiding this comment

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

Thanks @howardjohn! istio/api#3600 would help if Envoy's CustomTag supported formatters, but it currently only reads from dynamic metadata (CustomTag_Metadata), not filter state. Updated the PR to expose all peer metadata fields.

Copy link
Member

Choose a reason for hiding this comment

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

value
(string) Custom tag value.

The same format specifier as used for HTTP access logging applies here, however unknown specifier values are replaced with the empty string instead of -.

Used to specify what kind of custom tag.

which allows %FILTER_STATE(KEY:F:FIELD?):Z%

seems like it could work? I haven't tried

(I read the API 3 times and didn't realize this was possible until now)

Copy link
Author

Choose a reason for hiding this comment

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

thanks John, closing the PR as there is no need for the proxy change. (and wow!)

google::protobuf::Struct metadata_struct;
(*metadata_struct.mutable_fields())["source_workload"].set_string_value(
result->workload_name_);
info.setDynamicMetadata("envoy.filters.http.peer_metadata", metadata_struct);
}
break;
}
}
Expand Down