-
Notifications
You must be signed in to change notification settings - Fork 365
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
[FEAT] Add integration with huggingface_hub.utils.telemetry
#5218
[FEAT] Add integration with huggingface_hub.utils.telemetry
#5218
Conversation
@dvsrepo added some initial work, still in progress but added you more so you could keep track. |
…ent),` instead of direct `_TELEMETRY_CLIENT` import
Looks good, just left two small comments! |
…ssend_telemetry-to-the-argilla-server
for workspace in workspaces: | ||
await telemetry_client.track_crud_workspace(action="read", workspace=workspace) | ||
await telemetry_client.track_crud_workspace(action="read", workspace=None, count=len(workspaces)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand these lines. For other list endpoints we just track the resource count, but here we track also the workspaces individually. What's the motivation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@frascuchon It is to keep track of list like operations but not differentiate too much in the naming CRUD. If you think it is interesting for development, I will create a separate "list" action. Otherwise, I will leave it. I think the individual calls and list-like I forgot unintentionally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reviewed the code and see I did keep track of the list-like thing in other places too.
for field in dataset.fields: | ||
await telemetry_client.track_crud_dataset_setting( | ||
action="read", dataset=dataset, setting_name="fields", setting=field | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know how these telemetry requests are done? Are they synchronous? UDP?
We should check that we are not spending a lot of time executing these requests so we are not adding additional time to the API endpoint requests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jfcalvo underlying code can be found here. https://github.com/huggingface/huggingface_hub/blob/main/src/huggingface_hub/utils/_telemetry.py
action = "create" | ||
if await Suggestion.get_by(db, record_id=record_id, question_id=suggestion_create.question_id): | ||
response.status_code = status.HTTP_200_OK | ||
action = "update" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can have an upsert
action so you don't need to add logic trying to know if it's a create
or an update
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can also rename it to "upsert" but I wanted to avoid capturing all edge cases "publish", "search", "read", "list" "upsert" "update" because I thought it might be a bit much for metrics/telemetry. @frascuchon @jfcalvo if you feel it would help development, I can make a finer distinguishment.
rafactor: add "me" to user operations refactor: add "list" to like-like operations
context = self._system_info.copy() | ||
user_agent.update(self._system_info) | ||
if count is not None: | ||
user_agent["count"] = count |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the meaning of count
and what is used for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Count is used for list operations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just send it as part of the data
content for those actions measuring list?
# Description <!-- Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change. --> This PR adds a middleware component to track the API endpoint's usage. **Type of change** <!-- Please delete options that are not relevant. Remember to title the PR according to the type of change --> - New feature (non-breaking change which adds functionality) - Refactor (change restructuring the codebase without changing functionality) - Improvement (change adding some improvement to an existing functionality) **How Has This Been Tested** <!-- Please add some reference about how your feature has been tested. --> **Checklist** <!-- Please go over the list and make sure you've taken everything into account --> - I added relevant documentation - I followed the style guidelines of this project - I did a self-review of my code - I made corresponding changes to the documentation - I confirm My changes generate no new warnings - I have added tests that prove my fix is effective or that my feature works - I have added relevant notes to the CHANGELOG.md file (See https://keepachangelog.com/) --------- Co-authored-by: José Francisco Calvo <jose@argilla.io>
…ssend_telemetry-to-the-argilla-server
…5445) # Description <!-- Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change. --> This PR restores the server_id for telemetry purposes and also add the user.id and user.role when tracking API requests. **Type of change** <!-- Please delete options that are not relevant. Remember to title the PR according to the type of change --> - Improvement (change adding some improvement to an existing functionality) - Documentation update **How Has This Been Tested** <!-- Please add some reference about how your feature has been tested. --> **Checklist** <!-- Please go over the list and make sure you've taken everything into account --> - I added relevant documentation - I followed the style guidelines of this project - I did a self-review of my code - I made corresponding changes to the documentation - I confirm My changes generate no new warnings - I have added tests that prove my fix is effective or that my feature works - I have added relevant notes to the CHANGELOG.md file (See https://keepachangelog.com/)
# Description <!-- Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change. --> This PR adds the track startup method defined in #5441 and include perstitent_storaged_enbled info as part of the system info **Type of change** <!-- Please delete options that are not relevant. Remember to title the PR according to the type of change --> - Improvement (change adding some improvement to an existing functionality) **How Has This Been Tested** <!-- Please add some reference about how your feature has been tested. --> **Checklist** <!-- Please go over the list and make sure you've taken everything into account --> - I added relevant documentation - I followed the style guidelines of this project - I did a self-review of my code - I made corresponding changes to the documentation - I confirm My changes generate no new warnings - I have added tests that prove my fix is effective or that my feature works - I have added relevant notes to the CHANGELOG.md file (See https://keepachangelog.com/)
huggingface_hub.utils.telemetry
huggingface_hub.utils.telemetry
Description
This PR adds changes to the server telemetry to gather metrics for API endpoint calls. This is the first iteration. Some new usage metrics can be included.
The metrics gathered include the user ID and some system info as the server ID (UUID generated once when starting the Argilla server)
Also, it deprecates the old telemetry KEY ("huggingface_hub includes an helper to send telemetry data. This information helps us debug issues and prioritize new features. Users can disable telemetry collection at any time by setting the HF_HUB_DISABLE_TELEMETRY=1 environment variable. Telemetry is also disabled in offline mode (i.e. when setting HF_HUB_OFFLINE=1)."
OUTDATED
Adds telemetry for:
General Idea:
I’ve structured data to come in through URLs/topics like
dataset/settings/vectorsettings/create
ordateset/records/suggestions/read
along with some generalized metadata per URL/topics, likecount
ortype
of suggestion or setting.To discuss:
list
methods. I currently tracklist-like
and send each individual withread
, along with aread
with a count. I did this because it might be interesting to get the total number of users, workspaces etc. Should we move this over tolist
as a separate CRUD action? Do we also want to capture each individual updatebulk_crud
as separate CRUD actions?header
along withuser/login
operations? otherwise I will rewrite this a bit and include theuser/login
asuser/read
.Follow up
FastAPI
endpoint metrics totelemetry
#5224 @frascuchon_Closes #5204
Type of change
How Has This Been Tested
NA
Checklist