diff --git a/src/AgileConfig.Server.Apisite/Appsettings.cs b/src/AgileConfig.Server.Apisite/Appsettings.cs index acbd4ef2..d9e2a528 100644 --- a/src/AgileConfig.Server.Apisite/Appsettings.cs +++ b/src/AgileConfig.Server.Apisite/Appsettings.cs @@ -39,15 +39,22 @@ public class Appsettings public static string OtlpLogsEndpoint => Global.Config["otlp:logs:endpoint"]; + public static string OtlpLogsHeaders => Global.Config["otlp:logs:headers"]; + public static string OtlpLogsProtocol => Global.Config["otlp:logs:protocol"]; public static string OtlpTracesEndpoint => Global.Config["otlp:traces:endpoint"]; public static string OtlpTracesProtocol => Global.Config["otlp:traces:protocol"]; + + public static string OtlpTracesHeaders => Global.Config["otlp:traces:headers"]; public static string OtlpMetricsEndpoint => Global.Config["otlp:metrics:endpoint"]; public static string OtlpMetricsProtocol => Global.Config["otlp:metrics:protocol"]; + + public static string OtlpMetricsHeaders => Global.Config["otlp:metrics:headers"]; + public static string OtlpInstanceId => Global.Config["otlp:instanceId"]; } diff --git a/src/AgileConfig.Server.Apisite/Program.cs b/src/AgileConfig.Server.Apisite/Program.cs index 0193cb1f..cc7001b3 100644 --- a/src/AgileConfig.Server.Apisite/Program.cs +++ b/src/AgileConfig.Server.Apisite/Program.cs @@ -65,8 +65,11 @@ private static void AddOtlpLogging(ILoggingBuilder builder) { expOp.Protocol = Appsettings.OtlpLogsProtocol == "http" ? OtlpExportProtocol.HttpProtobuf : OtlpExportProtocol.Grpc; expOp.Endpoint = new Uri(Appsettings.OtlpLogsEndpoint); - }) - ; + if (!string.IsNullOrEmpty(Appsettings.OtlpLogsHeaders)) + { + expOp.Headers = Appsettings.OtlpLogsHeaders; + } + }); }); } diff --git a/src/AgileConfig.Server.Apisite/StartupExtension.cs b/src/AgileConfig.Server.Apisite/StartupExtension.cs index c50a3c13..1425f497 100644 --- a/src/AgileConfig.Server.Apisite/StartupExtension.cs +++ b/src/AgileConfig.Server.Apisite/StartupExtension.cs @@ -37,6 +37,10 @@ public static IOpenTelemetryBuilder AddOtlpTraces(this IOpenTelemetryBuilder bui { op.Protocol = Appsettings.OtlpTracesProtocol == "http" ? OtlpExportProtocol.HttpProtobuf : OtlpExportProtocol.Grpc; op.Endpoint = new System.Uri(Appsettings.OtlpTracesEndpoint); + if (!string.IsNullOrEmpty(Appsettings.OtlpTracesHeaders)) + { + op.Headers = Appsettings.OtlpTracesHeaders; + } }) ); @@ -59,6 +63,10 @@ public static IOpenTelemetryBuilder AddOtlpMetrics(this IOpenTelemetryBuilder bu op.Protocol = Appsettings.OtlpMetricsProtocol == "http" ? OtlpExportProtocol.HttpProtobuf : OtlpExportProtocol.Grpc; op.Endpoint = new System.Uri(Appsettings.OtlpMetricsEndpoint); reader.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds = 1000; + if (!string.IsNullOrEmpty(Appsettings.OtlpMetricsHeaders)) + { + op.Headers = Appsettings.OtlpMetricsHeaders; + } }) ); diff --git a/src/AgileConfig.Server.Apisite/appsettings.Development.json b/src/AgileConfig.Server.Apisite/appsettings.Development.json index 4c5077e8..69f5e09c 100644 --- a/src/AgileConfig.Server.Apisite/appsettings.Development.json +++ b/src/AgileConfig.Server.Apisite/appsettings.Development.json @@ -11,15 +11,18 @@ "instanceId": "agileconfig server -1", // if empty, will generate a new one "logs": { "protocol": "http", // http grpc - "endpoint": "http://192.168.0.201:5341/ingest/otlp/v1/logs" + "endpoint": "http://192.168.0.201:5341/ingest/otlp/v1/logs", + "headers":"X-Seq-ApiKey=aabbcc,X-Other-Head=other_head" }, "traces": { "protocol": "http", // http grpc - "endpoint": "http://192.168.0.201:5341/ingest/otlp/v1/traces" + "endpoint": "http://192.168.0.201:5341/ingest/otlp/v1/traces", + "headers":"X-Seq-ApiKey=aabbcc" }, "metrics": { "protocol": "http", // http grpc - "endpoint": "http://localhost:9090/api/v1/otlp/v1/metrics" + "endpoint": "http://localhost:9090/api/v1/otlp/v1/metrics", + "headers":"X-Seq-ApiKey=aabbcc" } }, "alwaysTrustSsl": true, // If true, the server will ignore SSL errors.