diff --git a/src/Elastic.Transport/Products/DefaultProductRegistration.cs b/src/Elastic.Transport/Products/DefaultProductRegistration.cs index 2c4e033..542a595 100644 --- a/src/Elastic.Transport/Products/DefaultProductRegistration.cs +++ b/src/Elastic.Transport/Products/DefaultProductRegistration.cs @@ -22,7 +22,7 @@ public sealed class DefaultProductRegistration : ProductRegistration /// /// /// - public DefaultProductRegistration() => _metaHeaderProvider = new DefaultMetaHeaderProvider(typeof(HttpTransport), "et"); + public DefaultProductRegistration() => _metaHeaderProvider = new DefaultMetaHeaderProvider(typeof(HttpTransport), ServiceIdentifier); /// A static instance of to promote reuse public static DefaultProductRegistration Default { get; } = new DefaultProductRegistration(); @@ -30,6 +30,9 @@ public sealed class DefaultProductRegistration : ProductRegistration /// public override string Name { get; } = "elastic-transport-net"; + /// + public override string? ServiceIdentifier => "et"; + /// public override bool SupportsPing { get; } = false; diff --git a/src/Elastic.Transport/Products/Elasticsearch/ElasticsearchProductRegistration.cs b/src/Elastic.Transport/Products/Elasticsearch/ElasticsearchProductRegistration.cs index f104cbc..8e2beb2 100644 --- a/src/Elastic.Transport/Products/Elasticsearch/ElasticsearchProductRegistration.cs +++ b/src/Elastic.Transport/Products/Elasticsearch/ElasticsearchProductRegistration.cs @@ -34,10 +34,13 @@ public class ElasticsearchProductRegistration : ProductRegistration public ElasticsearchProductRegistration(Type markerType) : this() { var clientVersionInfo = ReflectionVersionInfo.Create(markerType); - _metaHeaderProvider = new DefaultMetaHeaderProvider(clientVersionInfo, "es"); + + var identifier = ServiceIdentifier; + if (!string.IsNullOrEmpty(identifier)) + _metaHeaderProvider = new DefaultMetaHeaderProvider(clientVersionInfo, identifier); // Only set this if we have a version. - // If we don't have a version we won't apply the vendor-based REST API compatibilty Accept header. + // If we don't have a version we won't apply the vendor-based REST API compatibility Accept header. if (clientVersionInfo.Version.Major > 0) _clientMajorVersion = clientVersionInfo.Version.Major; } @@ -48,6 +51,9 @@ public ElasticsearchProductRegistration(Type markerType) : this() /// public override string Name { get; } = "elasticsearch-net"; + /// + public override string? ServiceIdentifier => "es"; + /// public override bool SupportsPing { get; } = true; diff --git a/src/Elastic.Transport/Products/ProductRegistration.cs b/src/Elastic.Transport/Products/ProductRegistration.cs index 278bf54..95da739 100644 --- a/src/Elastic.Transport/Products/ProductRegistration.cs +++ b/src/Elastic.Transport/Products/ProductRegistration.cs @@ -34,6 +34,11 @@ public abstract class ProductRegistration /// public abstract string Name { get; } + /// + /// An optional service-identifier string that is used in metadata headers. + /// + public abstract string? ServiceIdentifier { get; } + /// /// Whether the product will call out to supports ping endpoints ///