private async Task UploadTraceAsync()

in src/ServiceProfiler.EventPipe.Otel/Azure.Monitor.OpenTelemetry.Profiler.Core/PostStopProcessor.cs [208:233]


    private async Task<UploadContextModel?> UploadTraceAsync(
        PostStopOptions options, int processId, string namedPipeName, CancellationToken cancellationToken)
    {
        bool areOptionsSerialized = _serializer.TrySerialize(options, out string? serializedOptions);
        _logger.LogTrace(@"Trace session finished. Invoking upload. Args:
{arguments}", serializedOptions);

        string metadataPath = Path.ChangeExtension(options.TraceFilePath, "metadata");
        string machineName = _serviceProfilerContext.MachineName;
        await CreateMetadataAsync(options.Samples.Select(sample =>
            // At this point, we don't have a stamp id or the datacube yet, just use 'localstamp' as the stamp id.
            // Since the metadata file stays in the .etl.zip, it is not needed to locate the trace file.
            sample.ToArtifactLocationProperties("localstamp", processId, options.SessionId, Guid.Empty, machineName)
        ), metadataPath, cancellationToken).ConfigureAwait(false);

        return await _traceUploader.UploadAsync(
            options.SessionId,
            options.TraceFilePath,
            metadataPath,
            sampleFilePath: null,// Replaced by namedpipe name.
            namedPipeName,
            _roleNameSource.CloudRoleName,
            options.ProfilerSource.Source,
            cancellationToken,
            options.UploaderFullPath).ConfigureAwait(false);
    }