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

Added proxy logging #86

Merged
merged 8 commits into from
Jun 12, 2019
Merged

Added proxy logging #86

merged 8 commits into from
Jun 12, 2019

Conversation

WilliamXieMSFT
Copy link
Member

@WilliamXieMSFT WilliamXieMSFT commented Jun 6, 2019

This change incorporates the reverted changes from #68

Changes related to Proxy Logging:

  • Pulled common logic from EventLoggerSink into EventLoggingBase
  • Moved common header files into new Common.Lib project
  • Use CCriticalSection and CriticalSectionHolder in Proxy dllmain
  • Added IfFailRet_Proxy macro for CProxyLogging
  • Use GetFileAttributes over fOpen

Other changes/fixes:

  • Fix Build Version to use yyyyMMdd for local non-release builds
  • Added URL/Ref linking for docs
  • Address build warnings
  • Fix Header includes
  • Added SAL annotations to MIDL builds
  • Renamed MSI package description to "Microsoft CLR Instrumentation Engine"

do {
// Skip any files; we only want directories
if ((findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
{
CProxyLogging::LogWarning(_T("dllmain::GetLatestVersionFolder - Skipping '%s', not a directory"), findFileData.cFileName);
Copy link
Member Author

@WilliamXieMSFT WilliamXieMSFT Jun 6, 2019

Choose a reason for hiding this comment

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

LogWarning [](start = 31, length = 10)

Currently I'm logging a warning of each folder that fails parsing or pattern matching or missing profiler dll

Not sure if there are security or privacy implications #Resolved

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll remove these logwarnings since they're taking up a large amount of the eventlog for very little gain.


In reply to: 291384022 [](ancestors = 291384022)


namespace MicrosoftInstrumentationEngine
{
class CEventLogger :
Copy link
Member Author

@WilliamXieMSFT WilliamXieMSFT Jun 6, 2019

Choose a reason for hiding this comment

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

CEventLogger [](start = 10, length = 12)

This class is the proxy's version of CEventLoggerSink #Closed

@WilliamXieMSFT
Copy link
Member Author

WilliamXieMSFT commented Jun 6, 2019

Consider adding/changing existing tests to register using the proxy. #Closed

@WilliamXieMSFT
Copy link
Member Author

I moved several classes from ProfilerProxy project to static ProfilerProxy.lib project in order to write my tests.


In reply to: 499689819 [](ancestors = 499689819)

@@ -29,6 +27,11 @@ namespace MicrosoftInstrumentationEngine
do { if (FAILED(hr = (EXPR))) { CLogging::LogError(_T("IfFailRet(") _T(#EXPR) _T(") failed in function ") __FUNCTIONT__); return hr; } } while (false)
#endif

#ifndef IfFailRet_Proxy
Copy link
Member

@wiktork wiktork Jun 10, 2019

Choose a reason for hiding this comment

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

IfFailRet_Proxy [](start = 8, length = 15)

Common.Lib should not be aware of proxy logging. You might want to define this inside the proxy project #Resolved

@wiktork
Copy link
Member

wiktork commented Jun 10, 2019

        /* [in] */ __RPC__in_opt IProfilerManagerLoggingHost *pLoggingHost);

You're positive this doesn't introduce any breaking api changes? #Resolved


Refers to: src/InstrumentationEngine.Api/InstrumentationEngine.h:924 in 2951596. [](commit_id = 2951596, deletion_comment = False)

@WilliamXieMSFT
Copy link
Member Author

WilliamXieMSFT commented Jun 10, 2019

        /* [in] */ __RPC__in_opt IProfilerManagerLoggingHost *pLoggingHost);

I added these SAL annotations to fix a build warning, I am confident there's no breaking API changes since the implementation in ProfilerManager.cpp (which had SAL annotations) had no changes needed.

I'll verify with a build of Aerobee.


In reply to: 500574167 [](ancestors = 500574167)


Refers to: src/InstrumentationEngine.Api/InstrumentationEngine.h:924 in 2951596. [](commit_id = 2951596, deletion_comment = False)


HRESULT Initialize();

void LogMessage(_In_ LPCWSTR wszMessage, _In_ va_list argptr);
Copy link
Member

@wiktork wiktork Jun 10, 2019

Choose a reason for hiding this comment

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

Is the override keyword supported now, particularly for linux builds? it makes it clearer that you are implementing methods #Resolved

Copy link
Member Author

Choose a reason for hiding this comment

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

Linux supports override, however these methods are not in the base class


In reply to: 292171420 [](ancestors = 292171420)


struct EventLogItem
{
EventLogItem(WORD wEventType, tstring tsEventLog) {
Copy link
Member

@wiktork wiktork Jun 10, 2019

Choose a reason for hiding this comment

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

nit: use initializer #Resolved


class CEventLoggingBase
{
protected:
Copy link
Member

@wiktork wiktork Jun 10, 2019

Choose a reason for hiding this comment

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

protected [](start = 0, length = 9)

Since we have protected functions to use these, can these members be private? #Resolved


if (s_initialize.IsSuccessful())
{
++s_initCount;
Copy link
Member

@wiktork wiktork Jun 10, 2019

Choose a reason for hiding this comment

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

s_initCount [](start = 10, length = 11)

is this really decremented each time it could be incremented? #Resolved

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, the lifecycle of CProxyLogging is in dllmain's getclassobject which calls initialize and shutdown.


In reply to: 292172818 [](ancestors = 292172818)

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll add comments around this design for maintainability & aid in future changes


In reply to: 292173675 [](ancestors = 292173675,292172818)

Copy link
Member Author

@WilliamXieMSFT WilliamXieMSFT Jun 10, 2019

Choose a reason for hiding this comment

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

Discussed offline, there's a bug here if a thread calls initialize/shutdown before a second thread can call initialize (since the CInitOnce is not reset).

Fix is to move Shutdown() call on DllCanUnloadNow


In reply to: 292176770 [](ancestors = 292176770,292173675,292172818)

private:
void AssertSucceeded(HRESULT hr)
{
Assert::IsTrue(SUCCEEDED(hr));
Copy link
Member

@wiktork wiktork Jun 10, 2019

Choose a reason for hiding this comment

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

IsTrue [](start = 20, length = 6)

Does this assert automatically pass along some useful callstack information to the test the result? #Resolved

Copy link
Member Author

Choose a reason for hiding this comment

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

Both TestExplorer and running vstest.exe show stacktrace & assert message on failure


In reply to: 292173458 [](ancestors = 292173458)

Copy link
Member

@wiktork wiktork left a comment

Choose a reason for hiding this comment

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

:shipit:

// [1]: SemanticVersion (eg. 1.0.0)
// [2]: Preview tag if exists (eg. -build12345)
// [3]: Debug tag if exists (eg. _Debug)
const std::wregex InstrumentationEngineVersion::versionRegex(_T("^(\\d+\\.\\d+\\.\\d+)(-build\\d+)?(_Debug)?$"));
Copy link
Member Author

@WilliamXieMSFT WilliamXieMSFT Jun 11, 2019

Choose a reason for hiding this comment

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

\d+ [](start = 67, length = 4)

Just realized there's no checks for major version 1. #Resolved


## <a name="app-service">Azure App Service</a>

Microsoft Docs: [App Service Overview]()
Copy link
Contributor

@delmyers delmyers Jun 12, 2019

Choose a reason for hiding this comment

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

() [](start = 38, length = 2)

No URL? #Resolved

Copy link
Member Author

Choose a reason for hiding this comment

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

Ack, thanks the catch!


In reply to: 293011104 [](ancestors = 293011104)


Microsoft Docs: [App Service Overview]()

Azure App Service is a PaaS offering in Azure and provides hosting of web applications and sites as well as a Site Control Manager (SCM, also known as [Kudu](https://github.com/projectkudu/kudu) that provides administrative and management capabilities.
Copy link
Contributor

@delmyers delmyers Jun 12, 2019

Choose a reason for hiding this comment

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

Azure App Se [](start = 0, length = 12)

Can paragraphs be split across lines so that we don't have to scroll during PRs? #Resolved

#include "tstring.h"
#include "CriticalSectionHolder.h"

struct EventLogItem
Copy link
Contributor

@delmyers delmyers Jun 12, 2019

Choose a reason for hiding this comment

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

EventLogItem [](start = 7, length = 12)

Should there be a namespace for this stuff? #Resolved

@WilliamXieMSFT
Copy link
Member Author

WilliamXieMSFT commented Jun 12, 2019

/azp run

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

@WilliamXieMSFT WilliamXieMSFT merged commit 5c726db into develop Jun 12, 2019
@WilliamXieMSFT WilliamXieMSFT deleted the dev/willxie/proxy2 branch June 12, 2019 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants