Skip to content
This repository was archived by the owner on Aug 3, 2024. It is now read-only.

Commit d74bea9

Browse files
Port MachineNameTelemetryInitializer from NuGet.ApplicationInsights.Owin (#330)
1 parent f14515b commit d74bea9

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
using System;
5+
6+
namespace NuGet.Services.Logging
7+
{
8+
public class MachineNameTelemetryInitializer
9+
: SupportPropertiesTelemetryInitializer
10+
{
11+
public MachineNameTelemetryInitializer()
12+
: base("MachineName", TryGetMachineName())
13+
{
14+
}
15+
16+
private static string TryGetMachineName()
17+
{
18+
try
19+
{
20+
return Environment.MachineName;
21+
}
22+
catch
23+
{
24+
return string.Empty;
25+
}
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)