Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
Mpdreamz committed Apr 4, 2024
2 parents 50720b0 + 7c93454 commit e23b38e
Show file tree
Hide file tree
Showing 15 changed files with 75 additions and 43 deletions.
13 changes: 6 additions & 7 deletions .github/workflows/opentelemetry.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
---
# Look up results at https://ela.st/oblt-ci-cd-stats
# There will be one service per GitHub repository, including the org name, and one Transaction per Workflow.
name: OpenTelemetry Export Trace

on:
workflow_run:
workflows:
- pre-commit
- release
- release-main
- test
- test-reporter
- update-specs
workflows: [ "*" ]
types: [completed]

permissions:
contents: read

jobs:
otel-export-trace:
runs-on: ubuntu-latest
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/test-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This workflow sets the 'test' status check to success in case it's a docs only PR and e2e.yml is not triggered
# https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks#handling-skipped-but-required-checks
name: test # The name must be the same as in test.yml

on:
pull_request:
paths-ignore: # This expression needs to match the paths ignored on e2e.yml.
- '**'
- '!*.md'
- '!*.asciidoc'
- '!docs/**'

permissions:
contents: read

## Concurrency only allowed in the main branch.
## So old builds running for old commits within the same Pull Request are cancelled
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:

test-windows:
runs-on: windows-latest

steps:
- run: 'echo "Not required for docs"'

test-linux:
runs-on: ubuntu-latest

steps:
- run: 'echo "Not required for docs"'
4 changes: 4 additions & 0 deletions .github/workflows/test-reporter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ on:
types:
- completed

permissions:
contents: read
actions: read

jobs:
report:
runs-on: ubuntu-latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<PackageReference Include="Serilog" Version="2.10.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.0" />
<PackageReference Include="Elastic.Elasticsearch.Ephemeral" Version="0.4.3" />
<PackageReference Include="Elastic.Clients.Elasticsearch" Version="8.0.4" />
<PackageReference Include="Elastic.Clients.Elasticsearch" Version="8.12.1" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="5.0.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
</ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions examples/Elastic.Serilog.Sinks.Example/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Elastic.Serilog.Sinks.Example;
using Elastic.Elasticsearch.Ephemeral;
using Elastic.Ingest.Elasticsearch;
using Elastic.Transport;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<ItemGroup>
<PackageReference Include="Elastic.Elasticsearch.Ephemeral" Version="0.4.3" />
<PackageReference Include="Elastic.Clients.Elasticsearch" Version="8.0.4" />
<PackageReference Include="Elastic.Clients.Elasticsearch" Version="8.12.1" />
</ItemGroup>

<ItemGroup>
Expand Down
16 changes: 5 additions & 11 deletions examples/aspnetcore-with-serilog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,13 @@ public static IWebHost BuildWebHost(string[] args) =>
.UseStartup<Startup>()
.UseSerilog((ctx, config) =>
{
config.ReadFrom.Configuration(ctx.Configuration);

// Ensure HttpContextAccessor is accessible
// Ensure HttpContextAccessor is accessible
var httpAccessor = ctx.Configuration.Get<HttpContextAccessor>();

// Create a formatter configuration to se this accessor
var formatterConfig = new EcsTextFormatterConfiguration();
formatterConfig.MapHttpContext(httpAccessor);

// Write events to the console using this configration
var formatter = new EcsTextFormatter(formatterConfig);

config.WriteTo.Console(formatter);
config
.ReadFrom.Configuration(ctx.Configuration)
.Enrich.WithEcsHttpContext(httpAccessor)
.WriteTo.Async(a => a.Console(new EcsTextFormatter()));
})
.UseKestrel()
.Build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ public ElasticsearchBenchmarkExporter(ElasticsearchBenchmarkExporterOptions opti
{
Options = options;
var config = Options.CreateTransportConfiguration();
Transport = new DefaultHttpTransport<TransportConfiguration>(config);
Transport = new DistributedTransport<TransportConfiguration>(config);
}

// ReSharper disable once UnusedMember.Global
/// <summary> Exports benchmark results to Elasticsearch </summary>
public ElasticsearchBenchmarkExporter(ElasticsearchBenchmarkExporterOptions options, Func<ElasticsearchBenchmarkExporterOptions, TransportConfiguration> configure)
{
Options = options;
Transport = new DefaultHttpTransport<TransportConfiguration>(configure(Options));
Transport = new DistributedTransport<TransportConfiguration>(configure(Options));
}


private HttpTransport<TransportConfiguration> Transport { get; }
private ITransport<TransportConfiguration> Transport { get; }
private ElasticsearchBenchmarkExporterOptions Options { get; }

// We only log when we cannot write to Elasticsearch
Expand Down
4 changes: 2 additions & 2 deletions src/Elastic.Extensions.Logging/ElasticsearchLoggerProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private static NodePool CreateNodePool(ElasticsearchLoggerOptions loggerOptions)
}
}

