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

[vcpkg] Use a tag file rather than conditional compilation to permanently disable metrics. #15470

Merged
merged 11 commits into from Jan 13, 2021

Conversation

BillyONeal
Copy link
Member

We want to ship a signed binary rather than having the user build vcpkg's binary, and it is better if we can use the same binary for all customers.

We can't use the existing environment variable solution because ./bootstrap -disableMetrics needs to make that bootstrapped vcpkg act as if metrics were never compiled in in the first place, but we can get the same effect by writing a tag file next to the binary which tells the binary to have that behavior.

Also adds e2e tests of the metrics setting.

@BillyONeal BillyONeal added category:vcpkg-feature The issue is a new capability of the tool that doesn’t already exist and we haven’t committed info:internal This PR or Issue was filed by the vcpkg team. labels Jan 6, 2021
@JackBoosY JackBoosY self-assigned this Jan 6, 2021
BillyONeal added a commit to microsoft/vcpkg-tool that referenced this pull request Jan 6, 2021
Write-Host $Script:CurrentTest
./vcpkg @testArgs
& "./$vcpkgName" @testArgs | Tee-Object -Variable 'ConsoleOutput'
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this redirects the output, it would be nice if this was combined with Throw-IfFailed/Throw-IfNotFailed and would print the output on unexpected return code.

Perhaps Run-Vcpkg and Run-Vcpkg-Fail? (I'd keep the name Run-Vcpkg for passing to minimize the impact on existing tests)

function Run-Vcpkg-Fail {
    # ...
    $out = Run-Vcpkg-Base $TestArgs
    if ($LASTEXITCODE -eq 0) {
        $out
        throw "..."
    }
    return $out
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Since this redirects the output

It redirects the output into Tee-Object so the output still goes to the screen too.

scripts/bootstrap.ps1 Outdated Show resolved Hide resolved
toolsrc/src/vcpkg.cpp Outdated Show resolved Hide resolved
toolsrc/CMakeLists.txt Show resolved Hide resolved
System::print2(System::Color::warning,
"Warning: passed either --printmetrics or --no-printmetrics, but metrics are disabled.\n");
}
auto metrics = Metrics::g_metrics.lock();
Copy link
Contributor

Choose a reason for hiding this comment

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

Taking this lock over a larger scope can be problematic because if any failures occur, we will attempt to recursively lock. This is because the exit-on-failure code will try to flush the metrics.

Copy link
Member Author

Choose a reason for hiding this comment

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

That is just as much a problem in the "before" code as the "after" code as in both cases the lock is held for the entirety of the contained calls.

…ics_define

# Conflicts:
#	scripts/bootstrap.ps1
toolsrc/src/vcpkg.cpp Outdated Show resolved Hide resolved
Comment on lines 260 to 268
{
System::print2(System::Color::warning,
"Warning: passed either --sendmetrics or --no-sendmetrics, but metrics are disabled.\n");
}

if (args.print_metrics.has_value() && !metrics->metrics_enabled())
{
System::print2(System::Color::warning,
"Warning: passed either --printmetrics or --no-printmetrics, but metrics are disabled.\n");
Copy link
Contributor

Choose a reason for hiding this comment

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

It doesn't make sense to me to warn for --no-printmetrics; I feel like these checks should be: !args.print_metrics.value_or(false).

Copy link
Member Author

Choose a reason for hiding this comment

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

tbh I don't think --no-printmetrics should exist since there's no world where we would want to print them by default.

Copy link
Contributor

Choose a reason for hiding this comment

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

this is fair, but it still should be true for --no-sendmetrics.

Co-authored-by: nicole mazzuca <mazzucan@outlook.com>
BillyONeal added a commit that referenced this pull request Jan 22, 2021
…PKG_DISABLE_METRICS (#15810)

* Restore x-upload-metrics command accidentally disabled by removing VCPKG_DISABLE_METRICS in #15470

* Didn't save a file.
BillyONeal added a commit to microsoft/vcpkg-tool that referenced this pull request Jan 26, 2021
…PKG_DISABLE_METRICS (#15810)

* Restore x-upload-metrics command accidentally disabled by removing VCPKG_DISABLE_METRICS in microsoft/vcpkg#15470

* Didn't save a file.
strega-nil pushed a commit to strega-nil/vcpkg that referenced this pull request May 5, 2021
Sungeun0318 pushed a commit to Sungeun0318/-vcpkg that referenced this pull request May 15, 2024
…PKG_DISABLE_METRICS (#15810)

* Restore x-upload-metrics command accidentally disabled by removing VCPKG_DISABLE_METRICS in microsoft/vcpkg#15470

* Didn't save a file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:vcpkg-feature The issue is a new capability of the tool that doesn’t already exist and we haven’t committed info:internal This PR or Issue was filed by the vcpkg team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants