Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[System.ClientModel] Add Logging #45472

Merged
merged 85 commits into from
Feb 1, 2025
Merged
Show file tree
Hide file tree
Changes from 76 commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
8d9dd93
initial draft
m-redding Jun 14, 2024
74c77c4
WIP test stubs pt 1
m-redding Jun 18, 2024
4192f6c
WIP test stubs 2
m-redding Jun 19, 2024
7f5c7cf
tweaks
m-redding Jun 20, 2024
edccce7
changes
m-redding Jun 24, 2024
b08f2c5
p1 of adding Event Source
m-redding Jun 26, 2024
291365d
tests p1
m-redding Jun 26, 2024
107abf0
test updates
m-redding Jun 27, 2024
207b215
Tests2
m-redding Jun 28, 2024
3747094
updates
m-redding Jul 17, 2024
c986aed
API
m-redding Jul 17, 2024
d802bc3
try slimming methods and adding retry policy log
m-redding Jul 18, 2024
fc17694
test
m-redding Jul 22, 2024
7253073
conflicts
m-redding Aug 13, 2024
205ef71
refactory + add abstraction
m-redding Aug 13, 2024
1c2f4dc
add tests and update api
m-redding Aug 13, 2024
cb53622
more tests
m-redding Aug 13, 2024
8f98aec
fix functional tests
m-redding Aug 15, 2024
06126f2
static -> instance
m-redding Aug 15, 2024
6f51ac6
updates
m-redding Aug 19, 2024
69ced27
tweaks
m-redding Aug 19, 2024
e445a1b
tweaks
m-redding Aug 19, 2024
dec45fd
fix
m-redding Aug 19, 2024
524edc9
Merge branch 'Azure:main' into loggingpolicy2
m-redding Sep 4, 2024
469aeb7
little refactorings
m-redding Sep 9, 2024
ecf0a26
tweaks
m-redding Sep 11, 2024
373fb99
tweaks
m-redding Sep 11, 2024
441ee3e
WIP feedback
m-redding Sep 13, 2024
49a3bcd
reformat
m-redding Sep 17, 2024
da1b7f8
WIP more feedback
m-redding Sep 17, 2024
86dc327
WIP
m-redding Sep 17, 2024
672390a
Merge branch 'Azure:main' into loggingpolicy2
m-redding Sep 18, 2024
ef183ef
Merge branch 'loggingpolicy2' of https://github.com/m-redding/azure-s…
m-redding Sep 18, 2024
9f93eea
Merge branch 'Azure:main' into loggingpolicy2
m-redding Oct 8, 2024
281aa37
Merge branch 'loggingpolicy2' of https://github.com/m-redding/azure-s…
m-redding Oct 8, 2024
b5d97f0
Merge branch 'Azure:main' into loggingpolicy2
m-redding Oct 22, 2024
4a97e78
WIP - updates
m-redding Oct 23, 2024
2726470
Export API
m-redding Oct 23, 2024
e93cbd9
API
m-redding Oct 23, 2024
9e5f1d3
API tweaks
m-redding Oct 23, 2024
87bafa7
comment
m-redding Oct 23, 2024
009792c
Merge branch 'Azure:main' into loggingpolicy2
m-redding Nov 4, 2024
1fb84da
changes 1
m-redding Nov 5, 2024
d5a9360
changes 2
m-redding Nov 7, 2024
985844f
changes
m-redding Nov 7, 2024
3afbc2e
fixes
m-redding Nov 7, 2024
b5ba8ac
more updates
m-redding Nov 7, 2024
382f0d7
some tests
m-redding Nov 7, 2024
eaebe02
WIP - experiment
m-redding Nov 7, 2024
72c2062
Merge branch 'Azure:main' into loggingpolicy2
m-redding Nov 14, 2024
21bea5e
wip
m-redding Nov 15, 2024
fca37df
Merge branch 'Azure:main' into loggingpolicy2
m-redding Nov 18, 2024
7818432
Merge branch 'loggingpolicy2' of https://github.com/m-redding/azure-s…
m-redding Nov 18, 2024
909cdb8
wip fixes
m-redding Nov 25, 2024
e21486a
Merge branch 'Azure:main' into loggingpolicy2
m-redding Nov 27, 2024
f474c2c
event source / logger tests green
m-redding Dec 2, 2024
8cd0d58
API
m-redding Dec 2, 2024
75c24dc
fb
m-redding Dec 2, 2024
bc0c547
implement request ID
m-redding Dec 2, 2024
80ca39a
adding tests, some fb
m-redding Dec 3, 2024
f35144c
more FB
m-redding Dec 3, 2024
2e92d6f
more fb + more tests
m-redding Dec 3, 2024
7cdeb49
WIP
m-redding Dec 10, 2024
41e3abd
tweaks to logging stream
m-redding Dec 10, 2024
eadd1bb
tests green
m-redding Dec 10, 2024
37975b6
test updates
m-redding Dec 12, 2024
9b2f9a0
more test updates
m-redding Dec 12, 2024
8d307b8
Update sdk/core/System.ClientModel/src/Options/ClientLoggingOptions.cs
m-redding Dec 13, 2024
0ebff9d
fb 1
m-redding Dec 13, 2024
778c70b
fb 2
m-redding Dec 13, 2024
dccb471
fixes
m-redding Dec 14, 2024
57b9166
Merge branch 'Azure:main' into loggingpolicy2
m-redding Dec 14, 2024
bdf8068
initial samples
m-redding Jan 2, 2025
91e2a03
api fix and logging.md
m-redding Jan 3, 2025
18d6ae0
tests
m-redding Jan 6, 2025
fbcbf57
Merge branch 'Azure:main' into loggingpolicy2
m-redding Jan 6, 2025
9f75d15
Merge branch 'Azure:main' into loggingpolicy2
m-redding Jan 22, 2025
d0123df
Merge branch 'Azure:main' into loggingpolicy2
m-redding Jan 25, 2025
2ade2a6
Apply suggestions from code review
m-redding Jan 25, 2025
96a36c8
feedback 1
m-redding Jan 27, 2025
433a018
more fb
m-redding Jan 27, 2025
7dbc599
more feedback
m-redding Jan 29, 2025
9f5b4e6
test fix
m-redding Jan 29, 2025
ccd5775
prefer activity.current for request id
m-redding Jan 30, 2025
0ce5416
last clean up tweaks
m-redding Feb 1, 2025
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
2 changes: 2 additions & 0 deletions eng/Packages.Data.props
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
<PackageReference Update="System.ValueTuple" Version="4.5.0" />
<PackageReference Update="Microsoft.Bcl.AsyncInterfaces" Version="6.0.0" />
<PackageReference Update="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Update="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0"/>

