Skip to content

Commit

Permalink
Various telemetry updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ejsmith committed Oct 31, 2024
1 parent 5e3ab1d commit 8ca4f2e
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<ReferenceFoundatioSource>false</ReferenceFoundatioSource>
<ReferenceFoundatioRepositoriesSource>false</ReferenceFoundatioRepositoriesSource>
<FoundatioVersion>11.0.5</FoundatioVersion>
<FoundatioVersion>11.0.6-alpha.0.18</FoundatioVersion>
<AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio>
</PropertyGroup>

Expand Down
12 changes: 6 additions & 6 deletions src/Exceptionless.Insulation/Exceptionless.Insulation.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<ItemGroup>
<PackageReference Include="Geocoding.Google" Version="4.0.1" />
<PackageReference Include="MaxMind.GeoIP2" Version="5.2.0" />
<PackageReference Include="Foundatio.Aliyun" Version="$(FoundatioVersion)" />
<PackageReference Include="Foundatio.AWS" Version="$(FoundatioVersion)" />
<PackageReference Include="Foundatio.AzureStorage" Version="$(FoundatioVersion)" />
<PackageReference Include="Foundatio.Minio" Version="$(FoundatioVersion)" />
<PackageReference Include="Foundatio.RabbitMQ" Version="$(FoundatioVersion)" />
<PackageReference Include="Foundatio.Redis" Version="$(FoundatioVersion)" />
<PackageReference Include="Foundatio.Aliyun" Version="11.0.5" />
<PackageReference Include="Foundatio.AWS" Version="11.0.5" />
<PackageReference Include="Foundatio.AzureStorage" Version="11.0.5" />
<PackageReference Include="Foundatio.Minio" Version="11.0.5" />
<PackageReference Include="Foundatio.RabbitMQ" Version="11.0.5" />
<PackageReference Include="Foundatio.Redis" Version="11.0.5" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="9.0.0-rc.2.24473.5" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="9.0.0-rc.2.24473.5" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.0-rc.2.24473.5" />
Expand Down
3 changes: 1 addition & 2 deletions src/Exceptionless.Job/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ public static IHostBuilder CreateHostBuilder(string[] args)
var options = AppOptions.ReadFromConfiguration(config);
var apmConfig = new ApmConfig(config, $"job-{jobOptions.JobName.ToLowerUnderscoredWords('-')}", options.InformationalVersion, options.CacheOptions.Provider == "redis");

var configDictionary = config.ToDictionary("Serilog");
Log.Information("Bootstrapping Exceptionless {JobName} job(s) in {AppMode} mode ({InformationalVersion}) on {MachineName} with settings {@Settings}", jobOptions.JobName ?? "All", environment, options.InformationalVersion, Environment.MachineName, configDictionary);
Log.Information("Bootstrapping Exceptionless {JobName} job(s) in {AppMode} mode ({InformationalVersion}) on {MachineName} with options {@Options}", jobOptions.JobName ?? "All", environment, options.InformationalVersion, Environment.MachineName, options);

var builder = Host.CreateDefaultBuilder()
.UseEnvironment(environment)
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptionless.Job/appsettings.Development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ BaseURL: 'http://localhost:9001/#!'

Serilog:
MinimumLevel:
Default: Debug
Default: Information

Apm:
EnableLogs: false
Expand Down
44 changes: 43 additions & 1 deletion src/Exceptionless.Web/ApmExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static IHostBuilder AddApm(this IHostBuilder builder, ApmConfig config)
builder.ConfigureServices(services =>
{
services.AddSingleton(config);
services.AddHostedService(sp => new SelfDiagnosticsLoggingHostedService(sp.GetRequiredService<ILoggerFactory>(), config.Debug ? EventLevel.Verbose : null));
//services.AddHostedService(sp => new SelfDiagnosticsLoggingHostedService(sp.GetRequiredService<ILoggerFactory>(), config.Debug ? EventLevel.Verbose : null));

services.AddOpenTelemetry().WithTracing(b =>
{
Expand All @@ -41,6 +41,9 @@ public static IHostBuilder AddApm(this IHostBuilder builder, ApmConfig config)
if (context.Request.Path.StartsWithSegments("/api/v2/push", StringComparison.OrdinalIgnoreCase))
return false;

if (context.Request.Path.StartsWithSegments("/health", StringComparison.OrdinalIgnoreCase))
return false;

if (context.Request.Headers.UserAgent.ToString().Contains("HealthChecker"))
return false;

Expand Down Expand Up @@ -84,7 +87,30 @@ public static IHostBuilder AddApm(this IHostBuilder builder, ApmConfig config)
b.AddConsoleExporter();

if (config.EnableExporter)
{
b.AddProcessor(new FilteringProcessor(activity =>
{
// filter out insignificant activities
if (config.MinDurationMs > 0 && activity.Duration < TimeSpan.FromMilliseconds(config.MinDurationMs))
return false;

if (activity is { DisplayName: "LLEN", Parent: null })
return false;

if (activity.DisplayName == "Elasticsearch HEAD")
return false;

if (activity.GetTagItem("db.statement") is not string statement)
return true;

if (statement.EndsWith("__PING__"))
return false;

return true;
}));

b.AddOtlpExporter();
}
});

services.AddOpenTelemetry().WithMetrics(b =>
Expand Down Expand Up @@ -174,3 +200,19 @@ public ApmConfig(IConfigurationRoot config, string processName, string? serviceV
public bool Debug => _apmConfig.GetValue("Debug", false);
public bool Console => _apmConfig.GetValue("Console", false);
}

public class FilteringProcessor : BaseProcessor<Activity>
{
private readonly Func<Activity, bool> _filter;

public FilteringProcessor(Func<Activity, bool> filter)
{
_filter = filter ?? throw new ArgumentNullException(nameof(filter));
}

public override void OnEnd(Activity activity)
{
if (!_filter(activity))
activity.ActivityTraceFlags &= ~ActivityTraceFlags.Recorded;
}
}
3 changes: 1 addition & 2 deletions src/Exceptionless.Web/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ public static IHostBuilder CreateHostBuilder(IConfigurationRoot config, string e
var options = AppOptions.ReadFromConfiguration(config);
var apmConfig = new ApmConfig(config, "web", options.InformationalVersion, options.CacheOptions.Provider == "redis");

var configDictionary = config.ToDictionary("Serilog");
Log.Information("Bootstrapping Exceptionless Web in {AppMode} mode ({InformationalVersion}) on {MachineName} with settings {@Settings}", environment, options.InformationalVersion, Environment.MachineName, configDictionary);
Log.Information("Bootstrapping Exceptionless Web in {AppMode} mode ({InformationalVersion}) on {MachineName} with options {@Options}", environment, options.InformationalVersion, Environment.MachineName, options);

SetClientEnvironmentVariablesInDevelopmentMode(options);

Expand Down
2 changes: 1 addition & 1 deletion src/Exceptionless.Web/appsettings.Development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ RunJobsInProcess: true

Serilog:
MinimumLevel:
Default: Debug
Default: Information

Apm:
EnableLogs: true
Expand Down

0 comments on commit 8ca4f2e

Please sign in to comment.