public override bool Probe()
        {
            var uri = EnvUtils.GetEnv(ECS_CONTAINER_METADATA_URI);

            if (uri == null)
            {
                return(false);
            }

            CheckAndSetFluentHost();

            try
            {
                var parsedUri = new Uri(uri);
                _ecsMetadata = _resourceFetcher.Fetch <ECSMetadata>(parsedUri);
                FormatImageName();
                return(true);
            }
            catch (Exception ex)
            {
                _logger.LogDebug("Failed to get response from: " + uri, ex);
            }

            return(false);
        }
Example #2
0
        private string GetSampledTrace()
        {
            string traceId = EnvUtils.GetEnv(TRACE_ID);

            if (traceId != null && traceId.Contains("Sampled=1", StringComparison.OrdinalIgnoreCase))
            {
                return(traceId);
            }

            return(string.Empty);
        }
Example #3
0
        public void ConfigureContext(MetricsContext context)
        {
            AddProperty(context, "executionEnvironment", EnvUtils.GetEnv(AWS_EXECUTION_ENV));
            AddProperty(context, "functionVersion", EnvUtils.GetEnv(LAMBDA_FUNCTION_VERSION));

            var traceId = GetSampledTrace();

            if (!string.IsNullOrEmpty(traceId))
            {
                AddProperty(context, "traceId", traceId);
            }
        }
        private void CheckAndSetFluentHost()
        {
            var fluentHost = EnvUtils.GetEnv(FLUENT_HOST);

            if (fluentHost == null || !string.IsNullOrEmpty(_configuration.AgentEndPoint))
            {
                return;
            }

            _fluentBitEndpoint           = string.Format("tcp://%s:%d", fluentHost, Constants.DEFAULT_AGENT_PORT);
            _configuration.AgentEndPoint = _fluentBitEndpoint;

            _logger.LogInformation("Using FluentBit configuration. Endpoint: {}", _fluentBitEndpoint);
        }
Example #5
0
        public bool Probe()
        {
            string functionName = EnvUtils.GetEnv(LAMBDA_FUNCTION_NAME);

            return(functionName != null);
        }