Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add .net version in agent header #167

Merged
merged 4 commits into from
Sep 20, 2022
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
5 changes: 3 additions & 2 deletions src/Momento.Sdk/Internal/ControlGrpcManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ internal sealed class ControlGrpcManager : IDisposable
{
private readonly GrpcChannel channel;
public ScsControl.ScsControlClient Client { get; }
private readonly string version = "csharp:" + GetAssembly(typeof(Momento.Sdk.Responses.CacheGetResponse)).GetName().Version.ToString();
private readonly string version = "dotnet:" + GetAssembly(typeof(Momento.Sdk.Responses.CacheGetResponse)).GetName().Version.ToString();
private readonly string runtimeVersion = "dotnet:" + System.Environment.Version;

public ControlGrpcManager(string authToken, string endpoint)
{
var uri = $"https://{endpoint}";
this.channel = GrpcChannel.ForAddress(uri, new GrpcChannelOptions() { Credentials = ChannelCredentials.SecureSsl });
List<Header> headers = new List<Header> { new Header(name: Header.AuthorizationKey, value: authToken), new Header(name: Header.AgentKey, value: version) };
List<Header> headers = new List<Header> { new Header(name: Header.AuthorizationKey, value: authToken), new Header(name: Header.AgentKey, value: version), new Header(name: Header.RuntimeVersionKey, value: runtimeVersion) };
CallInvoker invoker = channel.Intercept(new HeaderInterceptor(headers));
Client = new ScsControl.ScsControlClient(invoker);
}
Expand Down
5 changes: 3 additions & 2 deletions src/Momento.Sdk/Internal/DataGrpcManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ public class DataGrpcManager : IDisposable
private readonly GrpcChannel channel;
public Scs.ScsClient Client { get; }

private readonly string version = "csharp:" + GetAssembly(typeof(Momento.Sdk.Responses.CacheGetResponse)).GetName().Version.ToString();
private readonly string version = "dotnet:" + GetAssembly(typeof(Momento.Sdk.Responses.CacheGetResponse)).GetName().Version.ToString();
private readonly string runtimeVersion = "dotnet:" + System.Environment.Version;

internal DataGrpcManager(string authToken, string host)
{
var url = $"https://{host}";
this.channel = GrpcChannel.ForAddress(url, new GrpcChannelOptions() { Credentials = ChannelCredentials.SecureSsl });
List<Header> headers = new List<Header> { new Header(name: Header.AuthorizationKey, value: authToken), new Header(name: Header.AgentKey, value: version) };
List<Header> headers = new List<Header> { new Header(name: Header.AuthorizationKey, value: authToken), new Header(name: Header.AgentKey, value: version), new Header(name: Header.RuntimeVersionKey, value: runtimeVersion) };
CallInvoker invoker = this.channel.Intercept(new HeaderInterceptor(headers));
Client = new Scs.ScsClient(invoker);
}
Expand Down
3 changes: 2 additions & 1 deletion src/Momento.Sdk/Internal/HeaderInterceptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ class Header
{
public const string AuthorizationKey = "Authorization";
public const string AgentKey = "Agent";
public readonly List<string> onceOnlyHeaders = new List<string> { Header.AgentKey };
public const string RuntimeVersionKey = "Runtime_Version";
public readonly List<string> onceOnlyHeaders = new List<string> { Header.AgentKey, Header.RuntimeVersionKey };
public string Name;
public string Value;
public Header(String name, String value)
Expand Down