Esempio n. 1
0
        internal TelemetryTracker(
            ILambdaContext lambdaContext,
            string operationName = null,
            IEnumerable <KeyValuePair <string, string> > tags = null,
            IHeadersCollection headersCollection = null)
            : this()
        {
            if (!TelemetryConfiguration.TracingEnabled && !TelemetryConfiguration.MetricsEnabled)
            {
                return;
            }

            var coldStart = s_coldStart;

            if (coldStart)
            {
                s_coldStart = false;
            }

            var commonTags = lambdaContext.ExtractCommonTags();

            if (TelemetryConfiguration.MetricsEnabled)
            {
                _metricWrapper = new MetricWrapper(commonTags);
            }

            if (TelemetryConfiguration.TracingEnabled)
            {
                ISpanContext parentContext = null;
                if (TelemetryConfiguration.ContextPropagationEnabled && headersCollection != null)
                {
                    parentContext = B3SpanContextPropagator.Instance.Extract(headersCollection);
                }

                operationName = operationName ?? lambdaContext.FunctionName;
                _sfxScope     = s_sfxTracer.StartActive(operationName, parentContext);

                var sfxSpan = _sfxScope.Span;
                sfxSpan.SetTag("span.kind", "server");
                sfxSpan.SetTag("component", "dotnet-lambda-wrapper");
                sfxSpan.SetTag("aws_request_id", lambdaContext.AwsRequestId);
                foreach (var kvp in commonTags)
                {
                    sfxSpan.SetTag(kvp.Key, kvp.Value);
                }

                if (coldStart)
                {
                    sfxSpan.SetTag("cold_start", "true");
                }

                if (tags != null)
                {
                    foreach (var kvp in tags)
                    {
                        sfxSpan.SetTag(kvp.Key, kvp.Value);
                    }
                }
            }
        }
Esempio n. 2
0
        internal TelemetryTracker(
            ILambdaContext lambdaContext,
            string operationName = null,
            IEnumerable <KeyValuePair <string, string> > tags = null,
            IDictionary <string, string> headers = null)
            : this()
        {
            if (!TelemetryConfiguration.TracingEnabled && !TelemetryConfiguration.MetricsEnabled)
            {
                return;
            }

            var coldStart = s_coldStart;

            if (coldStart)
            {
                s_coldStart = false;
            }

            var commonTags = lambdaContext.ExtractCommonTags();

            if (TelemetryConfiguration.MetricsEnabled)
            {
                _metricWrapper = new MetricWrapper(commonTags);
            }

            if (TelemetryConfiguration.TracingEnabled)
            {
                OpenTracing.ISpanContext parentContext = null;
                if (TelemetryConfiguration.ContextPropagationEnabled && headers != null)
                {
                    var tracer = GlobalTracer.Instance;
                    parentContext = tracer.Extract(BuiltinFormats.HttpHeaders, new TextMapExtractAdapter(headers));
                }

                operationName = operationName ?? lambdaContext.FunctionName;
                _otScope      = s_otTracer.BuildSpan(operationName)
                                .AsChildOf(parentContext)
                                .WithTag("span.kind", "server")
                                .WithTag("component", "dotnet-lambda-wrapper")
                                .WithTag("aws_request_id", lambdaContext.AwsRequestId)
                                .StartActive();

                var otSpan = _otScope.Span;
                foreach (var kvp in commonTags)
                {
                    otSpan.SetTag(kvp.Key, kvp.Value);
                }

                if (coldStart)
                {
                    otSpan.SetTag("cold_start", "true");
                }

                if (tags != null)
                {
                    foreach (var kvp in tags)
                    {
                        otSpan.SetTag(kvp.Key, kvp.Value);
                    }
                }
            }
        }
Esempio n. 3
0
 protected internal static void setWrapper(MetricWrapper wrapper)
 {
     singleton = wrapper;
 }