Skip to content

Commit 281301a

Browse files
authored
Merge pull request #146 from OneLiteFeatherNET/feat/otlp-oidc-patches
feat: jwks refresh and otlp adjustments
2 parents 3f61584 + 4a3b754 commit 281301a

File tree

7 files changed

+73
-10
lines changed

7 files changed

+73
-10
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "feedback-fusion"
3-
version = "0.3.0"
3+
version = "0.4.0"
44
edition = "2021"
55
license = "MIT"
66

charts/feedback-fusion/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ type: application
1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
1717
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18-
version: 0.3.0
18+
version: 0.3.1
1919

2020
# This is the version number of the application being deployed. This version number should be
2121
# incremented each time you make changes to the application. Versions are not expected to
2222
# follow Semantic Versioning. They should reflect the version the application is using.
2323
# It is recommended to use it with quotes.
24-
appVersion: "0.3.0"
24+
appVersion: "0.4.0"

src/config.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,6 @@ macro_rules! update_otherwise_create {
345345
};
346346
}
347347

348-
#[instrument(skip_all)]
349348
pub async fn sync_target(target: TargetConfig, transaction: &dyn Executor) -> Result<()> {
350349
let id = target.id.clone();
351350
update_otherwise_create!(transaction, Target, target, name, description);
@@ -359,7 +358,6 @@ pub async fn sync_target(target: TargetConfig, transaction: &dyn Executor) -> Re
359358
Ok(())
360359
}
361360

362-
#[instrument(skip_all)]
363361
pub async fn sync_prompt(
364362
prompt: PromptConfig,
365363
transaction: &dyn Executor,
@@ -377,7 +375,6 @@ pub async fn sync_prompt(
377375
Ok(())
378376
}
379377

380-
#[instrument(skip_all)]
381378
pub async fn sync_field(
382379
field: FieldConfig,
383380
transaction: &dyn Executor,

src/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
*/
2222
#![allow(clippy::too_many_arguments)]
2323

24+
use std::time::Duration;
25+
2426
use crate::{
2527
prelude::*,
2628
services::v1::{FeedbackFusionV1Context, PublicFeedbackFusionV1Context},
@@ -96,6 +98,7 @@ async fn main() {
9698
// build the authority
9799
info!("Tryng to contact the OIDC Provider");
98100
let authority = oidc::authority().await.unwrap();
101+
authority.spawn_refresh(Duration::from_secs(60 * 60 * 6));
99102
let authorizer = Oauth2Authorizer::new()
100103
.with_claims::<OIDCClaims>()
101104
.with_verbose_error_handler();

src/otlp.rs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ pub fn init_tracing() {
6464
tracer_provider.tracer("feedback-fusion"),
6565
));
6666
tracing::subscriber::set_global_default(subscriber).ok();
67+
68+
info!("Initiating tracing with collector {}", endpoint);
6769
}
6870
}
6971

@@ -72,13 +74,32 @@ pub struct MakeFeedbackFusionSpan;
7274

7375
impl<B> MakeSpan<B> for MakeFeedbackFusionSpan {
7476
fn make_span(&mut self, request: &Request<B>) -> Span {
75-
// make the span
76-
let span = tracing::info_span!(
77+
let span = if request.uri().path().contains("grpc.health.v1.Health/Check") {
78+
tracing::debug_span!("HealthCheck")
79+
} else {
80+
let headers = request
81+
.headers()
82+
.iter()
83+
.filter(|(key, value)| {
84+
!key.to_string()
85+
.to_lowercase()
86+
.eq(&"authorization".to_owned())
87+
&& !value
88+
.to_str()
89+
.unwrap_or_default()
90+
.to_lowercase()
91+
.contains("bearer")
92+
})
93+
.collect_vec();
94+
95+
tracing::info_span!(
7796
"gRPC Request",
7897
host = %request.uri().host().unwrap_or_default(),
7998
path = %request.uri().path(),
99+
headers = ?headers,
80100
version = ?request.version()
81-
);
101+
)
102+
};
82103

83104
// try to extract the context
84105
let context = global::get_text_map_propagator(|propagator| {
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
database:
2+
postgres:
3+
username: postgres
4+
password: password
5+
database: postgres
6+
endpoint: localhost:5432
7+
oidc:
8+
provider: http://localhost:5151
9+
issuer: http://localhost:5151
10+
scopes:
11+
- name: "api:feedback-fusion"
12+
grants:
13+
- endpoint: "*"
14+
permissions:
15+
- "*"
16+
groups:
17+
- name: "admin"
18+
grants:
19+
- endpoint: "*"
20+
permissions:
21+
- "*"
22+
preset:
23+
targets:
24+
- id: target
25+
name: TestTarget
26+
description: A nice Target
27+
prompts:
28+
- id: prompt
29+
title: Testprompt
30+
description: A nice Prompt
31+
active: true
32+
fields:
33+
- id: field1
34+
title: TextField
35+
field_type: text
36+
options:
37+
type: text
38+
lines: 1
39+
placeholder: test
40+
41+
otlp:
42+
endpoint: http://tempo:4317

0 commit comments

Comments
 (0)