Skip to content
This repository has been archived by the owner on Nov 20, 2023. It is now read-only.

Add debug and tracing annotations #298

Merged
merged 8 commits into from
Apr 16, 2020
Merged
Show file tree
Hide file tree
Changes from 5 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
12 changes: 12 additions & 0 deletions src/Microsoft.Tye.Extensions/Dapr/DaprExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,18 @@ public override Task ProcessAsync(ExtensionContext context, ExtensionConfigurati
deployment.Annotations.Add("dapr.io/enabled", "true");
deployment.Annotations.Add("dapr.io/id", project.Name);
deployment.Annotations.Add("dapr.io/port", (httpBinding.Port ?? 80).ToString(CultureInfo.InvariantCulture));

thangchung marked this conversation as resolved.
Show resolved Hide resolved
#pragma warning disable CS8604 // Possible null reference argument.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's usally done by doing this:

daprConfig!.ToString()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did it with your suggestion, but no luck. Could anyone tell me how can I overcome this check?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did deployment.Annotations.TryAdd("dapr.io/config", daprConfig!.ToString() ?? string.Empty);, and it can overcome this check but not sure it is correctly

if (config.Data.TryGetValue("config", out var daprConfig) && daprConfig is object)
{
deployment.Annotations.TryAdd("dapr.io/config", daprConfig.ToString());
}
thangchung marked this conversation as resolved.
Show resolved Hide resolved

if (config.Data.TryGetValue("log-level", out var logLevel) && logLevel is object)
{
deployment.Annotations.TryAdd("dapr.io/log-level", logLevel.ToString());
}
#pragma warning restore CS8604 // Possible null reference argument.
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions test/E2ETest/testassets/generate/dapr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ metadata:
dapr.io/enabled: 'true'
dapr.io/id: 'dapr_test_project'
dapr.io/port: '80'
dapr.io/config: 'tracing'
dapr.io/log-level: 'debug'
labels:
app.kubernetes.io/name: 'dapr_test_project'
app.kubernetes.io/part-of: 'dapr_test_application'
Expand All @@ -20,6 +22,8 @@ spec:
dapr.io/enabled: 'true'
dapr.io/id: 'dapr_test_project'
dapr.io/port: '80'
dapr.io/config: 'tracing'
dapr.io/log-level: 'debug'
labels:
app.kubernetes.io/name: 'dapr_test_project'
app.kubernetes.io/part-of: 'dapr_test_application'
Expand Down
2 changes: 2 additions & 0 deletions test/E2ETest/testassets/projects/dapr/tye.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: dapr_test_application
extensions:
- name: dapr
config: tracing
log-level: debug
services:
- name: dapr_test_project
project: dapr.csproj