private static HttpTransport CreateTransport(ElasticsearchLoggerOptions loggerOptions)
private static ITransport CreateTransport(ElasticsearchLoggerOptions loggerOptions)
{
// TODO: Check if Uri has changed before recreating
// TODO: Injectable factory? Or some way of testing.
Expand All @@ -137,7 +137,7 @@ private static HttpTransport CreateTransport(ElasticsearchLoggerOptions loggerOp
if (loggerOptions.ShipTo.NodePoolType != NodePoolType.Cloud)
config = SetAuthenticationOnTransport(loggerOptions, config);

var transport = new DefaultHttpTransport<TransportConfiguration>(config);
var transport = new DistributedTransport<TransportConfiguration>(config);
return transport;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Elastic.Extensions.Logging/LoggingBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,13 @@ Action<ElasticsearchChannelOptionsBase<LogEvent>> configureChannel

/// <summary>
/// Log to Elasticsearch
/// <para>This overload also allows you to reuse an instance of <see cref="HttpTransport"/></para>
/// <para>This overload also allows you to reuse an instance of <see cref="ITransport"/></para>
/// <para>Further configuration can be provided through the <paramref name="configure"/> parameter</para>
/// <para>Expert channel configuration can be provided to the <paramref name="configureChannel"/> parameter</para>
/// </summary>
public static ILoggingBuilder AddElasticsearch(
this ILoggingBuilder builder,
HttpTransport transport,
ITransport transport,
Action<ElasticsearchLoggerOptions>? configure = null,
Action<ElasticsearchChannelOptionsBase<LogEvent>>? configureChannel = null
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ public class ElasticsearchLoggerOptions : IEcsDocumentCreationOptions
public string[]? Tags { get; set; }

/// <summary>
/// Allows the direct setting of a <see cref="HttpTransport{TConfiguration}"/> to be used to communicate with Elasticsearch.
/// Allows the direct setting of a <see cref="ITransport{TConfiguration}"/> to be used to communicate with Elasticsearch.
/// <para>If set takes precedence over <see cref="ShipTo"/> </para>
/// </summary>
public HttpTransport? Transport { get; set; }
public ITransport? Transport { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Elastic.Ingest.Elasticsearch" Version="0.5.5" />
<PackageReference Include="Elastic.Ingest.Elasticsearch" Version="0.6.0" />
</ItemGroup>

</Project>
10 changes: 5 additions & 5 deletions src/Elastic.Serilog.Sinks/ElasticsearchSink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@ public class ElasticsearchSinkOptions : ElasticsearchSinkOptions<EcsDocument>
public ElasticsearchSinkOptions() { }

/// <inheritdoc cref="ElasticsearchSinkOptions"/>
public ElasticsearchSinkOptions(HttpTransport transport) : base(transport) { }
public ElasticsearchSinkOptions(ITransport transport) : base(transport) { }
}

/// <inheritdoc cref="ElasticsearchSinkOptions{TEcsDocument}"/>
public class ElasticsearchSinkOptions<TEcsDocument> where TEcsDocument : EcsDocument, new()
{
/// <inheritdoc cref="ElasticsearchSinkOptions"/>
public ElasticsearchSinkOptions() : this(new DefaultHttpTransport(TransportHelper.Default())) { }
public ElasticsearchSinkOptions() : this(new DistributedTransport(TransportHelper.Default())) { }

/// <inheritdoc cref="ElasticsearchSinkOptions"/>
public ElasticsearchSinkOptions(HttpTransport transport) => Transport = transport;
public ElasticsearchSinkOptions(ITransport transport) => Transport = transport;

/// <inheritdoc cref="HttpTransport{TConfiguration}"/>
internal HttpTransport Transport { get; }
/// <inheritdoc cref="ITransport{TConfiguration}"/>
internal ITransport Transport { get; }

/// <inheritdoc cref="EcsTextFormatterConfiguration{TEcsDocument}"/>
public EcsTextFormatterConfiguration<TEcsDocument> TextFormatting { get; set; } = new();
Expand Down
12 changes: 6 additions & 6 deletions src/Elastic.Serilog.Sinks/ElasticsearchSinkExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static LoggerConfiguration Elasticsearch(
var transportConfig = useSniffing ? TransportHelper.Static(nodes) : TransportHelper.Sniffing(nodes);
configureTransport?.Invoke(transportConfig);

var sinkOptions = new ElasticsearchSinkOptions(new DefaultHttpTransport(transportConfig));
var sinkOptions = new ElasticsearchSinkOptions(new DistributedTransport(transportConfig));
configureOptions?.Invoke(sinkOptions);

return loggerConfiguration.Sink(new ElasticsearchSink(sinkOptions), restrictedToMinimumLevel, levelSwitch);
Expand All @@ -80,7 +80,7 @@ public static LoggerConfiguration Elasticsearch<TEcsDocument>(
{
var transportConfig = useSniffing ? TransportHelper.Static(nodes) : TransportHelper.Sniffing(nodes);
configureTransport?.Invoke(transportConfig);
var sinkOptions = new ElasticsearchSinkOptions<TEcsDocument>(new DefaultHttpTransport(transportConfig));
var sinkOptions = new ElasticsearchSinkOptions<TEcsDocument>(new DistributedTransport(transportConfig));
configureOptions?.Invoke(sinkOptions);

return loggerConfiguration.Sink(new ElasticsearchSink<TEcsDocument>(sinkOptions), restrictedToMinimumLevel, levelSwitch);
Expand All @@ -104,7 +104,7 @@ public static LoggerConfiguration ElasticCloud(
{
var transportConfig = TransportHelper.Cloud(cloudId, apiKey);
configureTransport?.Invoke(transportConfig);
var sinkOptions = new ElasticsearchSinkOptions(new DefaultHttpTransport(transportConfig));
var sinkOptions = new ElasticsearchSinkOptions(new DistributedTransport(transportConfig));
configureOptions?.Invoke(sinkOptions);

return loggerConfiguration.Sink(new ElasticsearchSink(sinkOptions), restrictedToMinimumLevel, levelSwitch);
Expand All @@ -129,7 +129,7 @@ public static LoggerConfiguration ElasticCloud<TEcsDocument>(
{
var transportConfig = TransportHelper.Cloud(cloudId, apiKey);
configureTransport?.Invoke(transportConfig);
var sinkOptions = new ElasticsearchSinkOptions<TEcsDocument>(new DefaultHttpTransport(transportConfig));
var sinkOptions = new ElasticsearchSinkOptions<TEcsDocument>(new DistributedTransport(transportConfig));
configureOptions?.Invoke(sinkOptions);

return loggerConfiguration.Sink(new ElasticsearchSink<TEcsDocument>(sinkOptions), restrictedToMinimumLevel, levelSwitch);
Expand All @@ -154,7 +154,7 @@ public static LoggerConfiguration ElasticCloud(
{
var transportConfig = TransportHelper.Cloud(cloudId, username, password);
configureTransport?.Invoke(transportConfig);
var sinkOptions = new ElasticsearchSinkOptions(new DefaultHttpTransport(transportConfig));
var sinkOptions = new ElasticsearchSinkOptions(new DistributedTransport(transportConfig));
configureOptions?.Invoke(sinkOptions);

return loggerConfiguration.Sink(new ElasticsearchSink(sinkOptions), restrictedToMinimumLevel, levelSwitch);
Expand All @@ -180,7 +180,7 @@ public static LoggerConfiguration ElasticCloud<TEcsDocument>(
{
var transportConfig = TransportHelper.Cloud(cloudId, username, password);
configureTransport?.Invoke(transportConfig);
var sinkOptions = new ElasticsearchSinkOptions<TEcsDocument>(new DefaultHttpTransport(transportConfig));
var sinkOptions = new ElasticsearchSinkOptions<TEcsDocument>(new DistributedTransport(transportConfig));
configureOptions?.Invoke(sinkOptions);

return loggerConfiguration.Sink(new ElasticsearchSink<TEcsDocument>(sinkOptions), restrictedToMinimumLevel, levelSwitch);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Elastic.Clients.Elasticsearch" Version="8.0.4" />
<PackageReference Include="Elastic.Clients.Elasticsearch" Version="8.12.1" />
<PackageReference Include="Elastic.Elasticsearch.Xunit" Version="0.4.3" />
<PackageReference Include="Elastic.Ingest.Elasticsearch" Version="0.5.5" />
<PackageReference Include="Elastic.Ingest.Elasticsearch" Version="0.6.0" />

</ItemGroup>

Expand Down

0 comments on commit e23b38e

Please sign in to comment.