Skip to content

Commit

Permalink
Add a method to return the provider GUID from a given schema (microso…
Browse files Browse the repository at this point in the history
…ft#209)

A schema has the provider GUID available but no way to access it.
Having the provider GUID available from a schema enables applications
to use the schema directly for GUID comparisons without relying on
existing provide_name() string comparisons.
  • Loading branch information
acyr authored May 2, 2023
1 parent da66c3a commit 3bc145f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions krabs/krabs/schema.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,20 @@ namespace krabs {
*/
unsigned int event_flags() const;

/**
* <summary>
* Returns the provider GUID of an event via its schema.
* </summary>
* <example>
* void on_event(const EVENT_RECORD &record, const krabs::trace_context &trace_context)
* {
* krabs::schema schema(record, trace_context.schema_locator);
* GUID guid = krabs::provider_id(schema);
* }
* </example>
*/
GUID provider_id() const;

/**
* <summary>
* Returns the provider name of an event via its schema.
Expand Down Expand Up @@ -362,6 +376,11 @@ namespace krabs {
return record_.EventHeader.Flags;
}

inline GUID schema::provider_id() const
{
return record_.EventHeader.ProviderId;
}

inline const wchar_t *schema::provider_name() const
{
return reinterpret_cast<const wchar_t*>(
Expand Down

0 comments on commit 3bc145f

Please sign in to comment.