Skip to content

Commit

Permalink
[ETW Exporter] - ETW provider handle cleanup (#1322)
Browse files Browse the repository at this point in the history
  • Loading branch information
lalitb authored Apr 11, 2022
1 parent 3122254 commit d72dcb6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ class ETWProvider
{
std::lock_guard<std::mutex> lock(m_providerMapLock);

auto m = providers();
// use reference to provider list, NOT it' copy.
auto &m = providers();
auto it = m.begin();
while (it != m.end())
{
Expand All @@ -228,7 +229,10 @@ class ETWProvider
}

it->second.providerHandle = INVALID_HANDLE;
m.erase(it);
if (result == STATUS_OK)
{
m.erase(it);
}
}
return result;
}
Expand Down
6 changes: 4 additions & 2 deletions exporters/etw/test/etw_provider_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ TEST(ETWProvider, ProviderIsRegisteredSuccessfully)

bool registered = etw.is_registered(providerName);
ASSERT_TRUE(registered);
etw.close(handle);
}

TEST(ETWProvider, ProviderIsNotRegisteredSuccessfully)
Expand Down Expand Up @@ -46,17 +47,18 @@ TEST(ETWProvider, CheckOpenGUIDDataSuccessfully)
auto guidStrName = uuid_name.to_string();

ASSERT_STREQ(guidStrHandle.c_str(), guidStrName.c_str());
etw.close(handle);
}

TEST(ETWProvider, CheckCloseSuccess)
{
std::string providerName = "OpenTelemetry-ETW-Provider";

static ETWProvider etw;
auto handle = etw.open(providerName.c_str());

auto handle = etw.open(providerName.c_str(), ETWProvider::EventFormat::ETW_MANIFEST);
auto result = etw.close(handle);
ASSERT_NE(result, etw.STATUS_ERROR);
ASSERT_FALSE(etw.is_registered(providerName));
}

#endif

1 comment on commit d72dcb6

@github-actions
Copy link

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'OpenTelemetry-cpp sdk Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: d72dcb6 Previous: 3122254 Ratio
BM_BaselineBuffer/1 14230835.437774658 ns/iter 524044.0368652344 ns/iter 27.16

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.