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

V4 Updates for Metrics, Tracing and Security #336

Open
wants to merge 12 commits into
base: v4
Choose a base branch
from
Open

Conversation

TimHess
Copy link
Member

@TimHess TimHess commented Jan 3, 2025

Addresses the remaining parts of #317.

@TimHess TimHess self-assigned this Jan 3, 2025
Copy link

github-actions bot commented Jan 3, 2025

Preview link: https://docs-steeltoe-pr-336.azurewebsites.net

  • Your changes have been deployed to the preview site. The preview site will update as you add more commits to this branch.
  • The preview link is shareable, but will be deleted when the pull request is merged or closed.

This is an automated message.

Copy link
Member

@bart-vmware bart-vmware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few things that caught my eye while reading through the pages. I haven't done a thorough review yet.

api/v4/management/metrics.md Outdated Show resolved Hide resolved
api/v4/management/metrics.md Outdated Show resolved Hide resolved
api/v4/management/metrics.md Outdated Show resolved Hide resolved
## Instrumentation

In order for the Prometheus endpoint to return metrics, the application and relevant libraries need to be instrumented.
This page will cover the basics that Steeltoe has previously configured automatically, and you should refer to the [OpenTelemetry documentation](https://opentelemetry.io/docs/languages/net/instrumentation/) for more information.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the basics that Steeltoe has previously configured automatically

Does this refer to earlier versions of Steeltoe, as opposed to referring to an earlier section in this document?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it does, and should probably be worded differently. I don't think this is the only location that refers to previous Steeltoe versions, I'm not sure if we should always say it exactly the same way, or maybe rotate several variations just to avoid verbatim repetition... either way it all needs another pass to definitively avoid ambiguities like you've pointed out here

api/v4/management/prometheus.md Outdated Show resolved Hide resolved
api/v4/management/prometheus.md Outdated Show resolved Hide resolved
api/v4/security/sso-open-id.md Outdated Show resolved Hide resolved
api/v4/security/sso-open-id.md Outdated Show resolved Hide resolved
api/v4/security/sso-open-id.md Outdated Show resolved Hide resolved
api/v4/security/sso-open-id.md Outdated Show resolved Hide resolved
@TimHess TimHess marked this pull request as ready for review January 7, 2025 20:21
@TimHess TimHess requested a review from bart-vmware January 8, 2025 15:04
@bart-vmware
Copy link
Member

redis-key-storage-provider.md still needs to be updated.

Copy link
Member

@bart-vmware bart-vmware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some initial feedback, I need more time to dive into this.

Comment on lines +120 to +122
| CLR | Heap memory, garbage collections, thread utilization. |
| HTTPClient | Request timings and counts. |
| ASP.NET Core | Request timings and counts. |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it's just me, but I find it hard to understand the relationship of these entries with the actual configuration settings. I recommend to drop this table (which adds an indirection that's hard to correlate to the actual settings) and instead provide good documentation in the configuration keys themselves.

For the CLR-type observers, we should link to the list of metrics it affects, such as here, or list them explicitly. And sync up the doc-comments on MetricsObserverOptions in Steeltoe.

Looking at the Steeltoe source, these are the affected metrics:

I'm not sure these lists are complete or actually work. Surely needs testing, there are bugs.

Why do we have our own observers, instead of rely on the built-in metrics that the .NET runtime provides?

Copy link
Member Author

@TimHess TimHess Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, I just shuffled this content around and made surface-level changes. But you're right, we need to comprehensively review the observers too since it's just not very well done.

I thought the work around Observers was focused on removing the OpenTelemetry dependency and syncing with Spring, which should explain why we wouldn't be completely in sync with .NET... But what we're seeing still doesn't make much sense through that lens either and it might take a bit longer to sort out properly.

I believe we still need the DiagnosticObserver abstraction (or something similar) in order to collect what the EventSources emit... The OpenTelemetry instrumentation packages have a ListenerHandler that is pretty much the same thing.

