From 37207ea891c96cf39b26e644255c8551b151ac4b Mon Sep 17 00:00:00 2001 From: David Fowler Date: Wed, 18 Oct 2023 01:14:10 -0700 Subject: [PATCH] Update to the 1.7.0-alpha release of otel (#373) * Update to the 1.7.0-alpha release of otel - This adds 2 experimental flags to for projects to enable the semantic conventions for event ids and exceptions Fixes #173 * Updated the otel in memory exporter to make tests pass --- Directory.Packages.props | 6 ++-- samples/dapr/AppHost/aspire-manifest.json | 20 +++++------ .../eShopLite/AppHost/aspire-manifest.json | 34 ++++++------------- .../ProjectResourceBuilderExtensions.cs | 4 +++ .../AspireApplication1.ServiceDefaults.csproj | 4 +-- ...StarterApplication1.ServiceDefaults.csproj | 4 +-- 6 files changed, 32 insertions(+), 40 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 20cddbfbe0..d7e4f3a571 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -72,10 +72,10 @@ - - + + - + diff --git a/samples/dapr/AppHost/aspire-manifest.json b/samples/dapr/AppHost/aspire-manifest.json index d7481f8974..f8b353bd0c 100644 --- a/samples/dapr/AppHost/aspire-manifest.json +++ b/samples/dapr/AppHost/aspire-manifest.json @@ -3,7 +3,10 @@ "servicea": { "type": "project.v1", "path": "..\\ServiceA\\DaprServiceA.csproj", - "env": {}, + "env": { + "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true", + "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true" + }, "bindings": { "http": { "scheme": "http", @@ -20,7 +23,10 @@ "serviceb": { "type": "project.v1", "path": "..\\ServiceB\\DaprServiceB.csproj", - "env": {}, + "env": { + "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true", + "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true" + }, "bindings": { "http": { "scheme": "http", @@ -36,10 +42,7 @@ }, "service-a": { "type": "executable.v1", - "env": { - "OTEL_EXPORTER_OTLP_INSECURE": "true", - "OTEL_EXPORTER_OTLP_PROTOCOL": "grpc" - }, + "env": {}, "bindings": { "grpc": { "scheme": "tcp", @@ -60,10 +63,7 @@ }, "service-b": { "type": "executable.v1", - "env": { - "OTEL_EXPORTER_OTLP_INSECURE": "true", - "OTEL_EXPORTER_OTLP_PROTOCOL": "grpc" - }, + "env": {}, "bindings": { "grpc": { "scheme": "tcp", diff --git a/samples/eShopLite/AppHost/aspire-manifest.json b/samples/eShopLite/AppHost/aspire-manifest.json index db28f138f3..bfec43703a 100644 --- a/samples/eShopLite/AppHost/aspire-manifest.json +++ b/samples/eShopLite/AppHost/aspire-manifest.json @@ -1,16 +1,5 @@ { "resources": { - "grafana": { - "type": "container.v1", - "image": "grafana/grafana:latest", - "bindings": { - "grafana-http": { - "scheme": "http", - "protocol": "tcp", - "transport": "http" - } - } - }, "postgres": { "type": "postgres.server.v1" }, @@ -25,6 +14,8 @@ "type": "project.v1", "path": "..\\CatalogService\\CatalogService.csproj", "env": { + "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true", + "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true", "ConnectionStrings__catalog": "{catalog.connectionString}" }, "bindings": { @@ -50,6 +41,8 @@ "type": "project.v1", "path": "..\\BasketService\\BasketService.csproj", "env": { + "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true", + "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true", "ConnectionStrings__basketCache": "{basketCache.connectionString}", "ConnectionStrings__messaging": "{messaging.connectionString}" }, @@ -70,6 +63,8 @@ "type": "project.v1", "path": "..\\MyFrontend\\MyFrontend.csproj", "env": { + "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true", + "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true", "services__basketservice__0": "{basketservice.bindings.http.url}", "services__basketservice__1": "{basketservice.bindings.https.url}", "services__catalogservice__0": "{catalogservice.bindings.http.url}" @@ -91,6 +86,8 @@ "type": "project.v1", "path": "..\\OrderProcessor\\OrderProcessor.csproj", "env": { + "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true", + "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true", "ConnectionStrings__messaging": "{messaging.connectionString}" }, "bindings": { @@ -110,6 +107,8 @@ "type": "project.v1", "path": "..\\ApiGateway\\ApiGateway.csproj", "env": { + "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true", + "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true", "services__basketservice__0": "{basketservice.bindings.http.url}", "services__basketservice__1": "{basketservice.bindings.https.url}", "services__catalogservice__0": "{catalogservice.bindings.http.url}", @@ -127,17 +126,6 @@ "transport": "http" } } - }, - "prometheus": { - "type": "container.v1", - "image": "prom/prometheus:latest", - "bindings": { - "tcp": { - "scheme": "tcp", - "protocol": "tcp", - "transport": "tcp" - } - } } } -} +} \ No newline at end of file diff --git a/src/Aspire.Hosting/ProjectResourceBuilderExtensions.cs b/src/Aspire.Hosting/ProjectResourceBuilderExtensions.cs index 58af6120df..5954cd0ae2 100644 --- a/src/Aspire.Hosting/ProjectResourceBuilderExtensions.cs +++ b/src/Aspire.Hosting/ProjectResourceBuilderExtensions.cs @@ -14,6 +14,10 @@ public static class ProjectResourceBuilderExtensions { var project = new ProjectResource(name); var projectBuilder = builder.AddResource(project); + // We only want to turn these on for .NET projects, ConfigureOtlpEnvironment works for any resource type that + // implements IDistributedApplicationResourceWithEnvironment. + projectBuilder.WithEnvironment("OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES", "true"); + projectBuilder.WithEnvironment("OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES", "true"); projectBuilder.ConfigureOtlpEnvironment(); projectBuilder.ConfigureConsoleLogs(); var serviceMetadata = new TProject(); diff --git a/src/Aspire.ProjectTemplates/templates/aspire-empty/AspireApplication1.ServiceDefaults/AspireApplication1.ServiceDefaults.csproj b/src/Aspire.ProjectTemplates/templates/aspire-empty/AspireApplication1.ServiceDefaults/AspireApplication1.ServiceDefaults.csproj index 69a3fd7b25..fbfb0cf49a 100644 --- a/src/Aspire.ProjectTemplates/templates/aspire-empty/AspireApplication1.ServiceDefaults/AspireApplication1.ServiceDefaults.csproj +++ b/src/Aspire.ProjectTemplates/templates/aspire-empty/AspireApplication1.ServiceDefaults/AspireApplication1.ServiceDefaults.csproj @@ -13,8 +13,8 @@ - - + + diff --git a/src/Aspire.ProjectTemplates/templates/aspire-starter/AspireStarterApplication1.ServiceDefaults/AspireStarterApplication1.ServiceDefaults.csproj b/src/Aspire.ProjectTemplates/templates/aspire-starter/AspireStarterApplication1.ServiceDefaults/AspireStarterApplication1.ServiceDefaults.csproj index 69a3fd7b25..fbfb0cf49a 100644 --- a/src/Aspire.ProjectTemplates/templates/aspire-starter/AspireStarterApplication1.ServiceDefaults/AspireStarterApplication1.ServiceDefaults.csproj +++ b/src/Aspire.ProjectTemplates/templates/aspire-starter/AspireStarterApplication1.ServiceDefaults/AspireStarterApplication1.ServiceDefaults.csproj @@ -13,8 +13,8 @@ - - + +