Skip to content

Add support for specifying DOTNET_DiagnosticPortDefaultPrefix #110473

@xoofx

Description

@xoofx

Hello, 🙂

I have a case where I'm compiling .NET 8 NativeAOT dyld with EventPipe support that I can load in an existing .NET process. I would like to connect to the diagnostic port of this specific dyld by being able to configure my own prefix for the socket configuration. Currently, the prefix is hardcoded with dotnet-diagnostic at (for MacOS/Linux):

static
inline
bool
ipc_transport_get_default_name (
ep_char8_t *name,
int32_t name_len)
{
#ifdef DS_IPC_PAL_AF_UNIX
#ifndef EP_NO_RT_DEPENDENCY
return ds_rt_transport_get_default_name (
name,
name_len,
"dotnet-diagnostic",
ep_rt_current_process_get_id (),
NULL,
"socket");
#elif defined (EP_NO_RT_DEPENDENCY) && defined (FEATURE_CORECLR)
// generate the default socket name in TMP Path
const ProcessDescriptor pd = ProcessDescriptor::FromCurrentProcess();
PAL_GetTransportName(
name_len,
name,
"dotnet-diagnostic",
pd.m_Pid,
pd.m_ApplicationGroupId,
"socket");
return true;
#else
return false;
#endif
#else
return false;
#endif
}

I'm proposing to add support for an environment variable DOTNET_DiagnosticPortDefaultPrefix that would allow to configure this prefix name.

If not set, it would default to dotnet-diagnostic.

In general, this prefix could be used to disambiguate more easily these diagnostic ports from the pipe/tmp folders when there are several applications/services running on the same machine.

If accepted, I can make a PR.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions