Skip to content

Tracing: allow proper tracing for ratelimit calls from Envoy#486

Merged
RomanDzhabarov merged 9 commits intomasterfrom
rate_limit_header
Feb 16, 2017
Merged

Tracing: allow proper tracing for ratelimit calls from Envoy#486
RomanDzhabarov merged 9 commits intomasterfrom
rate_limit_header

Conversation

@RomanDzhabarov
Copy link
Copy Markdown
Member

@RomanDzhabarov RomanDzhabarov commented Feb 15, 2017

@lyft/network-team

This is to propagate x-ot-span-context on calls to ratelimit, so ingress Envoy on ratelimit service can set proper parent for the span.

virtual void limit(RequestCallbacks& callbacks, const std::string& domain,
const std::vector<Descriptor>& descriptors,
const std::string& request_id) PURE;
const std::vector<Descriptor>& descriptors, const std::string& request_id,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Instead of adding another param, I think at this point it would be better to make something like:

struct TraceContext {
  std::string request_id_;
  std::string span_context_;
};

And pass a const TraceContext&

We may add other things in the future and this will end up being a lot cleaner.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Deal, I'll name that TransportContext and will place that in Tracing namespace

* @param descriptors specifies a list of descriptors to query.
* @param request_id propagates the request_id of the current request to the ratelimit service.
* @param context provides transport context so that upstream can construct proper relationship
* between
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

fix

@@ -1,3 +1,4 @@
#include <envoy/tracing/http_tracer.h>
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

fix


callbacks_->complete(status);
callbacks_ = nullptr;
request_id_.clear();
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this is not required as we set it on every limit request

* Transport tracing context.
* It's used to set proper parent/child span relationship on Envoy calls, e.g., ratelimit call.
*/
struct TransportContext {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this should go in a header not called http_tracer.h

config_->stats().total_.inc();
calling_limit_ = true;
client_->limit(*this, config_->domain(), config_->descriptors(), EMPTY_STRING);
client_->limit(*this, config_->domain(), config_->descriptors(), {EMPTY_STRING, EMPTY_STRING});
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

just {}

std::string request_id_;
std::string span_context_;

bool operator==(const Tracing::TransportContext& rhs) const {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

since this is only needed in test code, put the definition of operator== in a test header.

return lhs.entries_ == rhs.entries_;
}

inline bool operator()(const Tracing::TransportContext& lhs,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This goes in a file in the tracing namespace

config_->stats().total_.inc();
calling_limit_ = true;
client_->limit(*this, config_->domain(), config_->descriptors(), EMPTY_STRING);
client_->limit(*this, config_->domain(), config_->descriptors(), {"", ""});
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

{} should work, but either way, I should have commented on this before, define a static const empty context, and pass it here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yeah in this case for some reason that does not work, compiler complains about missing initializer for request_id and span_context_

@RomanDzhabarov RomanDzhabarov merged commit b2516d1 into master Feb 16, 2017
@RomanDzhabarov RomanDzhabarov deleted the rate_limit_header branch February 16, 2017 18:09
lizan pushed a commit to lizan/envoy that referenced this pull request Apr 24, 2020
fixes to filter state getters/setters
jpsim pushed a commit that referenced this pull request Nov 28, 2022
Pulls in the fix from #8467.

Signed-off-by: Michael Rebello <me@michaelrebello.com>
Signed-off-by: JP Simard <jp@jpsim.com>
jpsim pushed a commit that referenced this pull request Nov 29, 2022
Pulls in the fix from #8467.

Signed-off-by: Michael Rebello <me@michaelrebello.com>
Signed-off-by: JP Simard <jp@jpsim.com>
mathetake pushed a commit that referenced this pull request Mar 3, 2026
**Commit Message**

Content type should be able to be string so adding this for
compatibility. It's already done for the other types - keeping it
consistent.

---------

Signed-off-by: Aaron Choo <achoo30@bloomberg.net>
Co-authored-by: Dan Sun <dsun20@bloomberg.net>
mathetake pushed a commit that referenced this pull request Mar 3, 2026
…508)

**Commit Message**

AWS Claude 3.5 v1 has cases when assistant returns empty content.
Sending that back to AWS will result in a validation error. Will skip
adding empty content if string is empty.

```
openai.BadRequestError: Error code: 400 - {'type': 'error', 'error': {'type': 'ValidationException:http://internal.amazon.com/coral/com.amazon.bedrock/', 'code': '400', 'message': 'The text field in the ContentBlock object at messages.3.content.0 is blank. Add text to the text field, and try again.'}}
```


**Related Issues/PRs (if applicable)**
#486

Signed-off-by: Aaron Choo <achoo30@bloomberg.net>
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.

2 participants