Skip to content

Commit

Permalink
try moving onend from namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
andracc committed Oct 9, 2024
1 parent 8c37dee commit a5a6801
Showing 1 changed file with 56 additions and 54 deletions.
110 changes: 56 additions & 54 deletions Backend/Otel/OtelKernel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using OpenTelemetry.Resources;
using OpenTelemetry.Trace;
using System.Linq;
using BackendFramework.Otel;

namespace BackendFramework.Otel
{
Expand Down Expand Up @@ -145,70 +146,71 @@ public static void AddOpenTelemetryInstrumentation(this IServiceCollection servi

}
}
}

internal class LocationEnricher(ILocationProvider locationProvider) : BaseProcessor<Activity>
internal class LocationEnricher(ILocationProvider locationProvider) : BaseProcessor<Activity>
{
public override async void OnEnd(Activity data)
{
public override async void OnEnd(Activity data)
string? uriPath = (string?)data.GetTagItem("url.full");
string locationUri = LocationProvider.locationGetterUri;

if (uriPath == null || !uriPath.Contains(locationUri))
{
string? uriPath = (string?)data.GetTagItem("url.full");
string locationUri = LocationProvider.locationGetterUri;
LocationApi? response = await locationProvider.GetLocation();

if (uriPath == null || !uriPath.Contains(locationUri))
var location = new
{
LocationApi? response = await locationProvider.GetLocation();

var location = new
{
Country = response?.country,
Region = response?.regionName,
City = response?.city,
};

data?.AddTag("country", location.Country);
data?.AddTag("region", location.Region);
data?.AddTag("city", location.City);
}
Country = response?.country,
Region = response?.regionName,
City = response?.city,
};

data?.SetTag("SESSIONID BAGGAGE", data?.GetBaggageItem("sessionId"));
if (uriPath != null && uriPath.Contains(locationUri))
{
data?.SetTag("url.full", "");
data?.SetTag("url.redacted.ip", LocationProvider.locationGetterUri);
}
data?.AddTag("country", location.Country);
data?.AddTag("region", location.Region);
data?.AddTag("city", location.City);
}

data?.SetTag("SESSIONID BAGGAGE", data?.GetBaggageItem("sessionId"));
if (uriPath != null && uriPath.Contains(locationUri))
{
data?.SetTag("url.full", "");
data?.SetTag("url.redacted.ip", LocationProvider.locationGetterUri);
}

}
}



// internal class LocationEnricher(ILocationProvider locationProvider) : BaseProcessor<Activity>
// {
// public override async void OnEnd(Activity data)
// {
// string? uriPath = (string?)data.GetTagItem("url.full");
// string locationUri = LocationProvider.locationGetterUri;
// if (uriPath == null || !uriPath.Contains(locationUri))
// {
// LocationApi? response = await locationProvider.GetLocation();

// // var location = new LocationApi
// // {
// // Country = response?.country,
// // Region = response?.regionName,
// // City = response?.city
// // };

// data?.AddTag("country", response?.country);
// data?.AddTag("regionName", response?.regionName);
// data?.AddTag("city", response?.city);
// }
// data?.SetTag("SESSIONID BAGGAGE", data?.GetBaggageItem("sessionId"));
// if (uriPath != null && uriPath.Contains(locationUri))
// {
// data?.SetTag("url.full", "");
// data?.SetTag("url.redacted.ip", LocationProvider.locationGetterUri);
// }
// }
// }
// internal class LocationEnricher(ILocationProvider locationProvider) : BaseProcessor<Activity>
// {
// public override async void OnEnd(Activity data)
// {
// string? uriPath = (string?)data.GetTagItem("url.full");
// string locationUri = LocationProvider.locationGetterUri;
// if (uriPath == null || !uriPath.Contains(locationUri))
// {
// LocationApi? response = await locationProvider.GetLocation();

// // var location = new LocationApi
// // {
// // Country = response?.country,
// // Region = response?.regionName,
// // City = response?.city
// // };

// data?.AddTag("country", response?.country);
// data?.AddTag("regionName", response?.regionName);
// data?.AddTag("city", response?.city);
// }
// data?.SetTag("SESSIONID BAGGAGE", data?.GetBaggageItem("sessionId"));
// if (uriPath != null && uriPath.Contains(locationUri))
// {
// data?.SetTag("url.full", "");
// data?.SetTag("url.redacted.ip", LocationProvider.locationGetterUri);
// }
// }
// }


}

0 comments on commit a5a6801

Please sign in to comment.