private BrowserMonitoringConfigurationData GetBrowserConfigurationData(IInternalTransaction transaction, TransactionMetricName transactionMetricName, string licenseKey)
        {
            var configuration = _configurationService.Configuration;

            var beacon = configuration.BrowserMonitoringBeaconAddress;

            if (beacon == null)
            {
                throw new NullReferenceException(nameof(beacon));
            }

            var errorBeacon = configuration.BrowserMonitoringErrorBeaconAddress;

            if (errorBeacon == null)
            {
                throw new NullReferenceException(nameof(errorBeacon));
            }

            var browserMonitoringKey = configuration.BrowserMonitoringKey;

            if (browserMonitoringKey == null)
            {
                throw new NullReferenceException(nameof(browserMonitoringKey));
            }

            var applicationId = configuration.BrowserMonitoringApplicationId;

            if (applicationId == null)
            {
                throw new NullReferenceException(nameof(applicationId));
            }

            var jsAgentPayloadFile = configuration.BrowserMonitoringJavaScriptAgentFile;

            if (jsAgentPayloadFile == null)
            {
                throw new NullReferenceException(nameof(jsAgentPayloadFile));
            }

            var obfuscatedTransactionName = Strings.ObfuscateStringWithKey(transactionMetricName.PrefixedName, licenseKey);
            var queueTime       = transaction.TransactionMetadata.QueueTime ?? _zeroTimespan;
            var applicationTime = transaction.GetDurationUntilNow();

            var attributes = new AttributeValueCollection(AttributeDestinations.JavaScriptAgent);

            _transactionAttributeMaker.SetUserAndAgentAttributes(attributes, transaction.TransactionMetadata);

            // for now, treat tripId as an agent attribute when passing to browser.  Eventually this will be an intrinsic but need changes to browser code first.
            // if CrossApplicationReferrerTripId is null then this transaction started the first external request, so use its guid
            _attribDefSvc.AttributeDefs.BrowserTripId.TrySetValue(attributes, transaction.TransactionMetadata.CrossApplicationReferrerTripId ?? transaction.Guid);

            //This will resolve any Lazy values and remove null values from the collection.
            //Browser monitoring should not render JSON for attributes if there are none
            attributes.MakeImmutable();

            var obfuscatedFormattedAttributes = GetObfuscatedFormattedAttributes(attributes, licenseKey);
            var sslForHttp = configuration.BrowserMonitoringUseSsl;

            return(new BrowserMonitoringConfigurationData(licenseKey, beacon, errorBeacon, browserMonitoringKey, applicationId, obfuscatedTransactionName, queueTime, applicationTime, jsAgentPayloadFile, obfuscatedFormattedAttributes, sslForHttp));
        }
        protected EventWireModel(AttributeDestinations targetObject, IAttributeValueCollection attribValues, bool isSynthetics, float priority)
        {
            _targetObject   = targetObject;
            AttributeValues = new AttributeValueCollection(attribValues, _targetObject);
            Priority        = priority;
            IsSynthetics    = isSynthetics;

            AttributeValues.MakeImmutable();
        }
            public TransactionTraceAttributes(IAttributeValueCollection attribValues)
            {
                var filteredAttribs = new AttributeValueCollection(attribValues, AttributeDestinations.TransactionTrace);

                filteredAttribs.MakeImmutable();

                AgentAttributes = new ReadOnlyDictionary <string, object>(filteredAttribs.GetAttributeValuesDic(AttributeClassification.AgentAttributes));
                Intrinsics      = new ReadOnlyDictionary <string, object>(filteredAttribs.GetAttributeValuesDic(AttributeClassification.Intrinsics));
                UserAttributes  = new ReadOnlyDictionary <string, object>(filteredAttribs.GetAttributeValuesDic(AttributeClassification.UserAttributes));
            }
            public ErrorTraceAttributesWireModel(IAttributeValueCollection attribValues, IList <string> stackTrace = null)
            {
                var filteredAttribValues = new AttributeValueCollection(attribValues, AttributeDestinations.ErrorTrace);

                filteredAttribValues.MakeImmutable();

                AgentAttributes = new ReadOnlyDictionary <string, object>(filteredAttribValues.GetAttributeValuesDic(AttributeClassification.AgentAttributes));
                Intrinsics      = new ReadOnlyDictionary <string, object>(filteredAttribValues.GetAttributeValuesDic(AttributeClassification.Intrinsics));
                UserAttributes  = new ReadOnlyDictionary <string, object>(filteredAttribValues.GetAttributeValuesDic(AttributeClassification.UserAttributes));

                if (stackTrace != null)
                {
                    StackTrace = new ReadOnlyCollection <string>(stackTrace);
                }
            }