Skip to content
This repository has been archived by the owner on Aug 3, 2024. It is now read-only.
/ ServerCommon Public archive

Port MachineNameTelemetryInitializer from NuGet.ApplicationInsights.Owin #330

Merged
merged 1 commit into from
Jan 9, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;

namespace NuGet.Services.Logging
{
public class MachineNameTelemetryInitializer
: SupportPropertiesTelemetryInitializer
{
public MachineNameTelemetryInitializer()
: base("MachineName", TryGetMachineName())
{
}

private static string TryGetMachineName()
Copy link
Member Author

@xavierdecoster xavierdecoster Jan 9, 2020

Choose a reason for hiding this comment

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

Current version lives here: https://github.com/NuGet/NuGet.Services.Metadata/blob/master/src/NuGet.ApplicationInsights.Owin/MachineNameTelemetryInitializer.cs

Note that we now inherit from SupportPropertiesTelemetryInitializer which uses the proper AppInsights API to set properties. The current version in NuGet.ApplicationInsights.Owin still uses the obsolete API via TelemetryContext.

{
try
{
return Environment.MachineName;
}
catch
{
return string.Empty;
}
}
}
}