-
Notifications
You must be signed in to change notification settings - Fork 298
Add user principal tag in metrics #2445
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
Changes from all commits
eec30db
4580c0b
9905344
7702e78
1f17793
b0e2cd7
8830a3d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,9 @@ public interface MetricsConfiguration { | |
/** Configuration for the Realm ID metric tag. */ | ||
RealmIdTag realmIdTag(); | ||
|
||
/** Configuration for the user principal metric tag. */ | ||
UserPrincipalTag userPrincipalTag(); | ||
|
||
interface RealmIdTag { | ||
|
||
/** | ||
|
@@ -65,4 +68,16 @@ interface RealmIdTag { | |
@Min(1) | ||
int httpMetricsMaxCardinality(); | ||
} | ||
|
||
interface UserPrincipalTag { | ||
|
||
/** | ||
* Whether to include the User Principal tag in the API request metrics. | ||
* | ||
* <p>Beware that if the cardinality of this tag is too high, it can cause performance issues or | ||
* even crash the server. | ||
*/ | ||
@WithDefault("false") | ||
boolean enableInApiMetrics(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Defaulting to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @dimas-b I sent an email to |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,9 @@ public Map<String, String> getConfigOverrides() { | |
"polaris.metrics.realm-id-tag.enable-in-api-metrics", | ||
"true", | ||
"polaris.metrics.realm-id-tag.enable-in-http-metrics", | ||
"true"); | ||
"true", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At some point I think we'll need to refactor these tests and create a sort of "parameterized Quarkus test" that tests all the combinations of (realm tag on/off) x (principal tag on/off). But we can look into that later. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, good point. Thanks! |
||
"polaris.metrics.user-principal-tag.enable-in-api-metrics", | ||
"false"); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.polaris.service.metrics; | ||
|
||
import io.quarkus.test.junit.QuarkusTest; | ||
import io.quarkus.test.junit.QuarkusTestProfile; | ||
import io.quarkus.test.junit.TestProfile; | ||
import java.util.Map; | ||
|
||
@QuarkusTest | ||
@TestProfile(UserPrincipalTagDisabledMetricsTest.Profile.class) | ||
public class UserPrincipalTagDisabledMetricsTest extends MetricsTestBase { | ||
|
||
public static class Profile implements QuarkusTestProfile { | ||
|
||
@Override | ||
public Map<String, String> getConfigOverrides() { | ||
return Map.of( | ||
"polaris.metrics.tags.environment", "prod", "polaris.realm-context.type", "test"); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.polaris.service.metrics; | ||
|
||
import io.quarkus.test.junit.QuarkusTest; | ||
import io.quarkus.test.junit.QuarkusTestProfile; | ||
import io.quarkus.test.junit.TestProfile; | ||
import java.util.Map; | ||
|
||
@QuarkusTest | ||
@TestProfile(UserPrincipalTagEnabledMetricsTest.Profile.class) | ||
public class UserPrincipalTagEnabledMetricsTest extends MetricsTestBase { | ||
|
||
public static class Profile implements QuarkusTestProfile { | ||
|
||
@Override | ||
public Map<String, String> getConfigOverrides() { | ||
return Map.of( | ||
"polaris.metrics.tags.environment", | ||
"prod", | ||
"polaris.metrics.user-principal-tag.enable-in-api-metrics", | ||
"true", | ||
"polaris.metrics.realm-id-tag.enable-in-api-metrics", | ||
"false", | ||
"polaris.metrics.realm-id-tag.enable-in-http-metrics", | ||
"false"); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we are missing a readiness check when both tags are enabled, since this is the most dangerous situation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, this is a great point. I added one.