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

Adding baggage api #3

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Adding baggage api #3

wants to merge 3 commits into from

Conversation

nikhil1511
Copy link
Owner

@nikhil1511 nikhil1511 commented Apr 15, 2021

Fixes

  • Adding baggage implementation
  • Adding unit tests
  • Fixing pragma once bug in kv_properties

For significant contributions please make sure you have completed the following items:

  • CHANGELOG.md updated for non-trivial changes
  • Unit tests have been added
  • Changes in public API reviewed

/* Returns shared_ptr of new baggage object which contains new key-value pair. If key or value is
invalid, copy of current baggage is returned
*/
nostd::shared_ptr<Baggage> Set(const nostd::string_view &key, const nostd::string_view &value)

Choose a reason for hiding this comment

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

Wouldn't it be better to check validity of kv pair first? If not valid, then this copying can be avoided or may be i am missing something from ot specs here.

Copy link
Owner Author

@nikhil1511 nikhil1511 Apr 16, 2021

Choose a reason for hiding this comment

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

Let me think through this. Ideally, we return copy everytime but we might return same copy in case keys do not change.

Copy link
Owner Author

@nikhil1511 nikhil1511 Apr 16, 2021

Choose a reason for hiding this comment

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

I am planning to keep it as it is for now. We are copying in all other cases anyway and so I am not keen on handling this edge case separately. Lets see what other think in main repo.

: kv_properties_(new opentelemetry::common::KeyValueProperties(keys_and_values))
{}

static nostd::shared_ptr<Baggage> GetDefault()

Choose a reason for hiding this comment

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

Does spec talk about baggage having a singleton interface for default cases?

Copy link
Owner Author

Choose a reason for hiding this comment

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

No it doesnt talk about it. We had similar thing in trace_state and so I went ahead with it.

nostd::shared_ptr<Baggage> Delete(const nostd::string_view &key)
{
// keeping size of baggage same as key might not be found in it
nostd::shared_ptr<Baggage> baggage(new Baggage(kv_properties_->Size()));

Choose a reason for hiding this comment

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

If key to be deleted is found then size of baggage is one more than the no of keys. isn`t that a bug?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Its just an upper bound on the number of pairs. Not much of worry. We must make sure that size is not less than the actual size.

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.

3 participants