Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Core/Resgrid.Config/ExternalErrorConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public static class ExternalErrorConfig
public static string ExternalErrorServiceUrlForInternalApi = "";
public static string ExternalErrorServiceUrlForInternalWorker = "";
public static string ExternalErrorServiceUrlForMcp = "";
public static string ExternalErrorServiceUrlForTts = "";
public static double SentryPerfSampleRate = 0.4;
public static double SentryProfilingSampleRate = 0;
#endregion Sentry Settings
Expand Down
13 changes: 11 additions & 2 deletions Web/Resgrid.Web.Tts/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,17 @@ WORKDIR /src/Web/Resgrid.Web.Tts
RUN dotnet publish "Resgrid.Web.Tts.csproj" -c Release -o /app/publish /p:UseAppHost=false --no-restore -p:Version=${BUILD_VERSION}

FROM base AS final
RUN apt-get update \
&& apt-get install -y --no-install-recommends espeak-ng ffmpeg ca-certificates \
# Enable multiverse repository for MBROLA packages, install TTS dependencies,
# then clean up in a single RUN layer to keep the image small.
RUN echo "deb http://archive.ubuntu.com/ubuntu/ noble multiverse" >> /etc/apt/sources.list \
&& echo "deb http://archive.ubuntu.com/ubuntu/ noble-updates multiverse" >> /etc/apt/sources.list \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
espeak-ng \
ffmpeg \
ca-certificates \
mbrola \
mbrola-us1 \
&& rm -rf /var/lib/apt/lists/* \
&& groupadd --gid 10001 appgroup \
&& useradd --uid 10001 --gid appgroup --create-home --shell /usr/sbin/nologin appuser
Expand Down
40 changes: 40 additions & 0 deletions Web/Resgrid.Web.Tts/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,54 @@
using Resgrid.Web.Tts.Configuration;
using Resgrid.Web.Tts.Health;
using Resgrid.Web.Tts.Services;
using System.Reflection;
using System.Text.Json;
using System.Threading.RateLimiting;
using Sentry.Profiling;

var builder = WebApplication.CreateBuilder(args);

ConfigProcessor.LoadAndProcessConfig(builder.Configuration["AppOptions:ConfigPath"]);
ConfigProcessor.LoadAndProcessEnvVariables(builder.Configuration.AsEnumerable());

// Configure Sentry error tracking and performance monitoring
if (!string.IsNullOrWhiteSpace(ExternalErrorConfig.ExternalErrorServiceUrlForTts))
{
builder.WebHost.UseSentry(options =>
{
options.Dsn = ExternalErrorConfig.ExternalErrorServiceUrlForTts;
options.AttachStacktrace = true;
options.SendDefaultPii = true;
options.AutoSessionTracking = true;
options.TracesSampleRate = ExternalErrorConfig.SentryPerfSampleRate;
options.Environment = ExternalErrorConfig.Environment;
options.Release = Assembly.GetEntryAssembly()?.GetName().Version?.ToString();
options.ProfilesSampleRate = ExternalErrorConfig.SentryProfilingSampleRate;

// Add profiling integration for performance tracing
options.AddIntegration(new ProfilingIntegration());

options.TracesSampler = samplingContext =>
{
if (samplingContext?.CustomSamplingContext != null)
{
if (samplingContext.CustomSamplingContext.TryGetValue("__HttpPath", out var httpPath))
{
var pathValue = httpPath?.ToString();
if (string.Equals(pathValue, "/health", StringComparison.OrdinalIgnoreCase) ||
string.Equals(pathValue, "/livez", StringComparison.OrdinalIgnoreCase) ||
string.Equals(pathValue, "/readyz", StringComparison.OrdinalIgnoreCase))
{
return 0;
}
}
}

return ExternalErrorConfig.SentryPerfSampleRate;
};
});
}

builder.Logging.ClearProviders();
builder.Logging.AddJsonConsole();

Expand Down
2 changes: 2 additions & 0 deletions Web/Resgrid.Web.Tts/Resgrid.Web.Tts.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<ItemGroup>
<PackageReference Include="AWSSDK.S3" Version="3.7.414.5" />
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="9.0.2" />
<PackageReference Include="Sentry.AspNetCore" Version="5.4.0" />
<PackageReference Include="Sentry.Profiling" Version="5.4.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="8.0.0" />
</ItemGroup>

Expand Down
9 changes: 8 additions & 1 deletion Web/Resgrid.Web.Tts/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,17 @@
"Amazon": "Warning"
}
},
"Sentry": {
"IncludeActivityData": true,
"MaxBreadcrumbs": 50,
"MinimumBreadcrumbLevel": "Information",
"MinimumEventLevel": "Error",
"Debug": false
},
"AppOptions": {
"ConfigPath": ""
},
"_Comment": "TTS runtime settings are loaded from Resgrid.Config.TtsConfig via ResgridConfig.json or RESGRID:TtsConfig:* environment variables.",
"_Comment": "TTS runtime settings are loaded from Resgrid.Config.TtsConfig via ResgridConfig.json or RESGRID:TtsConfig:* environment variables. Sentry DSN uses ExternalErrorConfig.ExternalErrorServiceUrlForTts.",
"AllowedHosts": "*",
"ConnectionStrings": {
}
Expand Down
Loading