private static bool ValidateOKStatus(HttpWebResponse response) { var statusCode = response.StatusCode; Serverless.Debug("The extension responds with statusCode = " + statusCode); return(statusCode == HttpStatusCode.OK); }
internal static Scope CreatePlaceholderScope(Tracer tracer, string traceId, string samplingPriority) { Span span = null; if (traceId == null) { Serverless.Debug("traceId not found"); span = tracer.StartSpan(PlaceholderOperationName, tags: null, serviceName: PlaceholderServiceName, addToTraceContext: false); } else { Serverless.Debug($"creating the placeholder traceId = {traceId}"); span = tracer.StartSpan(PlaceholderOperationName, tags: null, serviceName: PlaceholderServiceName, traceId: TraceId.CreateFromUlong(Convert.ToUInt64(traceId)), addToTraceContext: false); } if (samplingPriority == null) { Serverless.Debug($"samplingPriority not found"); span.Context.TraceContext.SetSamplingPriority(tracer.TracerManager.Sampler?.GetSamplingPriority(span)); } else { Serverless.Debug($"setting the placeholder sampling proirity to = {samplingPriority}"); span.Context.TraceContext.SetSamplingPriority(Convert.ToInt32(samplingPriority)); } return(tracer.TracerManager.ScopeManager.Activate(span, false)); }
private static string SerializeObject <T>(T obj) { try { return(JsonConvert.SerializeObject(obj)); } catch (Exception ex) { Serverless.Debug("Failed to serialize object with the following error: " + ex.ToString()); return(DefaultJson); } }
private static void NotifyExtensionEnd(ILambdaExtensionRequest requestBuilder, Scope scope, bool isError, string json = DefaultJson) { try { if (!SendEndInvocation(requestBuilder, scope, isError, json)) { Serverless.Debug("Extension does not send a status 200 OK"); } } catch (Exception ex) { Serverless.Error("Could not send payload to the extension", ex); } }
internal static void NotifyExtensionEnd(ILambdaExtensionRequest requestBuilder, bool isError) { try { if (!SendEndInvocation(requestBuilder, isError)) { Serverless.Debug("Extension does not send a status 200 OK"); } } catch (Exception ex) { Serverless.Error("Could not send payload to the extension", ex); } }
internal static void NotifyExtensionStart(ILambdaExtensionRequest requestBuilder, string json) { try { if (!SendStartInvocation(requestBuilder, json)) { Serverless.Debug("Extension does not send a status 200 OK"); } } catch (Exception ex) { Serverless.Error("Could not send payload to the extension", ex); } }
internal static CallTargetState StartInvocation <TArg>(TArg payload, ILambdaExtensionRequest requestBuilder) { var json = DefaultJson; try { json = JsonConvert.SerializeObject(payload); } catch (Exception) { Serverless.Debug("Could not serialize input"); } NotifyExtensionStart(requestBuilder, json); return(new CallTargetState(CreatePlaceholderScope(Tracer.Instance, requestBuilder))); }
private static Scope NotifyExtensionStart(ILambdaExtensionRequest requestBuilder, string json, IDictionary <string, string> context) { Scope scope = null; try { scope = SendStartInvocation(requestBuilder, json, context); if (scope == null) { Serverless.Debug("Error while creating the scope"); } } catch (Exception ex) { Serverless.Error("Could not send payload to the extension", ex); } return(scope); }
internal static Scope CreatePlaceholderScope(Tracer tracer, ILambdaExtensionRequest requestBuilder) { Scope scope = null; try { var request = requestBuilder.GetTraceContextRequest(); using (var response = (HttpWebResponse)request.GetResponse()) { var traceId = response.Headers.Get(HttpHeaderNames.TraceId); // need to set the exact same spanId so nested spans (auto-instrumentation or manual) will have the correct parent-id var spanId = response.Headers.Get(HttpHeaderNames.SpanId); Serverless.Debug($"received traceId = {traceId} and spanId = {spanId}"); var span = tracer.StartSpan(PlaceholderOperationName, null, serviceName: PlaceholderServiceName, traceId: Convert.ToUInt64(traceId), spanId: Convert.ToUInt64(spanId), addToTraceContext: false); scope = tracer.TracerManager.ScopeManager.Activate(span, false); } } catch (Exception ex) { Serverless.Error("Error creating the placeholder scope", ex); } return(scope); }
/// <summary> /// OnMethodBegin callback /// </summary> /// <typeparam name="TTarget">Type of the target</typeparam> /// <typeparam name="TArg">Type of the incomingEventOrContent</typeparam> /// <param name="instance">Instance value, aka `this` of the instrumented method.</param> /// <param name="incomingEventOrContext">IncomingEventOrContext value</param> /// <returns>Calltarget state value</returns> internal static CallTargetState OnMethodBegin <TTarget, TArg>(TTarget instance, TArg incomingEventOrContext) { Serverless.Debug("OnMethodBegin - one param"); return(LambdaCommon.StartInvocation(incomingEventOrContext, RequestBuilder)); }
/// <summary> /// OnMethodBegin callback /// </summary> /// <typeparam name="TTarget">Type of the target</typeparam> /// <param name="instance">Instance value, aka `this` of the instrumented method.</param> /// <returns>Calltarget state value</returns> internal static CallTargetState OnMethodBegin <TTarget>(TTarget instance) { Serverless.Debug("OnMethodBegin - no param"); return(LambdaCommon.StartInvocationWithoutEvent(RequestBuilder)); }
/// <summary> /// OnMethodBegin callback /// </summary> /// <typeparam name="TTarget">Type of the target</typeparam> /// <typeparam name="TArg1">Type of the incommingEvent</typeparam> /// <typeparam name="TArg2">Type of the context</typeparam> /// <param name="instance">Instance value, aka `this` of the instrumented method.</param> /// <param name="incommingEvent">IncommingEvent value</param> /// <param name="context">Context value.</param> /// <returns>Calltarget state value</returns> internal static CallTargetState OnMethodBegin <TTarget, TArg1, TArg2>(TTarget instance, TArg1 incommingEvent, TArg2 context) { Serverless.Debug("OnMethodBeginOK - two params"); return(LambdaCommon.StartInvocation(incommingEvent, RequestBuilder)); }