Skip to content
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
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

## (Unreleased)

- - Add automatic retry on gateway timeout in `GrpcDurableTaskClient.WaitForInstanceCompletionAsync` in [#412](https://github.com/microsoft/durabletask-dotnet/pull/412))
- Add automatic retry on gateway timeout in `GrpcDurableTaskClient.WaitForInstanceCompletionAsync` in ([#412](https://github.com/microsoft/durabletask-dotnet/pull/412))
- Add specific logging for NotFound error on worker connection by @halspang in ([#413](https://github.com/microsoft/durabletask-dotnet/pull/413))

- Add user agent header to gRPC called in ([#417](https://github.com/microsoft/durabletask-dotnet/pull/417))

## v1.10.0

Expand Down
5 changes: 4 additions & 1 deletion src/Client/AzureManaged/DurableTaskSchedulerClientOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Azure.Identity;
using Grpc.Core;
using Grpc.Net.Client;
using Grpc.Net.Client.Configuration;
using Microsoft.DurableTask;

namespace Microsoft.DurableTask;

Expand Down Expand Up @@ -96,6 +96,9 @@ this.Credential is not null
async (context, metadata) =>
{
metadata.Add("taskhub", taskHubName);

// Add user agent header with durabletask-dotnet and DLL version from util
metadata.Add("user-agent", $"{DurableTaskUserAgentUtil.GetUserAgent()}");
if (cache == null)
{
return;
Expand Down
31 changes: 31 additions & 0 deletions src/Shared/AzureManaged/DurableTaskVersionUtil.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System.Diagnostics;

namespace Microsoft.DurableTask;

/// <summary>
/// Utility class for generating the user agent string for the Durable Task SDK.
/// </summary>
public static class DurableTaskUserAgentUtil
{
/// <summary>
/// The name of the SDK used in the user agent string.
/// </summary>
const string SdkName = "durabletask-dotnet";

/// <summary>
/// The version of the SDK used in the user agent string.
/// </summary>
static readonly string PackageVersion = FileVersionInfo.GetVersionInfo(typeof(DurableTaskUserAgentUtil).Assembly.Location).FileVersion;

Check warning on line 21 in src/Shared/AzureManaged/DurableTaskVersionUtil.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Possible null reference assignment.

Check warning on line 21 in src/Shared/AzureManaged/DurableTaskVersionUtil.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Possible null reference assignment.

/// <summary>
/// Generates the user agent string for the Durable Task SDK based on a fixed name and the package version.
/// </summary>
/// <returns>The user agent string.</returns>
public static string GetUserAgent()
{
return $"{SdkName}/{PackageVersion?.ToString() ?? "unknown"}";
}
}
4 changes: 3 additions & 1 deletion src/Worker/AzureManaged/DurableTaskSchedulerWorkerOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Azure.Identity;
using Grpc.Core;
using Grpc.Net.Client;
using Grpc.Net.Client.Configuration;
using Microsoft.DurableTask;

namespace Microsoft.DurableTask;

Expand Down Expand Up @@ -102,6 +102,8 @@ this.Credential is not null
async (context, metadata) =>
{
metadata.Add("taskhub", taskHubName);
// Add user agent header with durabletask-dotnet and DLL version from util
metadata.Add("user-agent", $"{DurableTaskUserAgentUtil.GetUserAgent()}");
metadata.Add("workerid", this.WorkerId);
if (cache == null)
{
Expand Down
Loading