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

feat: Add the parsing of HF_HUB_USER_AGENT_ORIGIN environment variable for telemetry #3027

Merged
merged 2 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion .github/workflows/trufflehog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ jobs:
- name: Secret Scanning
uses: trufflesecurity/trufflehog@main
with:
extra_args: --results=verified,unknown
# exclude buggy postgres detector that is causing false positives and not relevant to our codebase
extra_args: --results=verified,unknown --exclude-detectors=postgres
3 changes: 3 additions & 0 deletions router/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1877,6 +1877,8 @@ pub async fn run(

// Only send usage stats when TGI is run in container and the function returns Some
let is_container = matches!(usage_stats::is_container(), Ok(true));
// retrieve the huggingface_hub user agent origin if set, and add the origin to telemetry
let origin = std::env::var("HF_HUB_USER_AGENT_ORIGIN").ok();
let user_agent = match (usage_stats_level, is_container) {
(usage_stats::UsageStatsLevel::On | usage_stats::UsageStatsLevel::NoStack, true) => {
let reduced_args = usage_stats::Args::new(
Expand All @@ -1899,6 +1901,7 @@ pub async fn run(
max_client_batch_size,
usage_stats_level,
backend.name(),
origin,
);
Some(usage_stats::UserAgent::new(reduced_args))
}
Expand Down
3 changes: 3 additions & 0 deletions router/src/usage_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ pub struct Args {
max_client_batch_size: usize,
usage_stats_level: UsageStatsLevel,
backend_name: &'static str,
origin: Option<String>,
}

impl Args {
Expand All @@ -122,6 +123,7 @@ impl Args {
max_client_batch_size: usize,
usage_stats_level: UsageStatsLevel,
backend_name: &'static str,
origin: Option<String>,
) -> Self {
Self {
model_config,
Expand All @@ -143,6 +145,7 @@ impl Args {
max_client_batch_size,
usage_stats_level,
backend_name,
origin,
}
}
}
Expand Down
Loading