| `HttpClientCore` | Enable Http Client Metrics. | `false` |
| `HttpClientDesktop` | Enable Http Client Desktop Metrics. | `false` |
| `ExcludedMetrics` | Specify a list of metrics that should not be captured | none |
| `HttpClient` | Capture outgoing HTTP requests using [`HttpClient`](https://learn.microsoft.com//dotnet/api/system.net.http.httpclient). | `false` |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HttpClient is actually incorrect, unless we rename the property. See SteeltoeOSS/Steeltoe#1423.

api/v4/management/prometheus.md Outdated Show resolved Hide resolved

The Steeltoe package `Steeltoe.Configuration.CloudFoundry` reads Single Sign-On credentials from Cloud Foundry service bindings (`VCAP_SERVICES`) and re-maps them for Microsoft's JwtBearer library to read. Add the configuration provider to your application with this code:

```csharp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Namespace imports are missing here.

@@ -4,7 +4,7 @@ To improve the Steeltoe developer experience, this feature allows the configurat

Get started by adding a reference to the AutoConfiguration package (you may want to add other Steeltoe references at this point too, see [the table below](#supported-steeltoe-packages) for the full list of what's supported):

```
```shell
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could also be added in fileshares/usage.md

Copy link
Member

@bart-vmware bart-vmware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Publishing accumulated feedback at the end of my day, I haven't looked at all files yet.

@@ -56,6 +57,9 @@ Several steps need to happen before certificate authorization policies can be us
1. Authorization services and policies need to be added
1. Middleware needs to be activated

> [!NOTE]
> This section is only required on applications that are receiving certificate-authorized requests.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The namespace imports in the code block below are incorrect. It should be:

using Microsoft.AspNetCore.Authentication.Certificate;
using Steeltoe.Security.Authorization.Certificate;

@@ -56,6 +57,9 @@ Several steps need to happen before certificate authorization policies can be us
1. Authorization services and policies need to be added
1. Middleware needs to be activated

> [!NOTE]
> This section is only required on applications that are receiving certificate-authorized requests.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment in the code block below should be changed from:

Register Steeltoe components and policies requiring space or org to match between client and server certificates

to:

Register Steeltoe components and policies requiring org and space to match between client and server certificates

@@ -74,6 +78,7 @@ builder.Services.AddAuthorizationBuilder()

> [!TIP]
> Steeltoe configures the certificate forwarding middleware to look for a certificate in the `X-Client-Cert` HTTP header.
> To change the header name used for authorization, pass your value in when registering the policy: `.AddOrgAndSpacePolicies("Custom-Certificate-Header")`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line below:
use the IApplicationBuilder extension method UseCertificateAuthorization:
use the UseCertificateAuthorization extension method on IApplicationBuilder:

@@ -74,6 +78,7 @@ builder.Services.AddAuthorizationBuilder()

> [!TIP]
> Steeltoe configures the certificate forwarding middleware to look for a certificate in the `X-Client-Cert` HTTP header.
> To change the header name used for authorization, pass your value in when registering the policy: `.AddOrgAndSpacePolicies("Custom-Certificate-Header")`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving the section "Steeltoe exposes some of the policy-related..." before "To activate certificate-based authorization" feels more natural to me.

@@ -74,6 +78,7 @@ builder.Services.AddAuthorizationBuilder()

> [!TIP]
> Steeltoe configures the certificate forwarding middleware to look for a certificate in the `X-Client-Cert` HTTP header.
> To change the header name used for authorization, pass your value in when registering the policy: `.AddOrgAndSpacePolicies("Custom-Certificate-Header")`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment below:

// Requirement classes are public

Should be replaced with:

// Or the equivalent using different syntax

And would:

            [
                new SameOrgRequirement(),
                new SameSpaceRequirement()
            ]

fit on a single line?

api/v4/management/prometheus.md Outdated Show resolved Hide resolved
api/v4/security/sso-open-id.md Outdated Show resolved Hide resolved

If Single Sign-On for Tanzu is not available or desired for your application, you can use UAA as an alternative.

There is no service broker available to manage service instances or bindings for UAA, so a [user provided service instance](https://docs.cloudfoundry.org/devguide/services/user-provided.html) should be used to hold the credentials.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
There is no service broker available to manage service instances or bindings for UAA, so a [user provided service instance](https://docs.cloudfoundry.org/devguide/services/user-provided.html) should be used to hold the credentials.
There is no service broker available to manage service instances or bindings for UAA, so a [user provided service instance](https://docs.cloudfoundry.org/devguide/services/user-provided.html) must be used to hold the credentials.

api/v4/security/jwt-bearer.md Outdated Show resolved Hide resolved
api/v4/security/jwt-bearer.md Outdated Show resolved Hide resolved
@bart-vmware bart-vmware mentioned this pull request Jan 16, 2025
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants