What renaming does to your ETW provider
An EventSource is a self-describing provider: its provider name is the class name, its provider GUID is a hash of that name, its event names are method names, and its payload fields are parameter names. Obfuscate the class and every one of those identifiers changes — the GUID most dangerously, because EventSource is fail-silent and nothing throws. This post shows the GenerateGuidFromName algorithm, why dotnet-trace and PerfView go dark, and how to scope Nebula.NET so your telemetry provider keeps its identity while your logic still renames.
You obfuscate a service, ship it, and your dashboards go quiet. The dotnet-trace collection that used to fill with Checkout/OrderPlaced events now captures nothing from your provider. PerfView shows the session running and zero rows. No exception was thrown, no log line written, the app is healthy. The provider is still there and still emitting — under a name and a GUID your tooling has never heard of, because an EventSource describes itself with exactly the identifiers that renaming rewrites.
The real question
EventSource is a self-describing provider. You do not register a manifest or a GUID by hand; the runtime builds all of that by reflecting over your derived class. That is the convenience, and under obfuscation it is the trap. So the question is the usual one, sharpened: which parts of a provider’s identity are constants baked into your assembly, and which are reflected names that renaming has quietly changed? For EventSource the answer is unusually bad — almost everything that identifies the provider is a reflected name.
Four identifiers, all reflected
Here is an ordinary provider.
[EventSource(Name = null)] // name omitted on purpose, see below
public sealed class CheckoutEventSource : EventSource
{
public static readonly CheckoutEventSource Log = new();
[Event(1, Level = EventLevel.Informational)]
public void OrderPlaced(string orderId, decimal total) =>
WriteEvent(1, orderId, total);
}
Four things name this provider to the outside world, and the runtime derives each one by reflection at construction time:
- The provider name defaults to the type’s simple name —
CheckoutEventSource— unless you set[EventSource(Name = ...)]. - The provider GUID defaults to a hash of that name (next section).
- The event name is the method name —
OrderPlaced. - The payload field names are the parameter names —
orderId,total.
Every one of those is a metadata name, and renaming is the transform that rewrites metadata names. After Nebula renames the class to a, the method to b, and the parameters to p0, p1, the provider that ships is named a, emits an event called b with fields p0 and p1, and — the dangerous part — carries a GUID computed from "a".
The GUID is computed, not stored
This is the mechanism that turns a readability nuisance into silent data loss. When you do not supply [EventSource(Guid = ...)], the runtime computes the provider GUID from the provider name using the RFC-4122 name-based (SHA1) algorithm, against a fixed EventSource namespace GUID:
// System.Diagnostics.Tracing.EventSource.GenerateGuidFromName (faithful excerpt)
private static Guid GenerateGuidFromName(string name)
{
ReadOnlySpan<byte> namespaceBytes = new byte[]
{
0x48, 0x2C, 0x2D, 0xB2, 0xC3, 0x90, 0x47, 0xC8,
0x87, 0xF8, 0x1A, 0x15, 0xBF, 0xC1, 0x30, 0xFB,
};
byte[] bytes = Encoding.BigEndianUnicode.GetBytes(name); // caller passes name.ToUpperInvariant()
using var sha1 = IncrementalHash.CreateHash(HashAlgorithmName.SHA1);
sha1.AppendData(namespaceBytes);
sha1.AppendData(bytes);
Span<byte> hash = stackalloc byte[20];
sha1.GetHashAndReset(hash);
hash[7] = (byte)((hash[7] & 0x0F) | 0x50); // RFC-4122 version 5
// first three fields are then byte-swapped to little-endian for Guid()
return new Guid(hash.Slice(0, 16));
}
The input is the provider name. "CHECKOUTEVENTSOURCE" hashes to one GUID; "A" hashes to a completely unrelated one — a SHA1 avalanche, not a near-match. There is no fuzzy fallback: an ETW session or an EventPipe subscription keyed on the old GUID simply never sees the renamed provider. And because the name is also what you’d pass to dotnet-trace --providers CheckoutEventSource, matching by name fails in the same breath.
Why nothing tells you
EventSource has a hard design rule: a telemetry provider must never crash the application that hosts it. So the constructor validates the type’s shape and, if anything is wrong, swallows the failure instead of throwing — it records the problem in a private ConstructionException and disables the provider quietly. Renaming does not even trip that path, because a renamed provider is still well-formed; it is simply a different provider. The result is the worst failure mode a diagnostics pipeline can have: fully silent. Compare that to a [Serializable] contract or a JSON converter, where a renamed name usually surfaces as a missing field downstream. Here the events are perfectly emitted and nobody is listening.
Scoping Nebula
An EventSource subclass is a telemetry contract, not logic you need to hide. The clean fix is to keep that one type’s names and rename everything else. Put a keep rule on the provider:
{
"schemaVersion": 1,
"inputs": ["bin/Release/net8.0/Checkout.dll"],
"outputDirectory": "protected",
"encryptStrings": true,
"controlFlowObfuscation": true,
"renaming": {
"rules": [
{ "pattern": "Checkout.Telemetry.CheckoutEventSource", "action": "keep", "members": "public" },
{ "pattern": "Checkout.*", "action": "rename" }
]
}
}
nebula protect --config nebula.config.json
members: "public" keeps the public event methods and their parameter names — so the provider name, the derived GUID, the event names, and the payload field names all stay exactly what your tooling expects — while the type’s private fields still rename and the rest of the assembly renames freely. You keep one diagnostics class readable; your pricing, licensing, and domain logic still obfuscate to a, b, c and still get control-flow protection and string encryption.
If you would rather not rely on a keep rule for the provider’s identity, pin it in the attribute instead:
[EventSource(Name = "MyCompany-Checkout", Guid = "a1b2c3d4-0000-0000-0000-000000004f2a")]
public sealed class CheckoutEventSource : EventSource { /* ... */ }
Now the provider name and GUID are constants read from the attribute blob, not derived from the type name, so subscriptions by provider survive renaming even if the class becomes a. That covers every consumer that matches on provider. It does not cover consumers that match on event or field names — EventAttribute has no name override, so those still follow the method and parameter names. If your collectors parse by event name, pin the attribute and keep the member names.
When it breaks
Three edges are worth naming. First, in-process EventListeners: a listener that switches on eventData.EventName or reads a payload by eventData.PayloadNames[i] breaks exactly like an out-of-process collector, because those strings come from the renamed method and parameters — pin the attribute and keep the member names, or key the listener on the stable numeric EventId instead. Second, [EventData] TraceLogging types: if you pass a POCO to Write<T>(), its property names become the payload field names and renaming rewrites them, so the same keep reasoning applies to that type. Third, coverage: the break is invisible until the provider is actually subscribed, so verify against the protected build — run dotnet-trace collect --providers CheckoutEventSource against the obfuscated binary and confirm the events arrive, rather than trusting the debug build where nothing was renamed.
Takeaway
Obfuscation does not break EventSource — it re-identifies it. The provider name is your class name, the provider GUID is a SHA1 hash of that name, the event names are your method names, and the payload fields are your parameter names; renaming rewrites all four, the GUID most consequentially, and EventSource’s never-throw design guarantees the failure is silent. Keep the one diagnostics type’s names or pin its identity with [EventSource(Name, Guid)], and let Nebula.NET rename the rest. Then open the result in Glass.NET to confirm your provider still reports CheckoutEventSource/OrderPlaced while your logic reads as a, b, c.
Try Nebula.NET
Harden your .NET code in minutes — start with the free edition.