public ServiceProfilerContext()

in src/ServiceProfiler.EventPipe.Otel/Azure.Monitor.OpenTelemetry.Profiler.Core/ServiceProfilerContext.cs [18:49]


    public ServiceProfilerContext(
        IEndpointProvider endpointProvider,
        IConnectionStringParserFactory connectionStringParserFactory,
        IOptions<ServiceProfilerOptions> options,
        ILogger<ServiceProfilerContext> logger)
    {
        _logger = logger ?? throw new ArgumentNullException(nameof(logger));

        _options = options?.Value ?? throw new ArgumentNullException(nameof(options));
        _endpointProvider = endpointProvider ?? throw new ArgumentNullException(nameof(endpointProvider));

        ConnectionString = GetRequiredConnectionString(_options);
        _logger.LogDebug("Building {name}. Connection string: {connectionString}", nameof(ServiceProfilerContext), ConnectionString);

        _connectionStringParserFactory = connectionStringParserFactory ?? throw new ArgumentNullException(nameof(connectionStringParserFactory));
        IConnectionStringParser connectionStringParser = _connectionStringParserFactory.Create(ConnectionString);
        if (connectionStringParser.TryGetValue(ConnectionStringParser.Keys.InstrumentationKey, out string? instrumentationKeyValue))
        {
            _logger.LogDebug("Instrumentation key value: {iKey}", instrumentationKeyValue);
            AppInsightsInstrumentationKey = Guid.Parse(instrumentationKeyValue!);
        }
        else
        {
            _logger.LogError("Instrumentation key does not exist.");
        }

        StampFrontendEndpointUrl = _endpointProvider.GetEndpoint();
        if (StampFrontendEndpointUrl != new Uri(FrontendEndpoints.ProdGlobal, UriKind.Absolute))
        {
            _logger.LogWarning("Custom endpoint: {endpoint}. This is not supposed to be used in production. File an issue if this is not intended.", StampFrontendEndpointUrl);
        }
    }