private static void ServiceRemotingServiceEvents_ReceiveRequest(object?sender, EventArgs?e) { var tracer = Tracer.Instance; if (!_initialized || !tracer.Settings.IsIntegrationEnabled(ServiceRemotingConstants.IntegrationId)) { return; } ServiceRemotingHelpers.GetMessageHeaders(e, out var eventArgs, out var messageHeaders); SpanContext?spanContext = null; try { // extract propagation context from message headers for distributed tracing if (messageHeaders != null) { spanContext = SpanContextPropagator.Instance.Extract(messageHeaders, GetHeaders); } } catch (Exception ex) { Log.Error(ex, "Error extracting span context from Service Fabric Service Remoting message headers."); } try { var span = ServiceRemotingHelpers.CreateSpan(tracer, spanContext, SpanKinds.Server, eventArgs, messageHeaders); tracer.ActivateSpan(span); } catch (Exception ex) { Log.Error(ex, "Error creating or activating new Service Fabric Service Remoting service span."); } }
private static void ServiceRemotingClientEvents_SendRequest(object?sender, EventArgs?e) { var tracer = Tracer.Instance; if (!_initialized || !tracer.Settings.IsIntegrationEnabled(ServiceRemotingConstants.IntegrationId)) { return; } ServiceRemotingHelpers.GetMessageHeaders(e, out var eventArgs, out var messageHeaders); try { var span = ServiceRemotingHelpers.CreateSpan(tracer, context: null, SpanKinds.Client, eventArgs, messageHeaders); try { // inject propagation context into message headers for distributed tracing if (messageHeaders != null) { SpanContextPropagator.Instance.Inject( span.Context, messageHeaders, static (headers, headerName, headerValue) => headers.TryAddHeader(headerName, headerValue)); } } catch (Exception ex) { Log.Error(ex, "Error injecting span context into Service Fabric Service Remoting message headers."); } tracer.ActivateSpan(span); } catch (Exception ex) { Log.Error(ex, "Error creating or activating Service Fabric Service Remoting client span."); } }