Skip to content

Add IsPackagedProcess and IsSelfContained to common insights PartB fields#6233

Open
agniuks wants to merge 5 commits intomainfrom
user/agnel/app_insights
Open

Add IsPackagedProcess and IsSelfContained to common insights PartB fields#6233
agniuks wants to merge 5 commits intomainfrom
user/agnel/app_insights

Conversation

@agniuks
Copy link
Contributor

@agniuks agniuks commented Feb 20, 2026

Add IsPackagedProcess and IsSelfContained bools to PartB fields to get signal on self-contained vs framework-dependent and packaged vs unpackaged deployments

@agniuks
Copy link
Contributor Author

agniuks commented Feb 25, 2026

@DrusTheAxe what do you think of this? Getting some signal on selfcontained vs fwp dependent, and packages vs unpackaged is something we've wanted for a while.

@agniuks agniuks marked this pull request as ready for review February 25, 2026 18:57
@agniuks
Copy link
Contributor Author

agniuks commented Feb 25, 2026

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@agniuks
Copy link
Contributor Author

agniuks commented Feb 25, 2026

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

}

// Reimplemented here (not using AppModel::Identity / WindowsAppRuntime::SelfContained)
// to avoid header dependencies — PartB fires during bootstrap before DLL load.
Copy link
Member

Choose a reason for hiding this comment

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

-1

Dupe code is a bad idea. Add the needed #include's and learn to love the bomb :-)


#define _GENERIC_PARTB_FIELDS_ENABLED \
TraceLoggingStruct(4, "COMMON_WINDOWSAPPSDK_PARAMS"), \
TraceLoggingStruct(6, "COMMON_WINDOWSAPPSDK_PARAMS"), \
Copy link
Member

Choose a reason for hiding this comment

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

This adds the data to every TraceLoggingWrite event. That seems heavy handed.

Better to replace the IsDebuggerPresent boolean with a Flags UINT32 bitfield

TraceLoggingUInt32(::Microsoft::WindowsAppRuntine::Insights::RuntimeInformation::TraceLoggingInformationFlags(), "Flags") \

and add

enum class TraceLoggingInformationFlags
{
    None = 0,
    IsDebuggerPresent = 0x00000001,
    IsPackagedProcess = 0x00000002,
    IsSelfContained = 0x00000004,
};
DEFINE_ENUM_FLAG_OPERATORS(TraceLoggingInformationFlags)

std::uint32_t GetTraceLoggingInformationFlags()
{
    auto flags{ TraceLoggingInformationFlags::None };

    if (wil::details::IsDebuggerPresent())
    {
        flags |= TraceLoggingInformationFlags::IsDebuggerPresent;
    }

    try
    {
        if ( ::AppModel::Identity::IsPackagedProcess())
        {
            flags |= TraceLoggingInformationFlags::IsPackagedProcess;
        }
    }
    catch (...)
    {
        // Ignore errors
    }

    try
    {
        if ( ::WindowsAppRuntime::SelfContained::IsSelfContained())
        {
            flags |= TraceLoggingInformationFlags::IsSelfContained;
        }
    }
    catch (...)
    {
        // Ignore errors
    }

    return flags;
}

Copy link
Member

Choose a reason for hiding this comment

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

Or add to dev\common

  • HRESULT AppModel::Identity::IsPackagedProcess(bool& isPackagedProcess)
  • HRESULT WindowsAppRuntime::SelfContained::IsSelfContained_nothrow(bool& isSelfContained)
    as non-throwing variants and call these in GetTraceLoggingInformationFlags()

But regardless, don't duplicate code

@DrusTheAxe
Copy link
Member

@DrusTheAxe what do you think of this? Getting some signal on selfcontained vs fwp dependent, and packages vs unpackaged is something we've wanted for a while.

Good idea, but this information retrieval happens on every TraceLoggingWrite. Not too heavy a cost?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants