Skip to content

Commit e4fdc74

Browse files
committed
Add useragent
1 parent 33ec0d7 commit e4fdc74

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/Client/AzureManaged/DurableTaskSchedulerClientOptions.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using Azure.Identity;
77
using Grpc.Core;
88
using Grpc.Net.Client;
9-
using Grpc.Net.Client.Configuration;
9+
using Microsoft.DurableTask;
1010

1111
namespace Microsoft.DurableTask;
1212

@@ -96,6 +96,9 @@ this.Credential is not null
9696
async (context, metadata) =>
9797
{
9898
metadata.Add("taskhub", taskHubName);
99+
100+
// Add user agent header with durabletask-dotnet and DLL version from util
101+
metadata.Add("user-agent", $"{DurableTaskUserAgentUtil.GetUserAgent()}");
99102
if (cache == null)
100103
{
101104
return;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System.Reflection;
2+
3+
namespace Microsoft.DurableTask;
4+
5+
public static class DurableTaskUserAgentUtil
6+
{
7+
static string SdkName => "durabletask-dotnet";
8+
9+
public static string GetUserAgent()
10+
{
11+
var version = typeof(DurableTaskUserAgentUtil).Assembly.GetName().Version;
12+
return $"{SdkName}/{version?.ToString() ?? "unknown"}";
13+
}
14+
}

0 commit comments

Comments
 (0)