Skip to content

Commit

Permalink
fix: or-2583 roll back to before telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
koenmetsu committed Jan 27, 2025
1 parent 2391c30 commit 2e15cfe
Showing 1 changed file with 8 additions and 26 deletions.
34 changes: 8 additions & 26 deletions src/AssociationRegistry.KboMutations.SyncLambda/Function.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using AssociationRegistry.KboMutations.SyncLambda.JsonSerialization;
using AssociationRegistry.KboMutations.SyncLambda.Logging;
using AssociationRegistry.Magda;
using AssociationRegistry.Magda.Models;
using Marten;
using Marten.Events;
using Marten.Services;
Expand All @@ -19,21 +20,17 @@
using Npgsql;
using Weasel.Core;
using PostgreSqlOptionsSection = AssociationRegistry.KboMutations.SyncLambda.Logging.PostgreSqlOptionsSection;
using SsmClientWrapper = AssociationRegistry.KboMutations.SsmClientWrapper;

namespace AssociationRegistry.KboMutations.SyncLambda;

using KboMutations.Configuration;
using Magda.Models;
using Notifications;
using System.Diagnostics.Metrics;

public class Function
{
private static OpenTelemetrySetup _openTelemetrySetup;

private static async Task Main()
{

var handler = FunctionHandler;
await LambdaBootstrapBuilder.Create(handler, new SourceGeneratorLambdaJsonSerializer<LambdaFunctionJsonSerializerContext>())
.Build()
Expand All @@ -42,12 +39,10 @@ private static async Task Main()

private static async Task FunctionHandler(SQSEvent @event, ILambdaContext context)
{


var configurationBuilder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", true, true)
.AddEnvironmentVariables();
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", true, true)
.AddEnvironmentVariables();

var configuration = configurationBuilder.Build();
var awsConfigurationSection = configuration
Expand All @@ -71,20 +66,11 @@ private static async Task FunctionHandler(SQSEvent @event, ILambdaContext contex
var eventConflictResolver = new EventConflictResolver(Array.Empty<IEventPreConflictResolutionStrategy>(),
Array.Empty<IEventPostConflictResolutionStrategy>());

_openTelemetrySetup = new OpenTelemetrySetup(context.Logger, configuration);

var loggerFactory = LoggerFactory.Create(builder =>
{
builder.AddProvider(new LambdaLoggerProvider(context.Logger));

_openTelemetrySetup.SetUpLogging(builder);
});

var meter = new Meter(OpenTelemetrySetup.MeterName);

var counter = meter.CreateCounter<int>("kbosync_started");
counter.Add(1);

var repository = new VerenigingsRepository(new EventStore.EventStore(store, eventConflictResolver, loggerFactory.CreateLogger<EventStore.EventStore>()));

var geefOndernemingService = new MagdaGeefVerenigingService(
Expand Down Expand Up @@ -113,9 +99,9 @@ private static async Task FunctionHandler(SQSEvent @event, ILambdaContext contex
context.Logger.LogInformation($"{@event.Records.Count} RECORDS PROCESSED BY THE MESSAGE PROCESSOR");
}

public static async Task<MagdaOptionsSection> GetMagdaOptions(IConfiguration config,
SsmClientWrapper ssmClient,
ParamNamesConfiguration? paramNamesConfiguration)
private static async Task<MagdaOptionsSection> GetMagdaOptions(IConfiguration config,
SsmClientWrapper ssmClient,
ParamNamesConfiguration? paramNamesConfiguration)
{
var magdaOptions = config.GetSection(MagdaOptionsSection.SectionName)
.Get<MagdaOptionsSection>();
Expand All @@ -142,10 +128,6 @@ private static async Task<DocumentStore> SetUpDocumentStore(IConfiguration confi
throw new ApplicationException("PostgresSqlOptions is missing some values");

var opts = new StoreOptions();

opts.OpenTelemetry.TrackConnections = TrackLevel.Normal;
opts.OpenTelemetry.TrackEventCounters();

var connectionStringBuilder = new NpgsqlConnectionStringBuilder();
connectionStringBuilder.Host = postgresSection.Host;
connectionStringBuilder.Database = postgresSection.Database;
Expand Down

0 comments on commit 2e15cfe

Please sign in to comment.