diff --git a/Backend/Otel/OtelKernel.cs b/Backend/Otel/OtelKernel.cs index 74842e3da1..afc4282701 100644 --- a/Backend/Otel/OtelKernel.cs +++ b/Backend/Otel/OtelKernel.cs @@ -33,6 +33,12 @@ public static void AddOpenTelemetryInstrumentation(this IServiceCollection servi ); } + internal static void TrackConsent(Activity activity, HttpRequest request) + { + var consent = request.Headers.TryGetValue("otelConsent", out var values) ? values.FirstOrDefault() : "nothing"; + activity.SetBaggage("otelConsent", consent); + } + internal static void TrackSession(Activity activity, HttpRequest request) { var sessionId = request.Headers.TryGetValue("sessionId", out var values) ? values.FirstOrDefault() : null; @@ -67,7 +73,9 @@ private static void AspNetCoreBuilder(AspNetCoreTraceInstrumentationOptions opti options.EnrichWithHttpRequest = (activity, request) => { GetContentLengthAspNet(activity, request.Headers, "inbound.http.request.body.size"); + TrackConsent(activity, request); TrackSession(activity, request); + }; options.EnrichWithHttpResponse = (activity, response) => { @@ -98,7 +106,8 @@ internal class LocationEnricher(ILocationProvider locationProvider) : BaseProces { public override async void OnEnd(Activity data) { - var uriPath = (string?)data.GetTagItem("url.full"); + data?.SetTag("consent value", data?.GetBaggageItem("otelConsent")); + var uriPath = (string?)data?.GetTagItem("url.full"); var locationUri = LocationProvider.locationGetterUri; if (uriPath is null || !uriPath.Contains(locationUri)) { diff --git a/src/backend/index.ts b/src/backend/index.ts index 33bf1c40bc..d23a822041 100644 --- a/src/backend/index.ts +++ b/src/backend/index.ts @@ -55,6 +55,9 @@ const whiteListedErrorUrls = [ const axiosInstance = axios.create({ baseURL: apiBaseURL }); axiosInstance.interceptors.request.use((config: InternalAxiosRequestConfig) => { config.headers.sessionId = getSessionId(); + LocalStorage.getCurrentUser()?.otelConsent + ? (config.headers.otelConsent = "yay") + : (config.headers.otelConsent = "nay"); return config; }); axiosInstance.interceptors.response.use(undefined, (err: AxiosError) => {