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

Commit

Permalink
Add debug and tracing annotations for dapr (#298)
Browse files Browse the repository at this point in the history
* add debug and tracing annotations
  • Loading branch information
thangchung authored Apr 16, 2020
1 parent 2d3c9b8 commit cec77aa
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Microsoft.Tye.Extensions/Dapr/DaprExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public override Task ProcessAsync(ExtensionContext context, ExtensionConfigurati

// These environment variables are replaced with environment variables
// defined for this service.
Args = $"-app-id {project.Name} -app-port %APP_PORT% -dapr-grpc-port %DAPR_GRPC_PORT% --dapr-http-port %DAPR_HTTP_PORT% --metrics-port %METRICS_PORT% --placement-address localhost:50005",
Args = $"-app-id {project.Name} -app-port %APP_PORT% -dapr-grpc-port %DAPR_GRPC_PORT% --dapr-http-port %DAPR_HTTP_PORT% --metrics-port %METRICS_PORT% -log-level %LOG_LEVEL% -config %CONFIG% --placement-address localhost:50005",
};
context.Application.Services.Add(proxy);

Expand Down Expand Up @@ -146,6 +146,16 @@ 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));

if (config.Data.TryGetValue("config", out var daprConfig) && daprConfig is object)
{
deployment.Annotations.TryAdd("dapr.io/config", daprConfig!.ToString() ?? string.Empty);
}

if (config.Data.TryGetValue("log-level", out var logLevel) && logLevel is object)
{
deployment.Annotations.TryAdd("dapr.io/log-level", logLevel!.ToString() ?? string.Empty);
}
}
}
}
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

0 comments on commit cec77aa

Please sign in to comment.