Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Another attempt at getting TelemetryLogger working in VSCode #71734

Merged
merged 3 commits into from
Jan 20, 2024
Merged
Show file tree
Hide file tree
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
Expand Up @@ -11,6 +11,8 @@
using System.Threading;
using Microsoft.CodeAnalysis.Contracts.Telemetry;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Shared.TestHooks;
using Microsoft.CodeAnalysis.Telemetry;
using Microsoft.VisualStudio.Telemetry;

namespace Microsoft.CodeAnalysis.LanguageServer.Logging;
Expand All @@ -19,15 +21,18 @@ namespace Microsoft.CodeAnalysis.LanguageServer.Logging;
internal sealed class VSCodeTelemetryLogger : ITelemetryReporter
{
private TelemetrySession? _telemetrySession;
private readonly IAsynchronousOperationListenerProvider _asyncListenerProvider;

private const string CollectorApiKey = "0c6ae279ed8443289764825290e4f9e2-1a736e7c-1324-4338-be46-fc2a58ae4d14-7255";
private static int _dumpsSubmitted = 0;

private static readonly ConcurrentDictionary<int, object> _pendingScopes = new(concurrencyLevel: 2, capacity: 10);

[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public VSCodeTelemetryLogger()
public VSCodeTelemetryLogger(IAsynchronousOperationListenerProvider asyncListenerProvider)
{
_asyncListenerProvider = asyncListenerProvider;
}

public void InitializeSession(string telemetryLevel, string? sessionId, bool isDefaultSession)
Expand All @@ -46,6 +51,8 @@ public void InitializeSession(string telemetryLevel, string? sessionId, bool isD
session.RegisterForReliabilityEvent();

_telemetrySession = session;

TelemetryLogger.Create(_telemetrySession, logDelta: false, _asyncListenerProvider);
}

public void Log(string name, List<KeyValuePair<string, object?>> properties)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<ItemGroup>
<Compile Include="..\..\..\EditorFeatures\Core\EditAndContinue\Contracts\ContractWrappers.cs" Link="EditAndContinue\ContractWrappers.cs" />
<Compile Include="..\..\..\EditorFeatures\Core\EditAndContinue\Contracts\ManagedHotReloadServiceBridge.cs" Link="EditAndContinue\ManagedHotReloadServiceBridge.cs" />
<Compile Include="..\..\..\VisualStudio\Core\Def\Telemetry\Shared\*.cs" LinkBase="Logging" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,7 @@
<Compile Include="..\..\..\VisualStudio\Core\Def\Storage\ProjectContainerKeyCache.cs" Link="Host\Storage\ProjectContainerKeyCache.cs" />
<Compile Include="..\..\..\VisualStudio\Core\Def\Storage\FileDownloader.cs" Link="Host\Storage\FileDownloader.cs" />
<Compile Include="..\..\..\VisualStudio\Core\Def\Telemetry\AbstractWorkspaceTelemetryService.cs" Link="Services\ProcessTelemetry\AbstractWorkspaceTelemetryService.cs" />
<Compile Include="..\..\..\VisualStudio\Core\Def\Telemetry\AggregatingTelemetryLog.cs" Link="Services\ProcessTelemetry\AggregatingTelemetryLog.cs" />
<Compile Include="..\..\..\VisualStudio\Core\Def\Telemetry\AggregatingTelemetryLogManager.cs" Link="Services\ProcessTelemetry\AggregatingTelemetryLogManager.cs" />
<Compile Include="..\..\..\VisualStudio\Core\Def\Telemetry\TelemetryLogger.cs" Link="Services\ProcessTelemetry\TelemetryLogger.cs" />
<Compile Include="..\..\..\VisualStudio\Core\Def\Telemetry\TelemetryLogProvider.cs" Link="Services\ProcessTelemetry\TelemetryLogProvider.cs" />
<Compile Include="..\..\..\VisualStudio\Core\Def\Telemetry\TimedTelemetryLogBlock.cs" Link="Services\ProcessTelemetry\TimedTelemetryLogBlock.cs" />
<Compile Include="..\..\..\VisualStudio\Core\Def\Telemetry\VisualStudioTelemetryLog.cs" Link="Services\ProcessTelemetry\VisualStudioTelemetryLog.cs" />
<Compile Include="..\..\..\VisualStudio\Core\Def\Telemetry\VisualStudioTelemetryLogManager.cs" Link="Services\ProcessTelemetry\VisualStudioTelemetryLogManager.cs" />
<Compile Include="..\..\..\VisualStudio\Core\Def\Telemetry\Shared\*.cs" LinkBase="Services\ProcessTelemetry" />
</ItemGroup>
<ItemGroup>
<RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.LiveUnitTesting.BuildManager" Partner="UnitTesting" Key="$(UnitTestingKey)" />
Expand Down