private TelemetryData GetRequest(
            ApplicationTelemetryData application,
            HostTelemetryData host,
            string requestType,
            IPayload?payload)
        {
            var sequence = Interlocked.Increment(ref _sequence);

            return(new TelemetryData(
                       requestType: requestType,
                       tracerTime: DateTimeOffset.UtcNow.ToUnixTimeSeconds(),
                       runtimeId: DistributedTracer.Instance.GetRuntimeId(),
                       seqId: sequence,
                       application: application,
                       host: host,
                       payload: payload));
        }
Beispiel #2
0
        public void RecordTracerSettings(
            ImmutableTracerSettings tracerSettings,
            string defaultServiceName,
            AzureAppServices appServicesMetadata)
        {
            // Increment number of times this has been called
            var reconfigureCount = Interlocked.Increment(ref _tracerInstanceCount);
            var appData          = new ApplicationTelemetryData(
                serviceName: defaultServiceName,
                env: tracerSettings.Environment,
                tracerVersion: TracerConstants.AssemblyVersion,
                languageName: "dotnet",
                languageVersion: FrameworkDescription.Instance.ProductVersion)
            {
                ServiceVersion = tracerSettings.ServiceVersion,
                RuntimeName    = FrameworkDescription.Instance.Name,
            };

            _settings = new CurrentSettings(tracerSettings, appData);

            // The remaining properties can't change, so only need to set them the first time
            if (reconfigureCount != 1)
            {
                SetHasChanges();
                return;
            }

            _azureApServicesMetadata = appServicesMetadata;
            var host = HostMetadata.Instance;

            _hostData = new HostTelemetryData
            {
                ContainerId   = ContainerMetadata.GetContainerId(),
                Os            = FrameworkDescription.Instance.OSPlatform,
                OsVersion     = Environment.OSVersion.ToString(),
                Hostname      = host.Hostname,
                KernelName    = host.KernelName,
                KernelRelease = host.KernelRelease,
                KernelVersion = host.KernelVersion,
            };

            _isTracerInitialized = true;
            SetHasChanges();
        }