Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

Stats core changes#256

Merged
liyanhui1228 merged 11 commits intocensus-instrumentation:masterfrom
CESARBR:stats_core_changes
Aug 28, 2018
Merged

Stats core changes#256
liyanhui1228 merged 11 commits intocensus-instrumentation:masterfrom
CESARBR:stats_core_changes

Conversation

@MarceloAquino7
Copy link
Copy Markdown
Contributor

This PR contains all changes inside stats core in order to support exporters and the new transport class.

@googlebot
Copy link
Copy Markdown

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again. If the bot doesn't comment, it means it doesn't think anything has changed.

@songy23
Copy link
Copy Markdown
Contributor

songy23 commented Aug 14, 2018

Please fix the CLA.

A quick fix would be to squash all the commits into one: (assume upstream is https://github.com/census-instrumentation/opencensus-python.git, and origin is your personal repo)

$ git fetch upstream
$ git rebase -i upstream/master
$ # In the rebase UI, pick the top one commit and mark all others as "squash" or "s". Save and exit.
$ # Resolve any potential merge conflicts.
$ # Should see: Successfully rebased and updated refs/heads/master.
$ git push -f origin

Removing stats exporter stuff

Removing unused imports

Minor changes in comments and copyright

Unit tests for LastValue aggregation
@googlebot
Copy link
Copy Markdown

CLAs look good, thanks!

@MarceloAquino7
Copy link
Copy Markdown
Contributor Author

@songy23 I think that everything is fine right now.

def _get_items(self):
"""Get multiple items from a Queue.

Gets at least one (blocking) and at most ``max_items`` items
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.

max_items isn't defined anywhere. Did we perhaps mean to use max_batch_size?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, it was a mistake inside the comment. I'll fix that, thanks !

Pulls pending data off the queue and writes them in
batches to the specified tracing backend using the exporter.
"""
print('Background thread started.')
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.

Perhaps this was a legacy print but it pollutes user programs, please remove it or perhaps make it a log that can be turned on

if quit_:
break

print('Background thread exited.')
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.

Ditto about prints polluting user code from the library.

thread some time to finish processing before this function returns.

:type grace_period: float
:param grace_period: If specified, this method will block up to this
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.

grace_period is mentioned as a param but I don't see it in the function signature.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Right now we are reading its value inside the constructor, so of course do not make sense this piece of comment. I'll remove it, thanks !

self._queue.put_nowait(datas)

def flush(self):
"""Submit any pending datas."""
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.

s/datas/data/g, data is the plural form of datum as per https://www.merriam-webster.com/dictionary/data :)

SUM (int): The aggreation type of the view is 'sum'.
COUNT (int): The aggreation type of the view is 'count'.
DISTRIBUTION (int): The aggreation type of the view is 'distribution'.
LASTVALUE (int): The aggreation type of the view is 'lastvalue'.
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.

Minor nit: s/aggreation/aggregation/g

Copy link
Copy Markdown
Member

@odeke-em odeke-em left a comment

Choose a reason for hiding this comment

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

Nice, thanks @MarceloAquino7! I'll wait for @liyanhui1228 to take a look too and I'll also give the entire PR a full read a few more times. Thanks for incorporating the changes for the transport into opencensus.common.transports.*

@odeke-em odeke-em requested a review from liyanhui1228 August 19, 2018 21:30
Copy link
Copy Markdown
Contributor

@liyanhui1228 liyanhui1228 left a comment

Choose a reason for hiding this comment

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

Mostly LGTM, just some style nits. And please also fix the test coverage.

"""
The current recorded value
"""
return self._value No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Need an extra blank line at the end of file.

"""
The current value recorded
"""
return self._value No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Need extra blank line.



class _Worker(object):
"""A background thread that exports batches of data.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The indentation of this file is different than other files in this repo, shall we change to use 4 spaces indentation to match with the repo?


For blocking/sync transports, this is a no-op.
"""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remove extra blank line.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your reply @liyanhui1228 , I will work on these items. About the test coverage, do you guys use 4 spaces for indentation ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes we use 4 spaces indentation.

@odeke-em
Copy link
Copy Markdown
Member

@liyanhui1228 they've updated the code with our requests, PTAL again :)

@MarceloAquino7 please rebase from master, as Github currently reports some conflicts with master.

@liyanhui1228
Copy link
Copy Markdown
Contributor

This LGTM, will approve once the CI is green.

@odeke-em
Copy link
Copy Markdown
Member

@liyanhui1228 oh cool, I've updated the branch and now CI is running, please check back in say 10 minutes for when CI returns.

@odeke-em
Copy link
Copy Markdown
Member

@liyanhui1228 for some reason CircleCI tripped claiming that the coverage for some test failed

nox > Command coverage report --show-missing --fail-under=100 failed with exit code 2

https://circleci.com/gh/census-instrumentation/opencensus-python/616?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link PTAL

@liyanhui1228
Copy link
Copy Markdown
Contributor

Yes we should add more test to fix that test coverage.

@songy23 songy23 mentioned this pull request Aug 25, 2018
'spans': [{}, {}],
}
transport.export(data)
self.assertTrue(True)
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.

What happened here?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants