From eeb54f979fa51971f29b79c00091d224fc50ef75 Mon Sep 17 00:00:00 2001 From: qinyouzeng Date: Wed, 1 Jul 2026 16:26:26 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81api=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E6=96=87=E4=BB=B6=E6=B7=B7=E5=90=88=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=EF=BC=8C=E5=B9=B6=E8=AE=B0=E5=BD=95=E6=97=A5?= =?UTF-8?q?=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Handler/AspNetCoreInstrumentationHandler.cs | 14 ++------------ .../Handler/HttpClientInstrumentHandler.cs | 14 ++------------ 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/src/Contrib/Masa.Contrib.StackSdks.Tsc.OpenTelemetry/Traceing/Handler/AspNetCoreInstrumentationHandler.cs b/src/Contrib/Masa.Contrib.StackSdks.Tsc.OpenTelemetry/Traceing/Handler/AspNetCoreInstrumentationHandler.cs index dd33337..7e7e81a 100644 --- a/src/Contrib/Masa.Contrib.StackSdks.Tsc.OpenTelemetry/Traceing/Handler/AspNetCoreInstrumentationHandler.cs +++ b/src/Contrib/Masa.Contrib.StackSdks.Tsc.OpenTelemetry/Traceing/Handler/AspNetCoreInstrumentationHandler.cs @@ -143,25 +143,15 @@ private static string GetFileFormValue(string key, string fileName, string? cont private static void LogFormFileContent(string source, string key, string fileName, Stream fileStream) { - var logger = OpenTelemetryInstrumentationOptions.Logger; (long length, string? content) = fileStream.ReadAsBase64(); if (length <= 0) return; - - using var scope = logger?.BeginScope(new Dictionary - { - ["source"] = source, - ["form.key"] = key, - ["file.name"] = fileName, - ["file.length"] = length - }); - if (length - OpenTelemetryInstrumentationOptions.MaxBodySize > 0) { - logger?.LogInformation("file content exceeded max limit. max: {MaxBodySize}", OpenTelemetryInstrumentationOptions.MaxBodySize); + OpenTelemetryInstrumentationOptions.Logger?.LogInformation("[{Source}] keyName: {Key}, fileName: {FileName}, length: {Length}, max: {MaxBodySize}", source, key, fileName, length, OpenTelemetryInstrumentationOptions.MaxBodySize); return; } - logger?.LogInformation("file content(base64): {Content}", content ?? string.Empty); + OpenTelemetryInstrumentationOptions.Logger?.LogInformation("[{Source}] keyName: {Key}, fileName: {FileName}, base64 content: {Content}", source, key, fileName, content ?? string.Empty); } } diff --git a/src/Contrib/Masa.Contrib.StackSdks.Tsc.OpenTelemetry/Traceing/Handler/HttpClientInstrumentHandler.cs b/src/Contrib/Masa.Contrib.StackSdks.Tsc.OpenTelemetry/Traceing/Handler/HttpClientInstrumentHandler.cs index d7fa751..611ad55 100644 --- a/src/Contrib/Masa.Contrib.StackSdks.Tsc.OpenTelemetry/Traceing/Handler/HttpClientInstrumentHandler.cs +++ b/src/Contrib/Masa.Contrib.StackSdks.Tsc.OpenTelemetry/Traceing/Handler/HttpClientInstrumentHandler.cs @@ -113,26 +113,16 @@ private static string GetFileFormValue(string key, string fileName, string? cont private static void LogFormFileContent(string source, string key, string fileName, Stream fileStream) { - var logger = OpenTelemetryInstrumentationOptions.Logger; (long length, string? content) = fileStream.ReadAsBase64(); if (length <= 0) return; - - using var scope = logger?.BeginScope(new Dictionary - { - ["source"] = source, - ["form.key"] = key, - ["file.name"] = fileName, - ["file.length"] = length - }); - if (length - OpenTelemetryInstrumentationOptions.MaxBodySize > 0) { - logger?.LogInformation("file content exceeded max limit. max: {MaxBodySize}", OpenTelemetryInstrumentationOptions.MaxBodySize); + OpenTelemetryInstrumentationOptions.Logger?.LogInformation("[{Source}] Multipart form file content exceeded max limit. key: {Key}, fileName: {FileName}, length: {Length}, max: {MaxBodySize}", source, key, fileName, length, OpenTelemetryInstrumentationOptions.MaxBodySize); return; } - logger?.LogInformation("file content(base64): {Content}", content ?? string.Empty); + OpenTelemetryInstrumentationOptions.Logger?.LogInformation("[{Source}] Multipart form file content(base64). key: {Key}, fileName: {FileName}, content: {Content}", source, key, fileName, content ?? string.Empty); } private static long? GetStreamLength(Stream stream) From 58a302ee1eb16d5dc91a72140900cdbb52928ffe Mon Sep 17 00:00:00 2001 From: qinyouzeng Date: Wed, 1 Jul 2026 17:09:43 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20httpclient=20=E6=B7=BB=E5=8A=A0form?= =?UTF-8?q?=E8=A1=A8=E5=8D=95=E8=AE=B0=E5=BD=95=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Handler/AspNetCoreInstrumentationHandler.cs | 14 ++++++++++++-- .../Handler/HttpClientInstrumentHandler.cs | 14 ++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/Contrib/Masa.Contrib.StackSdks.Tsc.OpenTelemetry/Traceing/Handler/AspNetCoreInstrumentationHandler.cs b/src/Contrib/Masa.Contrib.StackSdks.Tsc.OpenTelemetry/Traceing/Handler/AspNetCoreInstrumentationHandler.cs index 7e7e81a..dd33337 100644 --- a/src/Contrib/Masa.Contrib.StackSdks.Tsc.OpenTelemetry/Traceing/Handler/AspNetCoreInstrumentationHandler.cs +++ b/src/Contrib/Masa.Contrib.StackSdks.Tsc.OpenTelemetry/Traceing/Handler/AspNetCoreInstrumentationHandler.cs @@ -143,15 +143,25 @@ private static string GetFileFormValue(string key, string fileName, string? cont private static void LogFormFileContent(string source, string key, string fileName, Stream fileStream) { + var logger = OpenTelemetryInstrumentationOptions.Logger; (long length, string? content) = fileStream.ReadAsBase64(); if (length <= 0) return; + + using var scope = logger?.BeginScope(new Dictionary + { + ["source"] = source, + ["form.key"] = key, + ["file.name"] = fileName, + ["file.length"] = length + }); + if (length - OpenTelemetryInstrumentationOptions.MaxBodySize > 0) { - OpenTelemetryInstrumentationOptions.Logger?.LogInformation("[{Source}] keyName: {Key}, fileName: {FileName}, length: {Length}, max: {MaxBodySize}", source, key, fileName, length, OpenTelemetryInstrumentationOptions.MaxBodySize); + logger?.LogInformation("file content exceeded max limit. max: {MaxBodySize}", OpenTelemetryInstrumentationOptions.MaxBodySize); return; } - OpenTelemetryInstrumentationOptions.Logger?.LogInformation("[{Source}] keyName: {Key}, fileName: {FileName}, base64 content: {Content}", source, key, fileName, content ?? string.Empty); + logger?.LogInformation("file content(base64): {Content}", content ?? string.Empty); } } diff --git a/src/Contrib/Masa.Contrib.StackSdks.Tsc.OpenTelemetry/Traceing/Handler/HttpClientInstrumentHandler.cs b/src/Contrib/Masa.Contrib.StackSdks.Tsc.OpenTelemetry/Traceing/Handler/HttpClientInstrumentHandler.cs index 611ad55..d7fa751 100644 --- a/src/Contrib/Masa.Contrib.StackSdks.Tsc.OpenTelemetry/Traceing/Handler/HttpClientInstrumentHandler.cs +++ b/src/Contrib/Masa.Contrib.StackSdks.Tsc.OpenTelemetry/Traceing/Handler/HttpClientInstrumentHandler.cs @@ -113,16 +113,26 @@ private static string GetFileFormValue(string key, string fileName, string? cont private static void LogFormFileContent(string source, string key, string fileName, Stream fileStream) { + var logger = OpenTelemetryInstrumentationOptions.Logger; (long length, string? content) = fileStream.ReadAsBase64(); if (length <= 0) return; + + using var scope = logger?.BeginScope(new Dictionary + { + ["source"] = source, + ["form.key"] = key, + ["file.name"] = fileName, + ["file.length"] = length + }); + if (length - OpenTelemetryInstrumentationOptions.MaxBodySize > 0) { - OpenTelemetryInstrumentationOptions.Logger?.LogInformation("[{Source}] Multipart form file content exceeded max limit. key: {Key}, fileName: {FileName}, length: {Length}, max: {MaxBodySize}", source, key, fileName, length, OpenTelemetryInstrumentationOptions.MaxBodySize); + logger?.LogInformation("file content exceeded max limit. max: {MaxBodySize}", OpenTelemetryInstrumentationOptions.MaxBodySize); return; } - OpenTelemetryInstrumentationOptions.Logger?.LogInformation("[{Source}] Multipart form file content(base64). key: {Key}, fileName: {FileName}, content: {Content}", source, key, fileName, content ?? string.Empty); + logger?.LogInformation("file content(base64): {Content}", content ?? string.Empty); } private static long? GetStreamLength(Stream stream)