<!-- Azure SDK packages -->
<PackageReference Update="Azure.Communication.Identity" Version="1.3.1" />
Expand Down Expand Up @@ -344,6 +345,7 @@
<PackageReference Update="Microsoft.Extensions.Configuration" Version="5.0.0" />
<PackageReference Update="Microsoft.Extensions.Hosting" Version="8.0.1" />
<PackageReference Update="Microsoft.Extensions.Logging.Configuration" Version="8.0.0-rc.1.23419.4" />
<PackageReference Update="Microsoft.Extensions.Logging.Console" Version="6.0.0"/>
<PackageReference Update="Microsoft.Extensions.DependencyInjection" Version="3.1.32" />
<PackageReference Update="Microsoft.Extensions.PlatformAbstractions" Version="1.1.0" />
<PackageReference Update="Microsoft.Graph" Version="5.57.0" />
Expand Down
25 changes: 25 additions & 0 deletions sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,19 @@ public enum ClientErrorBehaviors
Default = 0,
NoThrow = 1,
}
public partial class ClientLoggingOptions
{
public ClientLoggingOptions() { }
public System.Collections.Generic.IList<string> AllowedHeaderNames { get { throw null; } }
public System.Collections.Generic.IList<string> AllowedQueryParameters { get { throw null; } }
public bool? EnableLogging { get { throw null; } set { } }
public bool? EnableMessageContentLogging { get { throw null; } set { } }
public bool? EnableMessageLogging { get { throw null; } set { } }
public Microsoft.Extensions.Logging.ILoggerFactory? LoggerFactory { get { throw null; } set { } }
public int? MessageContentSizeLimit { get { throw null; } set { } }
protected void AssertNotFrozen() { }
public virtual void Freeze() { }
}
public sealed partial class ClientPipeline
{
internal ClientPipeline() { }
Expand All @@ -95,6 +108,8 @@ public void Send(System.ClientModel.Primitives.PipelineMessage message) { }
public partial class ClientPipelineOptions
{
public ClientPipelineOptions() { }
public System.ClientModel.Primitives.ClientLoggingOptions? ClientLoggingOptions { get { throw null; } set { } }
public System.ClientModel.Primitives.PipelinePolicy? MessageLoggingPolicy { get { throw null; } set { } }
public System.TimeSpan? NetworkTimeout { get { throw null; } set { } }
public System.ClientModel.Primitives.PipelinePolicy? RetryPolicy { get { throw null; } set { } }
public System.ClientModel.Primitives.PipelineTransport? Transport { get { throw null; } set { } }
Expand All @@ -105,6 +120,7 @@ public virtual void Freeze() { }
public partial class ClientRetryPolicy : System.ClientModel.Primitives.PipelinePolicy
{
public ClientRetryPolicy(int maxRetries = 3) { }
public ClientRetryPolicy(int maxRetries, bool enableLogging, Microsoft.Extensions.Logging.ILoggerFactory? loggerFactory) { }
public static System.ClientModel.Primitives.ClientRetryPolicy Default { get { throw null; } }
protected virtual System.TimeSpan GetNextDelay(System.ClientModel.Primitives.PipelineMessage message, int tryCount) { throw null; }
protected virtual void OnRequestSent(System.ClientModel.Primitives.PipelineMessage message) { }
Expand All @@ -129,6 +145,7 @@ public partial class HttpClientPipelineTransport : System.ClientModel.Primitives
{
public HttpClientPipelineTransport() { }
public HttpClientPipelineTransport(System.Net.Http.HttpClient client) { }
public HttpClientPipelineTransport(System.Net.Http.HttpClient? client, bool enableLogging, Microsoft.Extensions.Logging.ILoggerFactory? loggerFactory) { }
public static System.ClientModel.Primitives.HttpClientPipelineTransport Shared { get { throw null; } }
protected override System.ClientModel.Primitives.PipelineMessage CreateMessageCore() { throw null; }
public void Dispose() { }
Expand Down Expand Up @@ -158,6 +175,13 @@ public JsonModelConverter(System.ClientModel.Primitives.ModelReaderWriterOptions
public override System.ClientModel.Primitives.IJsonModel<object> Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { throw null; }
public override void Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.IJsonModel<object> value, System.Text.Json.JsonSerializerOptions options) { }
}
public partial class MessageLoggingPolicy : System.ClientModel.Primitives.PipelinePolicy
{
public MessageLoggingPolicy(System.ClientModel.Primitives.ClientLoggingOptions? options = null) { }
public static System.ClientModel.Primitives.MessageLoggingPolicy Default { get { throw null; } }
public sealed override void Process(System.ClientModel.Primitives.PipelineMessage message, System.Collections.Generic.IReadOnlyList<System.ClientModel.Primitives.PipelinePolicy> pipeline, int currentIndex) { }
public sealed override System.Threading.Tasks.ValueTask ProcessAsync(System.ClientModel.Primitives.PipelineMessage message, System.Collections.Generic.IReadOnlyList<System.ClientModel.Primitives.PipelinePolicy> pipeline, int currentIndex) { throw null; }
}
public static partial class ModelReaderWriter
{
public static object? Read(System.BinaryData data, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors)] System.Type returnType, System.ClientModel.Primitives.ModelReaderWriterOptions? options = null) { throw null; }
Expand Down Expand Up @@ -279,6 +303,7 @@ protected PipelineResponseHeaders() { }
public abstract partial class PipelineTransport : System.ClientModel.Primitives.PipelinePolicy
{
protected PipelineTransport() { }
protected PipelineTransport(bool enableLogging, Microsoft.Extensions.Logging.ILoggerFactory? loggerFactory) { }
public System.ClientModel.Primitives.PipelineMessage CreateMessage() { throw null; }
protected abstract System.ClientModel.Primitives.PipelineMessage CreateMessageCore();
public void Process(System.ClientModel.Primitives.PipelineMessage message) { }
Expand Down
25 changes: 25 additions & 0 deletions sdk/core/System.ClientModel/api/System.ClientModel.net8.0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,19 @@ public enum ClientErrorBehaviors
Default = 0,
NoThrow = 1,
}
public partial class ClientLoggingOptions
{
public ClientLoggingOptions() { }
public System.Collections.Generic.IList<string> AllowedHeaderNames { get { throw null; } }
public System.Collections.Generic.IList<string> AllowedQueryParameters { get { throw null; } }
public bool? EnableLogging { get { throw null; } set { } }
public bool? EnableMessageContentLogging { get { throw null; } set { } }
public bool? EnableMessageLogging { get { throw null; } set { } }
public Microsoft.Extensions.Logging.ILoggerFactory? LoggerFactory { get { throw null; } set { } }
public int? MessageContentSizeLimit { get { throw null; } set { } }
protected void AssertNotFrozen() { }
public virtual void Freeze() { }
}
public sealed partial class ClientPipeline
{
internal ClientPipeline() { }
Expand All @@ -95,6 +108,8 @@ public void Send(System.ClientModel.Primitives.PipelineMessage message) { }
public partial class ClientPipelineOptions
{
public ClientPipelineOptions() { }
public System.ClientModel.Primitives.ClientLoggingOptions? ClientLoggingOptions { get { throw null; } set { } }
public System.ClientModel.Primitives.PipelinePolicy? MessageLoggingPolicy { get { throw null; } set { } }
public System.TimeSpan? NetworkTimeout { get { throw null; } set { } }
public System.ClientModel.Primitives.PipelinePolicy? RetryPolicy { get { throw null; } set { } }
public System.ClientModel.Primitives.PipelineTransport? Transport { get { throw null; } set { } }
Expand All @@ -105,6 +120,7 @@ public virtual void Freeze() { }
public partial class ClientRetryPolicy : System.ClientModel.Primitives.PipelinePolicy
{
public ClientRetryPolicy(int maxRetries = 3) { }
public ClientRetryPolicy(int maxRetries, bool enableLogging, Microsoft.Extensions.Logging.ILoggerFactory? loggerFactory) { }
public static System.ClientModel.Primitives.ClientRetryPolicy Default { get { throw null; } }
protected virtual System.TimeSpan GetNextDelay(System.ClientModel.Primitives.PipelineMessage message, int tryCount) { throw null; }
protected virtual void OnRequestSent(System.ClientModel.Primitives.PipelineMessage message) { }
Expand All @@ -129,6 +145,7 @@ public partial class HttpClientPipelineTransport : System.ClientModel.Primitives
{
public HttpClientPipelineTransport() { }
public HttpClientPipelineTransport(System.Net.Http.HttpClient client) { }
public HttpClientPipelineTransport(System.Net.Http.HttpClient? client, bool enableLogging, Microsoft.Extensions.Logging.ILoggerFactory? loggerFactory) { }
public static System.ClientModel.Primitives.HttpClientPipelineTransport Shared { get { throw null; } }
protected override System.ClientModel.Primitives.PipelineMessage CreateMessageCore() { throw null; }
public void Dispose() { }
Expand Down Expand Up @@ -158,6 +175,13 @@ public JsonModelConverter(System.ClientModel.Primitives.ModelReaderWriterOptions
public override System.ClientModel.Primitives.IJsonModel<object> Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { throw null; }
public override void Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.IJsonModel<object> value, System.Text.Json.JsonSerializerOptions options) { }
}
public partial class MessageLoggingPolicy : System.ClientModel.Primitives.PipelinePolicy
{
public MessageLoggingPolicy(System.ClientModel.Primitives.ClientLoggingOptions? options = null) { }
public static System.ClientModel.Primitives.MessageLoggingPolicy Default { get { throw null; } }
public sealed override void Process(System.ClientModel.Primitives.PipelineMessage message, System.Collections.Generic.IReadOnlyList<System.ClientModel.Primitives.PipelinePolicy> pipeline, int currentIndex) { }
public sealed override System.Threading.Tasks.ValueTask ProcessAsync(System.ClientModel.Primitives.PipelineMessage message, System.Collections.Generic.IReadOnlyList<System.ClientModel.Primitives.PipelinePolicy> pipeline, int currentIndex) { throw null; }
}
public static partial class ModelReaderWriter
{
public static object? Read(System.BinaryData data, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors)] System.Type returnType, System.ClientModel.Primitives.ModelReaderWriterOptions? options = null) { throw null; }
Expand Down Expand Up @@ -279,6 +303,7 @@ protected PipelineResponseHeaders() { }
public abstract partial class PipelineTransport : System.ClientModel.Primitives.PipelinePolicy
{
protected PipelineTransport() { }
protected PipelineTransport(bool enableLogging, Microsoft.Extensions.Logging.ILoggerFactory? loggerFactory) { }
public System.ClientModel.Primitives.PipelineMessage CreateMessage() { throw null; }
protected abstract System.ClientModel.Primitives.PipelineMessage CreateMessageCore();
public void Process(System.ClientModel.Primitives.PipelineMessage message) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,19 @@ public enum ClientErrorBehaviors
Default = 0,
NoThrow = 1,
}
public partial class ClientLoggingOptions
{
public ClientLoggingOptions() { }
public System.Collections.Generic.IList<string> AllowedHeaderNames { get { throw null; } }
public System.Collections.Generic.IList<string> AllowedQueryParameters { get { throw null; } }
public bool? EnableLogging { get { throw null; } set { } }
public bool? EnableMessageContentLogging { get { throw null; } set { } }
public bool? EnableMessageLogging { get { throw null; } set { } }
public Microsoft.Extensions.Logging.ILoggerFactory? LoggerFactory { get { throw null; } set { } }
public int? MessageContentSizeLimit { get { throw null; } set { } }
protected void AssertNotFrozen() { }
public virtual void Freeze() { }
}
public sealed partial class ClientPipeline
{
internal ClientPipeline() { }
Expand All @@ -95,6 +108,8 @@ public void Send(System.ClientModel.Primitives.PipelineMessage message) { }
public partial class ClientPipelineOptions
{
public ClientPipelineOptions() { }
public System.ClientModel.Primitives.ClientLoggingOptions? ClientLoggingOptions { get { throw null; } set { } }
public System.ClientModel.Primitives.PipelinePolicy? MessageLoggingPolicy { get { throw null; } set { } }
public System.TimeSpan? NetworkTimeout { get { throw null; } set { } }
public System.ClientModel.Primitives.PipelinePolicy? RetryPolicy { get { throw null; } set { } }
public System.ClientModel.Primitives.PipelineTransport? Transport { get { throw null; } set { } }
Expand All @@ -105,6 +120,7 @@ public virtual void Freeze() { }
public partial class ClientRetryPolicy : System.ClientModel.Primitives.PipelinePolicy
{
public ClientRetryPolicy(int maxRetries = 3) { }
public ClientRetryPolicy(int maxRetries, bool enableLogging, Microsoft.Extensions.Logging.ILoggerFactory? loggerFactory) { }
public static System.ClientModel.Primitives.ClientRetryPolicy Default { get { throw null; } }
protected virtual System.TimeSpan GetNextDelay(System.ClientModel.Primitives.PipelineMessage message, int tryCount) { throw null; }
protected virtual void OnRequestSent(System.ClientModel.Primitives.PipelineMessage message) { }
Expand All @@ -129,6 +145,7 @@ public partial class HttpClientPipelineTransport : System.ClientModel.Primitives
{
public HttpClientPipelineTransport() { }
public HttpClientPipelineTransport(System.Net.Http.HttpClient client) { }
public HttpClientPipelineTransport(System.Net.Http.HttpClient? client, bool enableLogging, Microsoft.Extensions.Logging.ILoggerFactory? loggerFactory) { }
public static System.ClientModel.Primitives.HttpClientPipelineTransport Shared { get { throw null; } }
protected override System.ClientModel.Primitives.PipelineMessage CreateMessageCore() { throw null; }
public void Dispose() { }
Expand Down Expand Up @@ -157,6 +174,13 @@ public JsonModelConverter(System.ClientModel.Primitives.ModelReaderWriterOptions
public override System.ClientModel.Primitives.IJsonModel<object> Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { throw null; }
public override void Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.IJsonModel<object> value, System.Text.Json.JsonSerializerOptions options) { }
}
public partial class MessageLoggingPolicy : System.ClientModel.Primitives.PipelinePolicy
{
public MessageLoggingPolicy(System.ClientModel.Primitives.ClientLoggingOptions? options = null) { }
public static System.ClientModel.Primitives.MessageLoggingPolicy Default { get { throw null; } }
public sealed override void Process(System.ClientModel.Primitives.PipelineMessage message, System.Collections.Generic.IReadOnlyList<System.ClientModel.Primitives.PipelinePolicy> pipeline, int currentIndex) { }
public sealed override System.Threading.Tasks.ValueTask ProcessAsync(System.ClientModel.Primitives.PipelineMessage message, System.Collections.Generic.IReadOnlyList<System.ClientModel.Primitives.PipelinePolicy> pipeline, int currentIndex) { throw null; }
}
public static partial class ModelReaderWriter
{
public static object? Read(System.BinaryData data, System.Type returnType, System.ClientModel.Primitives.ModelReaderWriterOptions? options = null) { throw null; }
Expand Down Expand Up @@ -277,6 +301,7 @@ protected PipelineResponseHeaders() { }
public abstract partial class PipelineTransport : System.ClientModel.Primitives.PipelinePolicy
{
protected PipelineTransport() { }
protected PipelineTransport(bool enableLogging, Microsoft.Extensions.Logging.ILoggerFactory? loggerFactory) { }
public System.ClientModel.Primitives.PipelineMessage CreateMessage() { throw null; }
protected abstract System.ClientModel.Primitives.PipelineMessage CreateMessageCore();
public void Process(System.ClientModel.Primitives.PipelineMessage message) { }
Expand Down
Loading
Loading