id
stringlengths
20
153
type
stringclasses
1 value
granularity
stringclasses
14 values
content
stringlengths
16
84.3k
metadata
dict
connector-service_snippet_-1230957448226898650_150_30
clm
snippet
// connector-service/backend/grpc-server/src/logger/formatter.rs S: Subscriber + for<'a> LookupSpan<'a>, { let is_extra = |s: &str| !IMPLICIT_KEYS.contains(s); map_serializer.serialize_entry(HOSTNAME, &self.hostname)?; map_serializer.serialize_entry(PID, &self.pid)?; map_serializer.serialize_entry(LEVEL, &format_args!("{}", metadata.level()))?; map_serializer.serialize_entry(TARGET, metadata.target())?; map_serializer.serialize_entry(SERVICE, &self.service)?; map_serializer.serialize_entry(LINE, &metadata.line())?; map_serializer.serialize_entry(FILE, &metadata.file())?; map_serializer.serialize_entry(FN, name)?; map_serializer .serialize_entry(FULL_NAME, &format_args!("{}::{}", metadata.target(), name))?; if let Ok(time) = &time::OffsetDateTime::now_utc().format(&Iso8601::DEFAULT) { map_serializer.serialize_entry(TIME, time)?; } // Write down implicit default entries. for (key, value) in self.default_fields.iter() { map_serializer.serialize_entry(key, value)?; } let mut explicit_entries_set: HashSet<&str> = HashSet::default(); // Write down explicit event's entries. for (key, value) in storage.values.iter() { map_serializer.serialize_entry(key, value)?; explicit_entries_set.insert(key); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 150, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-1230957448226898650_150_50
clm
snippet
// connector-service/backend/grpc-server/src/logger/formatter.rs S: Subscriber + for<'a> LookupSpan<'a>, { let is_extra = |s: &str| !IMPLICIT_KEYS.contains(s); map_serializer.serialize_entry(HOSTNAME, &self.hostname)?; map_serializer.serialize_entry(PID, &self.pid)?; map_serializer.serialize_entry(LEVEL, &format_args!("{}", metadata.level()))?; map_serializer.serialize_entry(TARGET, metadata.target())?; map_serializer.serialize_entry(SERVICE, &self.service)?; map_serializer.serialize_entry(LINE, &metadata.line())?; map_serializer.serialize_entry(FILE, &metadata.file())?; map_serializer.serialize_entry(FN, name)?; map_serializer .serialize_entry(FULL_NAME, &format_args!("{}::{}", metadata.target(), name))?; if let Ok(time) = &time::OffsetDateTime::now_utc().format(&Iso8601::DEFAULT) { map_serializer.serialize_entry(TIME, time)?; } // Write down implicit default entries. for (key, value) in self.default_fields.iter() { map_serializer.serialize_entry(key, value)?; } let mut explicit_entries_set: HashSet<&str> = HashSet::default(); // Write down explicit event's entries. for (key, value) in storage.values.iter() { map_serializer.serialize_entry(key, value)?; explicit_entries_set.insert(key); } // Write down entries from the span, if it exists. if let Some(span) = &span { let extensions = span.extensions(); if let Some(visitor) = extensions.get::<Storage<'_>>() { for (key, value) in &visitor.values { if is_extra(key) && !explicit_entries_set.contains(key) { map_serializer.serialize_entry(key, value)?; } else { #[allow(clippy::print_stderr)] { eprintln!( "Attempting to log a reserved entry. It won't be added to the logs. key: {key:?}, value: {value:?}" ); } } } } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 150, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-1230957448226898650_175_15
clm
snippet
// connector-service/backend/grpc-server/src/logger/formatter.rs for (key, value) in storage.values.iter() { map_serializer.serialize_entry(key, value)?; explicit_entries_set.insert(key); } // Write down entries from the span, if it exists. if let Some(span) = &span { let extensions = span.extensions(); if let Some(visitor) = extensions.get::<Storage<'_>>() { for (key, value) in &visitor.values { if is_extra(key) && !explicit_entries_set.contains(key) { map_serializer.serialize_entry(key, value)?; } else { #[allow(clippy::print_stderr)]
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 175, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-1230957448226898650_175_30
clm
snippet
// connector-service/backend/grpc-server/src/logger/formatter.rs for (key, value) in storage.values.iter() { map_serializer.serialize_entry(key, value)?; explicit_entries_set.insert(key); } // Write down entries from the span, if it exists. if let Some(span) = &span { let extensions = span.extensions(); if let Some(visitor) = extensions.get::<Storage<'_>>() { for (key, value) in &visitor.values { if is_extra(key) && !explicit_entries_set.contains(key) { map_serializer.serialize_entry(key, value)?; } else { #[allow(clippy::print_stderr)] { eprintln!( "Attempting to log a reserved entry. It won't be added to the logs. key: {key:?}, value: {value:?}" ); } } } } } Ok(()) } /// /// Flush memory buffer into an output stream trailing it with next line.
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 175, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-1230957448226898650_175_50
clm
snippet
// connector-service/backend/grpc-server/src/logger/formatter.rs for (key, value) in storage.values.iter() { map_serializer.serialize_entry(key, value)?; explicit_entries_set.insert(key); } // Write down entries from the span, if it exists. if let Some(span) = &span { let extensions = span.extensions(); if let Some(visitor) = extensions.get::<Storage<'_>>() { for (key, value) in &visitor.values { if is_extra(key) && !explicit_entries_set.contains(key) { map_serializer.serialize_entry(key, value)?; } else { #[allow(clippy::print_stderr)] { eprintln!( "Attempting to log a reserved entry. It won't be added to the logs. key: {key:?}, value: {value:?}" ); } } } } } Ok(()) } /// /// Flush memory buffer into an output stream trailing it with next line. /// /// Should be done by single `write_all` call to avoid fragmentation of log because of multithreading. /// fn flush(&self, mut buffer: Vec<u8>) -> Result<(), std::io::Error> { buffer.write_all(b"\n")?; self.dst_writer.make_writer().write_all(&buffer) } /// Serialize entries of span. fn span_serialize<S>( &self, span: &SpanRef<'_, S>, ty: RecordType, ) -> Result<Vec<u8>, std::io::Error> where S: Subscriber + for<'a> LookupSpan<'a>, { let mut buffer = Vec::new(); let mut serializer = serde_json::Serializer::new(&mut buffer); let mut map_serializer = serializer.serialize_map(None)?;
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 175, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-1230957448226898650_200_15
clm
snippet
// connector-service/backend/grpc-server/src/logger/formatter.rs Ok(()) } /// /// Flush memory buffer into an output stream trailing it with next line. /// /// Should be done by single `write_all` call to avoid fragmentation of log because of multithreading. /// fn flush(&self, mut buffer: Vec<u8>) -> Result<(), std::io::Error> { buffer.write_all(b"\n")?; self.dst_writer.make_writer().write_all(&buffer) } /// Serialize entries of span. fn span_serialize<S>(
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 200, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-1230957448226898650_200_30
clm
snippet
// connector-service/backend/grpc-server/src/logger/formatter.rs Ok(()) } /// /// Flush memory buffer into an output stream trailing it with next line. /// /// Should be done by single `write_all` call to avoid fragmentation of log because of multithreading. /// fn flush(&self, mut buffer: Vec<u8>) -> Result<(), std::io::Error> { buffer.write_all(b"\n")?; self.dst_writer.make_writer().write_all(&buffer) } /// Serialize entries of span. fn span_serialize<S>( &self, span: &SpanRef<'_, S>, ty: RecordType, ) -> Result<Vec<u8>, std::io::Error> where S: Subscriber + for<'a> LookupSpan<'a>, { let mut buffer = Vec::new(); let mut serializer = serde_json::Serializer::new(&mut buffer); let mut map_serializer = serializer.serialize_map(None)?; let message = Self::span_message(span, ty); let mut storage = Storage::default(); storage.record_value(MESSAGE, message.into()); self.common_serialize(
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 200, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-1230957448226898650_200_50
clm
snippet
// connector-service/backend/grpc-server/src/logger/formatter.rs Ok(()) } /// /// Flush memory buffer into an output stream trailing it with next line. /// /// Should be done by single `write_all` call to avoid fragmentation of log because of multithreading. /// fn flush(&self, mut buffer: Vec<u8>) -> Result<(), std::io::Error> { buffer.write_all(b"\n")?; self.dst_writer.make_writer().write_all(&buffer) } /// Serialize entries of span. fn span_serialize<S>( &self, span: &SpanRef<'_, S>, ty: RecordType, ) -> Result<Vec<u8>, std::io::Error> where S: Subscriber + for<'a> LookupSpan<'a>, { let mut buffer = Vec::new(); let mut serializer = serde_json::Serializer::new(&mut buffer); let mut map_serializer = serializer.serialize_map(None)?; let message = Self::span_message(span, ty); let mut storage = Storage::default(); storage.record_value(MESSAGE, message.into()); self.common_serialize( &mut map_serializer, span.metadata(), Some(span), &storage, span.name(), )?; map_serializer.end()?; Ok(buffer) } /// Serialize event into a buffer of bytes using parent span. pub fn event_serialize<S>( &self, span: &Option<&SpanRef<'_, S>>, event: &Event<'_>, ) -> std::io::Result<Vec<u8>> where S: Subscriber + for<'a> LookupSpan<'a>, {
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 200, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-1230957448226898650_225_15
clm
snippet
// connector-service/backend/grpc-server/src/logger/formatter.rs let message = Self::span_message(span, ty); let mut storage = Storage::default(); storage.record_value(MESSAGE, message.into()); self.common_serialize( &mut map_serializer, span.metadata(), Some(span), &storage, span.name(), )?; map_serializer.end()?; Ok(buffer) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 225, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-1230957448226898650_225_30
clm
snippet
// connector-service/backend/grpc-server/src/logger/formatter.rs let message = Self::span_message(span, ty); let mut storage = Storage::default(); storage.record_value(MESSAGE, message.into()); self.common_serialize( &mut map_serializer, span.metadata(), Some(span), &storage, span.name(), )?; map_serializer.end()?; Ok(buffer) } /// Serialize event into a buffer of bytes using parent span. pub fn event_serialize<S>( &self, span: &Option<&SpanRef<'_, S>>, event: &Event<'_>, ) -> std::io::Result<Vec<u8>> where S: Subscriber + for<'a> LookupSpan<'a>, { let mut buffer = Vec::new(); let mut serializer = serde_json::Serializer::new(&mut buffer); let mut map_serializer = serializer.serialize_map(None)?; let mut storage = Storage::default();
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 225, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-1230957448226898650_225_50
clm
snippet
// connector-service/backend/grpc-server/src/logger/formatter.rs let message = Self::span_message(span, ty); let mut storage = Storage::default(); storage.record_value(MESSAGE, message.into()); self.common_serialize( &mut map_serializer, span.metadata(), Some(span), &storage, span.name(), )?; map_serializer.end()?; Ok(buffer) } /// Serialize event into a buffer of bytes using parent span. pub fn event_serialize<S>( &self, span: &Option<&SpanRef<'_, S>>, event: &Event<'_>, ) -> std::io::Result<Vec<u8>> where S: Subscriber + for<'a> LookupSpan<'a>, { let mut buffer = Vec::new(); let mut serializer = serde_json::Serializer::new(&mut buffer); let mut map_serializer = serializer.serialize_map(None)?; let mut storage = Storage::default(); event.record(&mut storage); let name = span.map_or("?", SpanRef::name); Self::event_message(span, event, &mut storage); self.common_serialize(&mut map_serializer, event.metadata(), *span, &storage, name)?; map_serializer.end()?; Ok(buffer) } /// /// Format message of a span. /// /// Example: "[FN_WITHOUT_COLON - START]" /// fn span_message<S>(span: &SpanRef<'_, S>, ty: RecordType) -> String where S: Subscriber + for<'a> LookupSpan<'a>, {
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 225, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-1230957448226898650_250_15
clm
snippet
// connector-service/backend/grpc-server/src/logger/formatter.rs let mut buffer = Vec::new(); let mut serializer = serde_json::Serializer::new(&mut buffer); let mut map_serializer = serializer.serialize_map(None)?; let mut storage = Storage::default(); event.record(&mut storage); let name = span.map_or("?", SpanRef::name); Self::event_message(span, event, &mut storage); self.common_serialize(&mut map_serializer, event.metadata(), *span, &storage, name)?; map_serializer.end()?; Ok(buffer) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 250, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-1230957448226898650_250_30
clm
snippet
// connector-service/backend/grpc-server/src/logger/formatter.rs let mut buffer = Vec::new(); let mut serializer = serde_json::Serializer::new(&mut buffer); let mut map_serializer = serializer.serialize_map(None)?; let mut storage = Storage::default(); event.record(&mut storage); let name = span.map_or("?", SpanRef::name); Self::event_message(span, event, &mut storage); self.common_serialize(&mut map_serializer, event.metadata(), *span, &storage, name)?; map_serializer.end()?; Ok(buffer) } /// /// Format message of a span. /// /// Example: "[FN_WITHOUT_COLON - START]" /// fn span_message<S>(span: &SpanRef<'_, S>, ty: RecordType) -> String where S: Subscriber + for<'a> LookupSpan<'a>, { format!("[{} - {}]", span.metadata().name().to_uppercase(), ty) } /// /// Format message of an event.
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 250, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-1230957448226898650_250_50
clm
snippet
// connector-service/backend/grpc-server/src/logger/formatter.rs let mut buffer = Vec::new(); let mut serializer = serde_json::Serializer::new(&mut buffer); let mut map_serializer = serializer.serialize_map(None)?; let mut storage = Storage::default(); event.record(&mut storage); let name = span.map_or("?", SpanRef::name); Self::event_message(span, event, &mut storage); self.common_serialize(&mut map_serializer, event.metadata(), *span, &storage, name)?; map_serializer.end()?; Ok(buffer) } /// /// Format message of a span. /// /// Example: "[FN_WITHOUT_COLON - START]" /// fn span_message<S>(span: &SpanRef<'_, S>, ty: RecordType) -> String where S: Subscriber + for<'a> LookupSpan<'a>, { format!("[{} - {}]", span.metadata().name().to_uppercase(), ty) } /// /// Format message of an event. /// /// Examples: "[FN_WITHOUT_COLON - EVENT] Message" /// fn event_message<S>( span: &Option<&SpanRef<'_, S>>, event: &Event<'_>, storage: &mut Storage<'_>, ) where S: Subscriber + for<'a> LookupSpan<'a>, { let message = storage .values .entry(MESSAGE) .or_insert_with(|| event.metadata().target().into()); // Prepend the span name to the message if span exists. if let (Some(span), Value::String(a)) = (span, message) { *a = format!("{} {}", Self::span_message(span, RecordType::Event), a,); } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 250, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-1230957448226898650_275_15
clm
snippet
// connector-service/backend/grpc-server/src/logger/formatter.rs format!("[{} - {}]", span.metadata().name().to_uppercase(), ty) } /// /// Format message of an event. /// /// Examples: "[FN_WITHOUT_COLON - EVENT] Message" /// fn event_message<S>( span: &Option<&SpanRef<'_, S>>, event: &Event<'_>, storage: &mut Storage<'_>, ) where S: Subscriber + for<'a> LookupSpan<'a>, {
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 275, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-1230957448226898650_275_30
clm
snippet
// connector-service/backend/grpc-server/src/logger/formatter.rs format!("[{} - {}]", span.metadata().name().to_uppercase(), ty) } /// /// Format message of an event. /// /// Examples: "[FN_WITHOUT_COLON - EVENT] Message" /// fn event_message<S>( span: &Option<&SpanRef<'_, S>>, event: &Event<'_>, storage: &mut Storage<'_>, ) where S: Subscriber + for<'a> LookupSpan<'a>, { let message = storage .values .entry(MESSAGE) .or_insert_with(|| event.metadata().target().into()); // Prepend the span name to the message if span exists. if let (Some(span), Value::String(a)) = (span, message) { *a = format!("{} {}", Self::span_message(span, RecordType::Event), a,); } } } #[allow(clippy::expect_used)] impl<S, W> Layer<S> for FormattingLayer<W> where
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 275, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-1230957448226898650_275_50
clm
snippet
// connector-service/backend/grpc-server/src/logger/formatter.rs format!("[{} - {}]", span.metadata().name().to_uppercase(), ty) } /// /// Format message of an event. /// /// Examples: "[FN_WITHOUT_COLON - EVENT] Message" /// fn event_message<S>( span: &Option<&SpanRef<'_, S>>, event: &Event<'_>, storage: &mut Storage<'_>, ) where S: Subscriber + for<'a> LookupSpan<'a>, { let message = storage .values .entry(MESSAGE) .or_insert_with(|| event.metadata().target().into()); // Prepend the span name to the message if span exists. if let (Some(span), Value::String(a)) = (span, message) { *a = format!("{} {}", Self::span_message(span, RecordType::Event), a,); } } } #[allow(clippy::expect_used)] impl<S, W> Layer<S> for FormattingLayer<W> where S: Subscriber + for<'a> LookupSpan<'a>, W: for<'a> MakeWriter<'a> + 'static, { fn on_event(&self, event: &Event<'_>, ctx: Context<'_, S>) { // Event could have no span. let span = ctx.lookup_current(); let result: std::io::Result<Vec<u8>> = self.event_serialize(&span.as_ref(), event); if let Ok(formatted) = result { let _ = self.flush(formatted); } } fn on_enter(&self, id: &tracing::Id, ctx: Context<'_, S>) { let span = ctx.span(id).expect("No span"); if let Ok(serialized) = self.span_serialize(&span, RecordType::EnterSpan) { let _ = self.flush(serialized); } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 275, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-1230957448226898650_300_15
clm
snippet
// connector-service/backend/grpc-server/src/logger/formatter.rs } #[allow(clippy::expect_used)] impl<S, W> Layer<S> for FormattingLayer<W> where S: Subscriber + for<'a> LookupSpan<'a>, W: for<'a> MakeWriter<'a> + 'static, { fn on_event(&self, event: &Event<'_>, ctx: Context<'_, S>) { // Event could have no span. let span = ctx.lookup_current(); let result: std::io::Result<Vec<u8>> = self.event_serialize(&span.as_ref(), event); if let Ok(formatted) = result { let _ = self.flush(formatted);
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 300, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-1230957448226898650_300_30
clm
snippet
// connector-service/backend/grpc-server/src/logger/formatter.rs } #[allow(clippy::expect_used)] impl<S, W> Layer<S> for FormattingLayer<W> where S: Subscriber + for<'a> LookupSpan<'a>, W: for<'a> MakeWriter<'a> + 'static, { fn on_event(&self, event: &Event<'_>, ctx: Context<'_, S>) { // Event could have no span. let span = ctx.lookup_current(); let result: std::io::Result<Vec<u8>> = self.event_serialize(&span.as_ref(), event); if let Ok(formatted) = result { let _ = self.flush(formatted); } } fn on_enter(&self, id: &tracing::Id, ctx: Context<'_, S>) { let span = ctx.span(id).expect("No span"); if let Ok(serialized) = self.span_serialize(&span, RecordType::EnterSpan) { let _ = self.flush(serialized); } } fn on_close(&self, id: tracing::Id, ctx: Context<'_, S>) { let span = ctx.span(&id).expect("No span"); if let Ok(serialized) = self.span_serialize(&span, RecordType::ExitSpan) { let _ = self.flush(serialized); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 300, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-1230957448226898650_300_50
clm
snippet
// connector-service/backend/grpc-server/src/logger/formatter.rs } #[allow(clippy::expect_used)] impl<S, W> Layer<S> for FormattingLayer<W> where S: Subscriber + for<'a> LookupSpan<'a>, W: for<'a> MakeWriter<'a> + 'static, { fn on_event(&self, event: &Event<'_>, ctx: Context<'_, S>) { // Event could have no span. let span = ctx.lookup_current(); let result: std::io::Result<Vec<u8>> = self.event_serialize(&span.as_ref(), event); if let Ok(formatted) = result { let _ = self.flush(formatted); } } fn on_enter(&self, id: &tracing::Id, ctx: Context<'_, S>) { let span = ctx.span(id).expect("No span"); if let Ok(serialized) = self.span_serialize(&span, RecordType::EnterSpan) { let _ = self.flush(serialized); } } fn on_close(&self, id: tracing::Id, ctx: Context<'_, S>) { let span = ctx.span(&id).expect("No span"); if let Ok(serialized) = self.span_serialize(&span, RecordType::ExitSpan) { let _ = self.flush(serialized); } } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 32, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 300, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_6348302695617038329_0_15
clm
snippet
// connector-service/backend/grpc-server/src/logger/storage.rs //! //! Storing [layer](https://docs.rs/tracing-subscriber/0.3.15/tracing_subscriber/layer/trait.Layer.html) for Router. //! use std::{collections::HashMap, fmt, time::Instant}; use tracing::{ field::{Field, Visit}, span::{Attributes, Record}, Id, Subscriber, }; use tracing_subscriber::{layer::Context, Layer}; /// Storage to store key value pairs of spans. #[derive(Clone, Debug)]
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_6348302695617038329_0_30
clm
snippet
// connector-service/backend/grpc-server/src/logger/storage.rs //! //! Storing [layer](https://docs.rs/tracing-subscriber/0.3.15/tracing_subscriber/layer/trait.Layer.html) for Router. //! use std::{collections::HashMap, fmt, time::Instant}; use tracing::{ field::{Field, Visit}, span::{Attributes, Record}, Id, Subscriber, }; use tracing_subscriber::{layer::Context, Layer}; /// Storage to store key value pairs of spans. #[derive(Clone, Debug)] pub struct StorageSubscription; /// Storage to store key value pairs of spans. /// When new entry is crated it stores it in [HashMap] which is owned by `extensions`. #[derive(Clone, Debug)] pub struct Storage<'a> { /// Hash map to store values. pub values: HashMap<&'a str, serde_json::Value>, } impl<'a> Storage<'a> { /// Default constructor. pub fn new() -> Self { Self::default() }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_6348302695617038329_0_50
clm
snippet
// connector-service/backend/grpc-server/src/logger/storage.rs //! //! Storing [layer](https://docs.rs/tracing-subscriber/0.3.15/tracing_subscriber/layer/trait.Layer.html) for Router. //! use std::{collections::HashMap, fmt, time::Instant}; use tracing::{ field::{Field, Visit}, span::{Attributes, Record}, Id, Subscriber, }; use tracing_subscriber::{layer::Context, Layer}; /// Storage to store key value pairs of spans. #[derive(Clone, Debug)] pub struct StorageSubscription; /// Storage to store key value pairs of spans. /// When new entry is crated it stores it in [HashMap] which is owned by `extensions`. #[derive(Clone, Debug)] pub struct Storage<'a> { /// Hash map to store values. pub values: HashMap<&'a str, serde_json::Value>, } impl<'a> Storage<'a> { /// Default constructor. pub fn new() -> Self { Self::default() } pub fn record_value(&mut self, key: &'a str, value: serde_json::Value) { if super::formatter::IMPLICIT_KEYS.contains(key) { #[allow(clippy::print_stderr)] { eprintln!("{key} is a reserved entry. Skipping it. value: {value}"); } } else { self.values.insert(key, value); } } } /// Default constructor. impl Default for Storage<'_> { fn default() -> Self { Self { values: HashMap::new(), } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_6348302695617038329_25_15
clm
snippet
// connector-service/backend/grpc-server/src/logger/storage.rs impl<'a> Storage<'a> { /// Default constructor. pub fn new() -> Self { Self::default() } pub fn record_value(&mut self, key: &'a str, value: serde_json::Value) { if super::formatter::IMPLICIT_KEYS.contains(key) { #[allow(clippy::print_stderr)] { eprintln!("{key} is a reserved entry. Skipping it. value: {value}"); } } else { self.values.insert(key, value); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 25, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_6348302695617038329_25_30
clm
snippet
// connector-service/backend/grpc-server/src/logger/storage.rs impl<'a> Storage<'a> { /// Default constructor. pub fn new() -> Self { Self::default() } pub fn record_value(&mut self, key: &'a str, value: serde_json::Value) { if super::formatter::IMPLICIT_KEYS.contains(key) { #[allow(clippy::print_stderr)] { eprintln!("{key} is a reserved entry. Skipping it. value: {value}"); } } else { self.values.insert(key, value); } } } /// Default constructor. impl Default for Storage<'_> { fn default() -> Self { Self { values: HashMap::new(), } } } /// Visitor to store entry. impl Visit for Storage<'_> { /// A i64.
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 25, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_6348302695617038329_25_50
clm
snippet
// connector-service/backend/grpc-server/src/logger/storage.rs impl<'a> Storage<'a> { /// Default constructor. pub fn new() -> Self { Self::default() } pub fn record_value(&mut self, key: &'a str, value: serde_json::Value) { if super::formatter::IMPLICIT_KEYS.contains(key) { #[allow(clippy::print_stderr)] { eprintln!("{key} is a reserved entry. Skipping it. value: {value}"); } } else { self.values.insert(key, value); } } } /// Default constructor. impl Default for Storage<'_> { fn default() -> Self { Self { values: HashMap::new(), } } } /// Visitor to store entry. impl Visit for Storage<'_> { /// A i64. fn record_i64(&mut self, field: &Field, value: i64) { self.record_value(field.name(), serde_json::Value::from(value)); } /// A u64. fn record_u64(&mut self, field: &Field, value: u64) { self.record_value(field.name(), serde_json::Value::from(value)); } /// A 64-bit floating point. fn record_f64(&mut self, field: &Field, value: f64) { self.record_value(field.name(), serde_json::Value::from(value)); } /// A boolean. fn record_bool(&mut self, field: &Field, value: bool) { self.record_value(field.name(), serde_json::Value::from(value)); } /// A string.
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 25, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_6348302695617038329_50_15
clm
snippet
// connector-service/backend/grpc-server/src/logger/storage.rs } /// Visitor to store entry. impl Visit for Storage<'_> { /// A i64. fn record_i64(&mut self, field: &Field, value: i64) { self.record_value(field.name(), serde_json::Value::from(value)); } /// A u64. fn record_u64(&mut self, field: &Field, value: u64) { self.record_value(field.name(), serde_json::Value::from(value)); } /// A 64-bit floating point.
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 50, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_6348302695617038329_50_30
clm
snippet
// connector-service/backend/grpc-server/src/logger/storage.rs } /// Visitor to store entry. impl Visit for Storage<'_> { /// A i64. fn record_i64(&mut self, field: &Field, value: i64) { self.record_value(field.name(), serde_json::Value::from(value)); } /// A u64. fn record_u64(&mut self, field: &Field, value: u64) { self.record_value(field.name(), serde_json::Value::from(value)); } /// A 64-bit floating point. fn record_f64(&mut self, field: &Field, value: f64) { self.record_value(field.name(), serde_json::Value::from(value)); } /// A boolean. fn record_bool(&mut self, field: &Field, value: bool) { self.record_value(field.name(), serde_json::Value::from(value)); } /// A string. fn record_str(&mut self, field: &Field, value: &str) { self.record_value(field.name(), serde_json::Value::from(value)); } /// Otherwise.
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 50, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_6348302695617038329_50_50
clm
snippet
// connector-service/backend/grpc-server/src/logger/storage.rs } /// Visitor to store entry. impl Visit for Storage<'_> { /// A i64. fn record_i64(&mut self, field: &Field, value: i64) { self.record_value(field.name(), serde_json::Value::from(value)); } /// A u64. fn record_u64(&mut self, field: &Field, value: u64) { self.record_value(field.name(), serde_json::Value::from(value)); } /// A 64-bit floating point. fn record_f64(&mut self, field: &Field, value: f64) { self.record_value(field.name(), serde_json::Value::from(value)); } /// A boolean. fn record_bool(&mut self, field: &Field, value: bool) { self.record_value(field.name(), serde_json::Value::from(value)); } /// A string. fn record_str(&mut self, field: &Field, value: &str) { self.record_value(field.name(), serde_json::Value::from(value)); } /// Otherwise. fn record_debug(&mut self, field: &Field, value: &dyn fmt::Debug) { match field.name() { // Skip fields which are already handled name if name.starts_with("log.") => (), name if name.starts_with("r#") => { self.record_value(&name[2..], serde_json::Value::from(format!("{value:?}"))); } name => { self.record_value(name, serde_json::Value::from(format!("{value:?}"))); } }; } } #[allow(clippy::expect_used)] impl<S: Subscriber + for<'a> tracing_subscriber::registry::LookupSpan<'a>> Layer<S> for StorageSubscription { /// On new span. fn on_new_span(&self, attrs: &Attributes<'_>, id: &Id, ctx: Context<'_, S>) {
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 50, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_6348302695617038329_75_15
clm
snippet
// connector-service/backend/grpc-server/src/logger/storage.rs fn record_str(&mut self, field: &Field, value: &str) { self.record_value(field.name(), serde_json::Value::from(value)); } /// Otherwise. fn record_debug(&mut self, field: &Field, value: &dyn fmt::Debug) { match field.name() { // Skip fields which are already handled name if name.starts_with("log.") => (), name if name.starts_with("r#") => { self.record_value(&name[2..], serde_json::Value::from(format!("{value:?}"))); } name => { self.record_value(name, serde_json::Value::from(format!("{value:?}"))); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 75, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_6348302695617038329_75_30
clm
snippet
// connector-service/backend/grpc-server/src/logger/storage.rs fn record_str(&mut self, field: &Field, value: &str) { self.record_value(field.name(), serde_json::Value::from(value)); } /// Otherwise. fn record_debug(&mut self, field: &Field, value: &dyn fmt::Debug) { match field.name() { // Skip fields which are already handled name if name.starts_with("log.") => (), name if name.starts_with("r#") => { self.record_value(&name[2..], serde_json::Value::from(format!("{value:?}"))); } name => { self.record_value(name, serde_json::Value::from(format!("{value:?}"))); } }; } } #[allow(clippy::expect_used)] impl<S: Subscriber + for<'a> tracing_subscriber::registry::LookupSpan<'a>> Layer<S> for StorageSubscription { /// On new span. fn on_new_span(&self, attrs: &Attributes<'_>, id: &Id, ctx: Context<'_, S>) { let span = ctx.span(id).expect("No span"); let mut visitor = if let Some(parent_span) = span.parent() { let mut extensions = parent_span.extensions_mut(); extensions
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 75, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_6348302695617038329_75_50
clm
snippet
// connector-service/backend/grpc-server/src/logger/storage.rs fn record_str(&mut self, field: &Field, value: &str) { self.record_value(field.name(), serde_json::Value::from(value)); } /// Otherwise. fn record_debug(&mut self, field: &Field, value: &dyn fmt::Debug) { match field.name() { // Skip fields which are already handled name if name.starts_with("log.") => (), name if name.starts_with("r#") => { self.record_value(&name[2..], serde_json::Value::from(format!("{value:?}"))); } name => { self.record_value(name, serde_json::Value::from(format!("{value:?}"))); } }; } } #[allow(clippy::expect_used)] impl<S: Subscriber + for<'a> tracing_subscriber::registry::LookupSpan<'a>> Layer<S> for StorageSubscription { /// On new span. fn on_new_span(&self, attrs: &Attributes<'_>, id: &Id, ctx: Context<'_, S>) { let span = ctx.span(id).expect("No span"); let mut visitor = if let Some(parent_span) = span.parent() { let mut extensions = parent_span.extensions_mut(); extensions .get_mut::<Storage<'_>>() .map(|v| v.to_owned()) .unwrap_or_default() } else { Storage::default() }; let mut extensions = span.extensions_mut(); attrs.record(&mut visitor); extensions.insert(visitor); } /// On additional key value pairs store it. fn on_record(&self, span: &Id, values: &Record<'_>, ctx: Context<'_, S>) { let span = ctx.span(span).expect("No span"); let mut extensions = span.extensions_mut(); let visitor = extensions .get_mut::<Storage<'_>>() .expect("The span does not have storage"); values.record(visitor);
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 75, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_6348302695617038329_100_15
clm
snippet
// connector-service/backend/grpc-server/src/logger/storage.rs let span = ctx.span(id).expect("No span"); let mut visitor = if let Some(parent_span) = span.parent() { let mut extensions = parent_span.extensions_mut(); extensions .get_mut::<Storage<'_>>() .map(|v| v.to_owned()) .unwrap_or_default() } else { Storage::default() }; let mut extensions = span.extensions_mut(); attrs.record(&mut visitor); extensions.insert(visitor);
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 100, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_6348302695617038329_100_30
clm
snippet
// connector-service/backend/grpc-server/src/logger/storage.rs let span = ctx.span(id).expect("No span"); let mut visitor = if let Some(parent_span) = span.parent() { let mut extensions = parent_span.extensions_mut(); extensions .get_mut::<Storage<'_>>() .map(|v| v.to_owned()) .unwrap_or_default() } else { Storage::default() }; let mut extensions = span.extensions_mut(); attrs.record(&mut visitor); extensions.insert(visitor); } /// On additional key value pairs store it. fn on_record(&self, span: &Id, values: &Record<'_>, ctx: Context<'_, S>) { let span = ctx.span(span).expect("No span"); let mut extensions = span.extensions_mut(); let visitor = extensions .get_mut::<Storage<'_>>() .expect("The span does not have storage"); values.record(visitor); } /// On enter store time. fn on_enter(&self, span: &Id, ctx: Context<'_, S>) { let span = ctx.span(span).expect("No span");
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 100, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_6348302695617038329_100_50
clm
snippet
// connector-service/backend/grpc-server/src/logger/storage.rs let span = ctx.span(id).expect("No span"); let mut visitor = if let Some(parent_span) = span.parent() { let mut extensions = parent_span.extensions_mut(); extensions .get_mut::<Storage<'_>>() .map(|v| v.to_owned()) .unwrap_or_default() } else { Storage::default() }; let mut extensions = span.extensions_mut(); attrs.record(&mut visitor); extensions.insert(visitor); } /// On additional key value pairs store it. fn on_record(&self, span: &Id, values: &Record<'_>, ctx: Context<'_, S>) { let span = ctx.span(span).expect("No span"); let mut extensions = span.extensions_mut(); let visitor = extensions .get_mut::<Storage<'_>>() .expect("The span does not have storage"); values.record(visitor); } /// On enter store time. fn on_enter(&self, span: &Id, ctx: Context<'_, S>) { let span = ctx.span(span).expect("No span"); let mut extensions = span.extensions_mut(); if extensions.get_mut::<Instant>().is_none() { extensions.insert(Instant::now()); } } /// On close create an entry about how long did it take. fn on_close(&self, span: Id, ctx: Context<'_, S>) { let span = ctx.span(&span).expect("No span"); let elapsed_milliseconds = { let extensions = span.extensions(); extensions .get::<Instant>() .map(|i| i.elapsed().as_millis()) .unwrap_or(0) }; let mut extensions_mut = span.extensions_mut(); let visitor = extensions_mut
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 100, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_6348302695617038329_125_15
clm
snippet
// connector-service/backend/grpc-server/src/logger/storage.rs } /// On enter store time. fn on_enter(&self, span: &Id, ctx: Context<'_, S>) { let span = ctx.span(span).expect("No span"); let mut extensions = span.extensions_mut(); if extensions.get_mut::<Instant>().is_none() { extensions.insert(Instant::now()); } } /// On close create an entry about how long did it take. fn on_close(&self, span: Id, ctx: Context<'_, S>) { let span = ctx.span(&span).expect("No span");
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 125, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_6348302695617038329_125_30
clm
snippet
// connector-service/backend/grpc-server/src/logger/storage.rs } /// On enter store time. fn on_enter(&self, span: &Id, ctx: Context<'_, S>) { let span = ctx.span(span).expect("No span"); let mut extensions = span.extensions_mut(); if extensions.get_mut::<Instant>().is_none() { extensions.insert(Instant::now()); } } /// On close create an entry about how long did it take. fn on_close(&self, span: Id, ctx: Context<'_, S>) { let span = ctx.span(&span).expect("No span"); let elapsed_milliseconds = { let extensions = span.extensions(); extensions .get::<Instant>() .map(|i| i.elapsed().as_millis()) .unwrap_or(0) }; let mut extensions_mut = span.extensions_mut(); let visitor = extensions_mut .get_mut::<Storage<'_>>() .expect("No visitor in extensions"); if let Ok(elapsed) = serde_json::to_value(elapsed_milliseconds) { visitor.record_value("elapsed_milliseconds", elapsed);
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 125, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_6348302695617038329_125_50
clm
snippet
// connector-service/backend/grpc-server/src/logger/storage.rs } /// On enter store time. fn on_enter(&self, span: &Id, ctx: Context<'_, S>) { let span = ctx.span(span).expect("No span"); let mut extensions = span.extensions_mut(); if extensions.get_mut::<Instant>().is_none() { extensions.insert(Instant::now()); } } /// On close create an entry about how long did it take. fn on_close(&self, span: Id, ctx: Context<'_, S>) { let span = ctx.span(&span).expect("No span"); let elapsed_milliseconds = { let extensions = span.extensions(); extensions .get::<Instant>() .map(|i| i.elapsed().as_millis()) .unwrap_or(0) }; let mut extensions_mut = span.extensions_mut(); let visitor = extensions_mut .get_mut::<Storage<'_>>() .expect("No visitor in extensions"); if let Ok(elapsed) = serde_json::to_value(elapsed_milliseconds) { visitor.record_value("elapsed_milliseconds", elapsed); } } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 33, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 125, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8913100032470277647_0_15
clm
snippet
// connector-service/backend/grpc-server/src/logger/setup.rs //! Setup logging subsystem. use std::collections::{HashMap, HashSet}; use tracing_appender::non_blocking::WorkerGuard; #[cfg(feature = "kafka")] use tracing_kafka::KafkaLayer; use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, Layer}; use super::config; /// Contains guards necessary for logging #[derive(Debug)] pub struct TelemetryGuard { _log_guards: Vec<WorkerGuard>, }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8913100032470277647_0_30
clm
snippet
// connector-service/backend/grpc-server/src/logger/setup.rs //! Setup logging subsystem. use std::collections::{HashMap, HashSet}; use tracing_appender::non_blocking::WorkerGuard; #[cfg(feature = "kafka")] use tracing_kafka::KafkaLayer; use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, Layer}; use super::config; /// Contains guards necessary for logging #[derive(Debug)] pub struct TelemetryGuard { _log_guards: Vec<WorkerGuard>, } /// Setup logging sub-system specifying the logging configuration, service (binary) name, and a /// list of external crates for which a more verbose logging must be enabled. All crates within the /// current cargo workspace are automatically considered for verbose logging. pub fn setup( config: &config::Log, service_name: &str, crates_to_filter: impl AsRef<[&'static str]>, ) -> Result<TelemetryGuard, log_utils::LoggerError> { let static_top_level_fields = HashMap::from_iter([ ("service".to_string(), serde_json::json!(service_name)), ( "build_version".to_string(), serde_json::json!(crate::version!()), ),
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8913100032470277647_0_50
clm
snippet
// connector-service/backend/grpc-server/src/logger/setup.rs //! Setup logging subsystem. use std::collections::{HashMap, HashSet}; use tracing_appender::non_blocking::WorkerGuard; #[cfg(feature = "kafka")] use tracing_kafka::KafkaLayer; use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, Layer}; use super::config; /// Contains guards necessary for logging #[derive(Debug)] pub struct TelemetryGuard { _log_guards: Vec<WorkerGuard>, } /// Setup logging sub-system specifying the logging configuration, service (binary) name, and a /// list of external crates for which a more verbose logging must be enabled. All crates within the /// current cargo workspace are automatically considered for verbose logging. pub fn setup( config: &config::Log, service_name: &str, crates_to_filter: impl AsRef<[&'static str]>, ) -> Result<TelemetryGuard, log_utils::LoggerError> { let static_top_level_fields = HashMap::from_iter([ ("service".to_string(), serde_json::json!(service_name)), ( "build_version".to_string(), serde_json::json!(crate::version!()), ), ]); let console_config = if config.console.enabled { let console_filter_directive = config .console .filtering_directive .clone() .unwrap_or_else(|| { get_envfilter_directive( tracing::Level::WARN, config.console.level.into_level(), crates_to_filter.as_ref(), ) }); let log_format = match config.console.log_format { config::LogFormat::Default => log_utils::ConsoleLogFormat::HumanReadable, config::LogFormat::Json => { // Disable color or emphasis related ANSI escape codes for JSON formats error_stack::Report::set_color_mode(error_stack::fmt::ColorMode::None);
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8913100032470277647_25_15
clm
snippet
// connector-service/backend/grpc-server/src/logger/setup.rs ("service".to_string(), serde_json::json!(service_name)), ( "build_version".to_string(), serde_json::json!(crate::version!()), ), ]); let console_config = if config.console.enabled { let console_filter_directive = config .console .filtering_directive .clone() .unwrap_or_else(|| { get_envfilter_directive(
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 25, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8913100032470277647_25_30
clm
snippet
// connector-service/backend/grpc-server/src/logger/setup.rs ("service".to_string(), serde_json::json!(service_name)), ( "build_version".to_string(), serde_json::json!(crate::version!()), ), ]); let console_config = if config.console.enabled { let console_filter_directive = config .console .filtering_directive .clone() .unwrap_or_else(|| { get_envfilter_directive( tracing::Level::WARN, config.console.level.into_level(), crates_to_filter.as_ref(), ) }); let log_format = match config.console.log_format { config::LogFormat::Default => log_utils::ConsoleLogFormat::HumanReadable, config::LogFormat::Json => { // Disable color or emphasis related ANSI escape codes for JSON formats error_stack::Report::set_color_mode(error_stack::fmt::ColorMode::None); log_utils::ConsoleLogFormat::CompactJson } };
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 25, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8913100032470277647_25_50
clm
snippet
// connector-service/backend/grpc-server/src/logger/setup.rs ("service".to_string(), serde_json::json!(service_name)), ( "build_version".to_string(), serde_json::json!(crate::version!()), ), ]); let console_config = if config.console.enabled { let console_filter_directive = config .console .filtering_directive .clone() .unwrap_or_else(|| { get_envfilter_directive( tracing::Level::WARN, config.console.level.into_level(), crates_to_filter.as_ref(), ) }); let log_format = match config.console.log_format { config::LogFormat::Default => log_utils::ConsoleLogFormat::HumanReadable, config::LogFormat::Json => { // Disable color or emphasis related ANSI escape codes for JSON formats error_stack::Report::set_color_mode(error_stack::fmt::ColorMode::None); log_utils::ConsoleLogFormat::CompactJson } }; Some(log_utils::ConsoleLoggingConfig { level: config.console.level.into_level(), log_format, filtering_directive: Some(console_filter_directive), print_filtering_directive: log_utils::DirectivePrintTarget::Stderr, }) } else { None }; let logger_config = log_utils::LoggerConfig { static_top_level_fields: static_top_level_fields.clone(), top_level_keys: HashSet::new(), persistent_keys: HashSet::new(), log_span_lifecycles: true, additional_fields_placement: log_utils::AdditionalFieldsPlacement::TopLevel, file_config: None, console_config, global_filtering_directive: None, };
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 25, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8913100032470277647_50_15
clm
snippet
// connector-service/backend/grpc-server/src/logger/setup.rs log_utils::ConsoleLogFormat::CompactJson } }; Some(log_utils::ConsoleLoggingConfig { level: config.console.level.into_level(), log_format, filtering_directive: Some(console_filter_directive), print_filtering_directive: log_utils::DirectivePrintTarget::Stderr, }) } else { None };
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 50, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8913100032470277647_50_30
clm
snippet
// connector-service/backend/grpc-server/src/logger/setup.rs log_utils::ConsoleLogFormat::CompactJson } }; Some(log_utils::ConsoleLoggingConfig { level: config.console.level.into_level(), log_format, filtering_directive: Some(console_filter_directive), print_filtering_directive: log_utils::DirectivePrintTarget::Stderr, }) } else { None }; let logger_config = log_utils::LoggerConfig { static_top_level_fields: static_top_level_fields.clone(), top_level_keys: HashSet::new(), persistent_keys: HashSet::new(), log_span_lifecycles: true, additional_fields_placement: log_utils::AdditionalFieldsPlacement::TopLevel, file_config: None, console_config, global_filtering_directive: None, }; let logging_components = log_utils::build_logging_components(logger_config)?; let mut subscriber_layers = Vec::new();
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 50, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8913100032470277647_50_50
clm
snippet
// connector-service/backend/grpc-server/src/logger/setup.rs log_utils::ConsoleLogFormat::CompactJson } }; Some(log_utils::ConsoleLoggingConfig { level: config.console.level.into_level(), log_format, filtering_directive: Some(console_filter_directive), print_filtering_directive: log_utils::DirectivePrintTarget::Stderr, }) } else { None }; let logger_config = log_utils::LoggerConfig { static_top_level_fields: static_top_level_fields.clone(), top_level_keys: HashSet::new(), persistent_keys: HashSet::new(), log_span_lifecycles: true, additional_fields_placement: log_utils::AdditionalFieldsPlacement::TopLevel, file_config: None, console_config, global_filtering_directive: None, }; let logging_components = log_utils::build_logging_components(logger_config)?; let mut subscriber_layers = Vec::new(); subscriber_layers.push(logging_components.storage_layer.boxed()); if let Some(console_layer) = logging_components.console_log_layer { subscriber_layers.push(console_layer); } #[allow(unused_mut)] let mut kafka_logging_enabled = false; // Add Kafka layer if configured #[cfg(feature = "kafka")] if let Some(kafka_config) = &config.kafka { if kafka_config.enabled { // Initialize kafka metrics if the feature is enabled. // This will cause the application to panic at startup if metric registration fails. tracing_kafka::init(); let kafka_filter_directive = kafka_config.filtering_directive.clone().unwrap_or_else(|| { get_envfilter_directive( tracing::Level::WARN, kafka_config.level.into_level(),
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 50, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8913100032470277647_75_15
clm
snippet
// connector-service/backend/grpc-server/src/logger/setup.rs let logging_components = log_utils::build_logging_components(logger_config)?; let mut subscriber_layers = Vec::new(); subscriber_layers.push(logging_components.storage_layer.boxed()); if let Some(console_layer) = logging_components.console_log_layer { subscriber_layers.push(console_layer); } #[allow(unused_mut)] let mut kafka_logging_enabled = false; // Add Kafka layer if configured #[cfg(feature = "kafka")] if let Some(kafka_config) = &config.kafka {
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 75, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8913100032470277647_75_30
clm
snippet
// connector-service/backend/grpc-server/src/logger/setup.rs let logging_components = log_utils::build_logging_components(logger_config)?; let mut subscriber_layers = Vec::new(); subscriber_layers.push(logging_components.storage_layer.boxed()); if let Some(console_layer) = logging_components.console_log_layer { subscriber_layers.push(console_layer); } #[allow(unused_mut)] let mut kafka_logging_enabled = false; // Add Kafka layer if configured #[cfg(feature = "kafka")] if let Some(kafka_config) = &config.kafka { if kafka_config.enabled { // Initialize kafka metrics if the feature is enabled. // This will cause the application to panic at startup if metric registration fails. tracing_kafka::init(); let kafka_filter_directive = kafka_config.filtering_directive.clone().unwrap_or_else(|| { get_envfilter_directive( tracing::Level::WARN, kafka_config.level.into_level(), crates_to_filter.as_ref(), ) }); let brokers: Vec<&str> = kafka_config.brokers.iter().map(|s| s.as_str()).collect();
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 75, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8913100032470277647_75_50
clm
snippet
// connector-service/backend/grpc-server/src/logger/setup.rs let logging_components = log_utils::build_logging_components(logger_config)?; let mut subscriber_layers = Vec::new(); subscriber_layers.push(logging_components.storage_layer.boxed()); if let Some(console_layer) = logging_components.console_log_layer { subscriber_layers.push(console_layer); } #[allow(unused_mut)] let mut kafka_logging_enabled = false; // Add Kafka layer if configured #[cfg(feature = "kafka")] if let Some(kafka_config) = &config.kafka { if kafka_config.enabled { // Initialize kafka metrics if the feature is enabled. // This will cause the application to panic at startup if metric registration fails. tracing_kafka::init(); let kafka_filter_directive = kafka_config.filtering_directive.clone().unwrap_or_else(|| { get_envfilter_directive( tracing::Level::WARN, kafka_config.level.into_level(), crates_to_filter.as_ref(), ) }); let brokers: Vec<&str> = kafka_config.brokers.iter().map(|s| s.as_str()).collect(); let mut builder = KafkaLayer::builder() .brokers(&brokers) .topic(&kafka_config.topic) .static_fields(static_top_level_fields.clone()); // Add batch_size if configured if let Some(batch_size) = kafka_config.batch_size { builder = builder.batch_size(batch_size); } // Add flush_interval_ms if configured if let Some(flush_interval_ms) = kafka_config.flush_interval_ms { builder = builder.linger_ms(flush_interval_ms); } // Add buffer_limit if configured if let Some(buffer_limit) = kafka_config.buffer_limit { builder = builder.queue_buffering_max_messages(buffer_limit); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 75, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8913100032470277647_100_15
clm
snippet
// connector-service/backend/grpc-server/src/logger/setup.rs crates_to_filter.as_ref(), ) }); let brokers: Vec<&str> = kafka_config.brokers.iter().map(|s| s.as_str()).collect(); let mut builder = KafkaLayer::builder() .brokers(&brokers) .topic(&kafka_config.topic) .static_fields(static_top_level_fields.clone()); // Add batch_size if configured if let Some(batch_size) = kafka_config.batch_size { builder = builder.batch_size(batch_size); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 100, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8913100032470277647_100_30
clm
snippet
// connector-service/backend/grpc-server/src/logger/setup.rs crates_to_filter.as_ref(), ) }); let brokers: Vec<&str> = kafka_config.brokers.iter().map(|s| s.as_str()).collect(); let mut builder = KafkaLayer::builder() .brokers(&brokers) .topic(&kafka_config.topic) .static_fields(static_top_level_fields.clone()); // Add batch_size if configured if let Some(batch_size) = kafka_config.batch_size { builder = builder.batch_size(batch_size); } // Add flush_interval_ms if configured if let Some(flush_interval_ms) = kafka_config.flush_interval_ms { builder = builder.linger_ms(flush_interval_ms); } // Add buffer_limit if configured if let Some(buffer_limit) = kafka_config.buffer_limit { builder = builder.queue_buffering_max_messages(buffer_limit); } let kafka_layer = match builder.build() { Ok(layer) => { // Create filter with infinite feedback loop prevention let kafka_filter_directive = format!( "{kafka_filter_directive},rdkafka=off,librdkafka=off,kafka=off,kafka_writer=off,tracing_kafka=off",
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 100, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8913100032470277647_100_50
clm
snippet
// connector-service/backend/grpc-server/src/logger/setup.rs crates_to_filter.as_ref(), ) }); let brokers: Vec<&str> = kafka_config.brokers.iter().map(|s| s.as_str()).collect(); let mut builder = KafkaLayer::builder() .brokers(&brokers) .topic(&kafka_config.topic) .static_fields(static_top_level_fields.clone()); // Add batch_size if configured if let Some(batch_size) = kafka_config.batch_size { builder = builder.batch_size(batch_size); } // Add flush_interval_ms if configured if let Some(flush_interval_ms) = kafka_config.flush_interval_ms { builder = builder.linger_ms(flush_interval_ms); } // Add buffer_limit if configured if let Some(buffer_limit) = kafka_config.buffer_limit { builder = builder.queue_buffering_max_messages(buffer_limit); } let kafka_layer = match builder.build() { Ok(layer) => { // Create filter with infinite feedback loop prevention let kafka_filter_directive = format!( "{kafka_filter_directive},rdkafka=off,librdkafka=off,kafka=off,kafka_writer=off,tracing_kafka=off", ); let kafka_filter = tracing_subscriber::EnvFilter::builder() .with_default_directive(kafka_config.level.into_level().into()) .parse_lossy(kafka_filter_directive); Some(layer.with_filter(kafka_filter)) } Err(e) => { tracing::warn!(error = ?e, "Failed to enable Kafka logging"); // Continue without Kafka None } }; if let Some(layer) = kafka_layer { subscriber_layers.push(layer.boxed()); kafka_logging_enabled = true; tracing::info!(topic = %kafka_config.topic, "Kafka logging enabled"); } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 100, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8913100032470277647_125_15
clm
snippet
// connector-service/backend/grpc-server/src/logger/setup.rs let kafka_layer = match builder.build() { Ok(layer) => { // Create filter with infinite feedback loop prevention let kafka_filter_directive = format!( "{kafka_filter_directive},rdkafka=off,librdkafka=off,kafka=off,kafka_writer=off,tracing_kafka=off", ); let kafka_filter = tracing_subscriber::EnvFilter::builder() .with_default_directive(kafka_config.level.into_level().into()) .parse_lossy(kafka_filter_directive); Some(layer.with_filter(kafka_filter)) } Err(e) => { tracing::warn!(error = ?e, "Failed to enable Kafka logging"); // Continue without Kafka
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 125, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8913100032470277647_125_30
clm
snippet
// connector-service/backend/grpc-server/src/logger/setup.rs let kafka_layer = match builder.build() { Ok(layer) => { // Create filter with infinite feedback loop prevention let kafka_filter_directive = format!( "{kafka_filter_directive},rdkafka=off,librdkafka=off,kafka=off,kafka_writer=off,tracing_kafka=off", ); let kafka_filter = tracing_subscriber::EnvFilter::builder() .with_default_directive(kafka_config.level.into_level().into()) .parse_lossy(kafka_filter_directive); Some(layer.with_filter(kafka_filter)) } Err(e) => { tracing::warn!(error = ?e, "Failed to enable Kafka logging"); // Continue without Kafka None } }; if let Some(layer) = kafka_layer { subscriber_layers.push(layer.boxed()); kafka_logging_enabled = true; tracing::info!(topic = %kafka_config.topic, "Kafka logging enabled"); } } } tracing_subscriber::registry() .with(subscriber_layers) .init();
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 125, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8913100032470277647_125_50
clm
snippet
// connector-service/backend/grpc-server/src/logger/setup.rs let kafka_layer = match builder.build() { Ok(layer) => { // Create filter with infinite feedback loop prevention let kafka_filter_directive = format!( "{kafka_filter_directive},rdkafka=off,librdkafka=off,kafka=off,kafka_writer=off,tracing_kafka=off", ); let kafka_filter = tracing_subscriber::EnvFilter::builder() .with_default_directive(kafka_config.level.into_level().into()) .parse_lossy(kafka_filter_directive); Some(layer.with_filter(kafka_filter)) } Err(e) => { tracing::warn!(error = ?e, "Failed to enable Kafka logging"); // Continue without Kafka None } }; if let Some(layer) = kafka_layer { subscriber_layers.push(layer.boxed()); kafka_logging_enabled = true; tracing::info!(topic = %kafka_config.topic, "Kafka logging enabled"); } } } tracing_subscriber::registry() .with(subscriber_layers) .init(); tracing::info!( service_name, build_version = crate::version!(), kafka_logging_enabled, "Logging subsystem initialized" ); // Returning the TelemetryGuard for logs to be printed and metrics to be collected until it is // dropped Ok(TelemetryGuard { _log_guards: logging_components.guards, }) } fn get_envfilter_directive( default_log_level: tracing::Level, filter_log_level: tracing::Level, crates_to_filter: impl AsRef<[&'static str]>, ) -> String {
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 125, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8913100032470277647_150_15
clm
snippet
// connector-service/backend/grpc-server/src/logger/setup.rs } tracing_subscriber::registry() .with(subscriber_layers) .init(); tracing::info!( service_name, build_version = crate::version!(), kafka_logging_enabled, "Logging subsystem initialized" ); // Returning the TelemetryGuard for logs to be printed and metrics to be collected until it is // dropped
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 150, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8913100032470277647_150_30
clm
snippet
// connector-service/backend/grpc-server/src/logger/setup.rs } tracing_subscriber::registry() .with(subscriber_layers) .init(); tracing::info!( service_name, build_version = crate::version!(), kafka_logging_enabled, "Logging subsystem initialized" ); // Returning the TelemetryGuard for logs to be printed and metrics to be collected until it is // dropped Ok(TelemetryGuard { _log_guards: logging_components.guards, }) } fn get_envfilter_directive( default_log_level: tracing::Level, filter_log_level: tracing::Level, crates_to_filter: impl AsRef<[&'static str]>, ) -> String { let mut explicitly_handled_targets = build_info::cargo_workspace_members!(); explicitly_handled_targets.extend(build_info::framework_libs_workspace_members()); explicitly_handled_targets.extend(crates_to_filter.as_ref()); // +1 for the default log level added as a directive
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 150, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8913100032470277647_150_50
clm
snippet
// connector-service/backend/grpc-server/src/logger/setup.rs } tracing_subscriber::registry() .with(subscriber_layers) .init(); tracing::info!( service_name, build_version = crate::version!(), kafka_logging_enabled, "Logging subsystem initialized" ); // Returning the TelemetryGuard for logs to be printed and metrics to be collected until it is // dropped Ok(TelemetryGuard { _log_guards: logging_components.guards, }) } fn get_envfilter_directive( default_log_level: tracing::Level, filter_log_level: tracing::Level, crates_to_filter: impl AsRef<[&'static str]>, ) -> String { let mut explicitly_handled_targets = build_info::cargo_workspace_members!(); explicitly_handled_targets.extend(build_info::framework_libs_workspace_members()); explicitly_handled_targets.extend(crates_to_filter.as_ref()); // +1 for the default log level added as a directive let num_directives = explicitly_handled_targets.len() + 1; explicitly_handled_targets .into_iter() .map(|crate_name| crate_name.replace('-', "_")) .zip(std::iter::repeat(filter_log_level)) .fold( { let mut directives = Vec::with_capacity(num_directives); directives.push(default_log_level.to_string()); directives }, |mut directives, (target, level)| { directives.push(format!("{target}={level}")); directives }, ) .join(",") }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 49, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 150, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8913100032470277647_175_15
clm
snippet
// connector-service/backend/grpc-server/src/logger/setup.rs let mut explicitly_handled_targets = build_info::cargo_workspace_members!(); explicitly_handled_targets.extend(build_info::framework_libs_workspace_members()); explicitly_handled_targets.extend(crates_to_filter.as_ref()); // +1 for the default log level added as a directive let num_directives = explicitly_handled_targets.len() + 1; explicitly_handled_targets .into_iter() .map(|crate_name| crate_name.replace('-', "_")) .zip(std::iter::repeat(filter_log_level)) .fold( { let mut directives = Vec::with_capacity(num_directives); directives.push(default_log_level.to_string());
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 175, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8913100032470277647_175_30
clm
snippet
// connector-service/backend/grpc-server/src/logger/setup.rs let mut explicitly_handled_targets = build_info::cargo_workspace_members!(); explicitly_handled_targets.extend(build_info::framework_libs_workspace_members()); explicitly_handled_targets.extend(crates_to_filter.as_ref()); // +1 for the default log level added as a directive let num_directives = explicitly_handled_targets.len() + 1; explicitly_handled_targets .into_iter() .map(|crate_name| crate_name.replace('-', "_")) .zip(std::iter::repeat(filter_log_level)) .fold( { let mut directives = Vec::with_capacity(num_directives); directives.push(default_log_level.to_string()); directives }, |mut directives, (target, level)| { directives.push(format!("{target}={level}")); directives }, ) .join(",") }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 24, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 175, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8913100032470277647_175_50
clm
snippet
// connector-service/backend/grpc-server/src/logger/setup.rs let mut explicitly_handled_targets = build_info::cargo_workspace_members!(); explicitly_handled_targets.extend(build_info::framework_libs_workspace_members()); explicitly_handled_targets.extend(crates_to_filter.as_ref()); // +1 for the default log level added as a directive let num_directives = explicitly_handled_targets.len() + 1; explicitly_handled_targets .into_iter() .map(|crate_name| crate_name.replace('-', "_")) .zip(std::iter::repeat(filter_log_level)) .fold( { let mut directives = Vec::with_capacity(num_directives); directives.push(default_log_level.to_string()); directives }, |mut directives, (target, level)| { directives.push(format!("{target}={level}")); directives }, ) .join(",") }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 24, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 175, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-372326334623076254_0_15
clm
snippet
// connector-service/backend/grpc-server/src/server/refunds.rs use std::sync::Arc; use common_utils::errors::CustomResult; use connector_integration::types::ConnectorData; use domain_types::{ connector_flow::{FlowName, RSync}, connector_types::{RefundFlowData, RefundSyncData, RefundsResponseData}, errors::{ApiError, ApplicationErrorResponse}, payment_method_data::DefaultPCIHolder, router_data::ConnectorAuthType, types::generate_refund_sync_response, utils::ForeignTryFrom, }; use error_stack::ResultExt; use external_services;
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-372326334623076254_0_30
clm
snippet
// connector-service/backend/grpc-server/src/server/refunds.rs use std::sync::Arc; use common_utils::errors::CustomResult; use connector_integration::types::ConnectorData; use domain_types::{ connector_flow::{FlowName, RSync}, connector_types::{RefundFlowData, RefundSyncData, RefundsResponseData}, errors::{ApiError, ApplicationErrorResponse}, payment_method_data::DefaultPCIHolder, router_data::ConnectorAuthType, types::generate_refund_sync_response, utils::ForeignTryFrom, }; use error_stack::ResultExt; use external_services; use grpc_api_types::payments::{ refund_service_server::RefundService, RefundResponse, RefundServiceGetRequest, RefundServiceTransformRequest, RefundServiceTransformResponse, WebhookEventType, WebhookResponseContent, }; use crate::{ configs::Config, error::{IntoGrpcStatus, ReportSwitchExt, ResultExtGrpc}, implement_connector_operation, request::RequestData, utils, }; // Helper trait for refund operations trait RefundOperationsInternal {
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-372326334623076254_0_50
clm
snippet
// connector-service/backend/grpc-server/src/server/refunds.rs use std::sync::Arc; use common_utils::errors::CustomResult; use connector_integration::types::ConnectorData; use domain_types::{ connector_flow::{FlowName, RSync}, connector_types::{RefundFlowData, RefundSyncData, RefundsResponseData}, errors::{ApiError, ApplicationErrorResponse}, payment_method_data::DefaultPCIHolder, router_data::ConnectorAuthType, types::generate_refund_sync_response, utils::ForeignTryFrom, }; use error_stack::ResultExt; use external_services; use grpc_api_types::payments::{ refund_service_server::RefundService, RefundResponse, RefundServiceGetRequest, RefundServiceTransformRequest, RefundServiceTransformResponse, WebhookEventType, WebhookResponseContent, }; use crate::{ configs::Config, error::{IntoGrpcStatus, ReportSwitchExt, ResultExtGrpc}, implement_connector_operation, request::RequestData, utils, }; // Helper trait for refund operations trait RefundOperationsInternal { async fn internal_get( &self, request: RequestData<RefundServiceGetRequest>, ) -> Result<tonic::Response<RefundResponse>, tonic::Status>; } #[derive(Debug)] pub struct Refunds { pub config: Arc<Config>, } impl RefundOperationsInternal for Refunds { implement_connector_operation!( fn_name: internal_get, log_prefix: "REFUND_SYNC", request_type: RefundServiceGetRequest, response_type: RefundResponse, flow_marker: RSync, resource_common_data_type: RefundFlowData, request_data_type: RefundSyncData,
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-372326334623076254_25_15
clm
snippet
// connector-service/backend/grpc-server/src/server/refunds.rs request::RequestData, utils, }; // Helper trait for refund operations trait RefundOperationsInternal { async fn internal_get( &self, request: RequestData<RefundServiceGetRequest>, ) -> Result<tonic::Response<RefundResponse>, tonic::Status>; } #[derive(Debug)] pub struct Refunds { pub config: Arc<Config>, }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 25, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-372326334623076254_25_30
clm
snippet
// connector-service/backend/grpc-server/src/server/refunds.rs request::RequestData, utils, }; // Helper trait for refund operations trait RefundOperationsInternal { async fn internal_get( &self, request: RequestData<RefundServiceGetRequest>, ) -> Result<tonic::Response<RefundResponse>, tonic::Status>; } #[derive(Debug)] pub struct Refunds { pub config: Arc<Config>, } impl RefundOperationsInternal for Refunds { implement_connector_operation!( fn_name: internal_get, log_prefix: "REFUND_SYNC", request_type: RefundServiceGetRequest, response_type: RefundResponse, flow_marker: RSync, resource_common_data_type: RefundFlowData, request_data_type: RefundSyncData, response_data_type: RefundsResponseData, request_data_constructor: RefundSyncData::foreign_try_from, common_flow_data_constructor: RefundFlowData::foreign_try_from, generate_response_fn: generate_refund_sync_response, all_keys_required: None
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 25, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-372326334623076254_25_50
clm
snippet
// connector-service/backend/grpc-server/src/server/refunds.rs request::RequestData, utils, }; // Helper trait for refund operations trait RefundOperationsInternal { async fn internal_get( &self, request: RequestData<RefundServiceGetRequest>, ) -> Result<tonic::Response<RefundResponse>, tonic::Status>; } #[derive(Debug)] pub struct Refunds { pub config: Arc<Config>, } impl RefundOperationsInternal for Refunds { implement_connector_operation!( fn_name: internal_get, log_prefix: "REFUND_SYNC", request_type: RefundServiceGetRequest, response_type: RefundResponse, flow_marker: RSync, resource_common_data_type: RefundFlowData, request_data_type: RefundSyncData, response_data_type: RefundsResponseData, request_data_constructor: RefundSyncData::foreign_try_from, common_flow_data_constructor: RefundFlowData::foreign_try_from, generate_response_fn: generate_refund_sync_response, all_keys_required: None ); } #[tonic::async_trait] impl RefundService for Refunds { #[tracing::instrument( name = "refunds_sync", fields( name = common_utils::consts::NAME, service_name = tracing::field::Empty, service_method = FlowName::Rsync.to_string(), request_body = tracing::field::Empty, response_body = tracing::field::Empty, error_message = tracing::field::Empty, merchant_id = tracing::field::Empty, gateway = tracing::field::Empty, request_id = tracing::field::Empty, status_code = tracing::field::Empty, message_ = "Golden Log Line (incoming)", response_time = tracing::field::Empty,
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 25, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-372326334623076254_50_15
clm
snippet
// connector-service/backend/grpc-server/src/server/refunds.rs response_data_type: RefundsResponseData, request_data_constructor: RefundSyncData::foreign_try_from, common_flow_data_constructor: RefundFlowData::foreign_try_from, generate_response_fn: generate_refund_sync_response, all_keys_required: None ); } #[tonic::async_trait] impl RefundService for Refunds { #[tracing::instrument( name = "refunds_sync", fields( name = common_utils::consts::NAME, service_name = tracing::field::Empty,
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 50, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-372326334623076254_50_30
clm
snippet
// connector-service/backend/grpc-server/src/server/refunds.rs response_data_type: RefundsResponseData, request_data_constructor: RefundSyncData::foreign_try_from, common_flow_data_constructor: RefundFlowData::foreign_try_from, generate_response_fn: generate_refund_sync_response, all_keys_required: None ); } #[tonic::async_trait] impl RefundService for Refunds { #[tracing::instrument( name = "refunds_sync", fields( name = common_utils::consts::NAME, service_name = tracing::field::Empty, service_method = FlowName::Rsync.to_string(), request_body = tracing::field::Empty, response_body = tracing::field::Empty, error_message = tracing::field::Empty, merchant_id = tracing::field::Empty, gateway = tracing::field::Empty, request_id = tracing::field::Empty, status_code = tracing::field::Empty, message_ = "Golden Log Line (incoming)", response_time = tracing::field::Empty, tenant_id = tracing::field::Empty, flow = FlowName::Rsync.to_string(), flow_specific_fields.status = tracing::field::Empty, ) skip(self, request)
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 50, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-372326334623076254_50_50
clm
snippet
// connector-service/backend/grpc-server/src/server/refunds.rs response_data_type: RefundsResponseData, request_data_constructor: RefundSyncData::foreign_try_from, common_flow_data_constructor: RefundFlowData::foreign_try_from, generate_response_fn: generate_refund_sync_response, all_keys_required: None ); } #[tonic::async_trait] impl RefundService for Refunds { #[tracing::instrument( name = "refunds_sync", fields( name = common_utils::consts::NAME, service_name = tracing::field::Empty, service_method = FlowName::Rsync.to_string(), request_body = tracing::field::Empty, response_body = tracing::field::Empty, error_message = tracing::field::Empty, merchant_id = tracing::field::Empty, gateway = tracing::field::Empty, request_id = tracing::field::Empty, status_code = tracing::field::Empty, message_ = "Golden Log Line (incoming)", response_time = tracing::field::Empty, tenant_id = tracing::field::Empty, flow = FlowName::Rsync.to_string(), flow_specific_fields.status = tracing::field::Empty, ) skip(self, request) )] async fn get( &self, request: tonic::Request<RefundServiceGetRequest>, ) -> Result<tonic::Response<RefundResponse>, tonic::Status> { let service_name = request .extensions() .get::<String>() .cloned() .unwrap_or_else(|| "RefundService".to_string()); utils::grpc_logging_wrapper( request, &service_name, self.config.clone(), common_utils::events::FlowName::Rsync, |request_data| async move { self.internal_get(request_data).await }, ) .await }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 50, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-372326334623076254_75_15
clm
snippet
// connector-service/backend/grpc-server/src/server/refunds.rs tenant_id = tracing::field::Empty, flow = FlowName::Rsync.to_string(), flow_specific_fields.status = tracing::field::Empty, ) skip(self, request) )] async fn get( &self, request: tonic::Request<RefundServiceGetRequest>, ) -> Result<tonic::Response<RefundResponse>, tonic::Status> { let service_name = request .extensions() .get::<String>() .cloned() .unwrap_or_else(|| "RefundService".to_string());
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 75, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-372326334623076254_75_30
clm
snippet
// connector-service/backend/grpc-server/src/server/refunds.rs tenant_id = tracing::field::Empty, flow = FlowName::Rsync.to_string(), flow_specific_fields.status = tracing::field::Empty, ) skip(self, request) )] async fn get( &self, request: tonic::Request<RefundServiceGetRequest>, ) -> Result<tonic::Response<RefundResponse>, tonic::Status> { let service_name = request .extensions() .get::<String>() .cloned() .unwrap_or_else(|| "RefundService".to_string()); utils::grpc_logging_wrapper( request, &service_name, self.config.clone(), common_utils::events::FlowName::Rsync, |request_data| async move { self.internal_get(request_data).await }, ) .await } #[tracing::instrument( name = "refunds_transform", fields( name = common_utils::consts::NAME, service_name = tracing::field::Empty,
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 75, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-372326334623076254_75_50
clm
snippet
// connector-service/backend/grpc-server/src/server/refunds.rs tenant_id = tracing::field::Empty, flow = FlowName::Rsync.to_string(), flow_specific_fields.status = tracing::field::Empty, ) skip(self, request) )] async fn get( &self, request: tonic::Request<RefundServiceGetRequest>, ) -> Result<tonic::Response<RefundResponse>, tonic::Status> { let service_name = request .extensions() .get::<String>() .cloned() .unwrap_or_else(|| "RefundService".to_string()); utils::grpc_logging_wrapper( request, &service_name, self.config.clone(), common_utils::events::FlowName::Rsync, |request_data| async move { self.internal_get(request_data).await }, ) .await } #[tracing::instrument( name = "refunds_transform", fields( name = common_utils::consts::NAME, service_name = tracing::field::Empty, service_method = FlowName::IncomingWebhook.to_string(), request_body = tracing::field::Empty, response_body = tracing::field::Empty, error_message = tracing::field::Empty, merchant_id = tracing::field::Empty, gateway = tracing::field::Empty, request_id = tracing::field::Empty, status_code = tracing::field::Empty, message_ = "Golden Log Line (incoming)", response_time = tracing::field::Empty, tenant_id = tracing::field::Empty, flow = FlowName::IncomingWebhook.to_string(), ) )] async fn transform( &self, request: tonic::Request<RefundServiceTransformRequest>, ) -> Result<tonic::Response<RefundServiceTransformResponse>, tonic::Status> { let service_name = request .extensions()
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 75, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-372326334623076254_100_15
clm
snippet
// connector-service/backend/grpc-server/src/server/refunds.rs #[tracing::instrument( name = "refunds_transform", fields( name = common_utils::consts::NAME, service_name = tracing::field::Empty, service_method = FlowName::IncomingWebhook.to_string(), request_body = tracing::field::Empty, response_body = tracing::field::Empty, error_message = tracing::field::Empty, merchant_id = tracing::field::Empty, gateway = tracing::field::Empty, request_id = tracing::field::Empty, status_code = tracing::field::Empty, message_ = "Golden Log Line (incoming)", response_time = tracing::field::Empty,
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 100, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-372326334623076254_100_30
clm
snippet
// connector-service/backend/grpc-server/src/server/refunds.rs #[tracing::instrument( name = "refunds_transform", fields( name = common_utils::consts::NAME, service_name = tracing::field::Empty, service_method = FlowName::IncomingWebhook.to_string(), request_body = tracing::field::Empty, response_body = tracing::field::Empty, error_message = tracing::field::Empty, merchant_id = tracing::field::Empty, gateway = tracing::field::Empty, request_id = tracing::field::Empty, status_code = tracing::field::Empty, message_ = "Golden Log Line (incoming)", response_time = tracing::field::Empty, tenant_id = tracing::field::Empty, flow = FlowName::IncomingWebhook.to_string(), ) )] async fn transform( &self, request: tonic::Request<RefundServiceTransformRequest>, ) -> Result<tonic::Response<RefundServiceTransformResponse>, tonic::Status> { let service_name = request .extensions() .get::<String>() .cloned() .unwrap_or_else(|| "RefundService".to_string()); utils::grpc_logging_wrapper( request,
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 100, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-372326334623076254_100_50
clm
snippet
// connector-service/backend/grpc-server/src/server/refunds.rs #[tracing::instrument( name = "refunds_transform", fields( name = common_utils::consts::NAME, service_name = tracing::field::Empty, service_method = FlowName::IncomingWebhook.to_string(), request_body = tracing::field::Empty, response_body = tracing::field::Empty, error_message = tracing::field::Empty, merchant_id = tracing::field::Empty, gateway = tracing::field::Empty, request_id = tracing::field::Empty, status_code = tracing::field::Empty, message_ = "Golden Log Line (incoming)", response_time = tracing::field::Empty, tenant_id = tracing::field::Empty, flow = FlowName::IncomingWebhook.to_string(), ) )] async fn transform( &self, request: tonic::Request<RefundServiceTransformRequest>, ) -> Result<tonic::Response<RefundServiceTransformResponse>, tonic::Status> { let service_name = request .extensions() .get::<String>() .cloned() .unwrap_or_else(|| "RefundService".to_string()); utils::grpc_logging_wrapper( request, &service_name, self.config.clone(), common_utils::events::FlowName::IncomingWebhook, |request_data| async move { let payload = request_data.payload; let connector = request_data.extracted_metadata.connector; let connector_auth_details = request_data.extracted_metadata.connector_auth_type; let request_details = payload .request_details .map(domain_types::connector_types::RequestDetails::foreign_try_from) .ok_or_else(|| { tonic::Status::invalid_argument("missing request_details in the payload") })? .map_err(|e| e.into_grpc_status())?; let webhook_secrets = payload .webhook_secrets .map(|details| { domain_types::connector_types::ConnectorWebhookSecrets::foreign_try_from(
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 100, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-372326334623076254_125_15
clm
snippet
// connector-service/backend/grpc-server/src/server/refunds.rs .get::<String>() .cloned() .unwrap_or_else(|| "RefundService".to_string()); utils::grpc_logging_wrapper( request, &service_name, self.config.clone(), common_utils::events::FlowName::IncomingWebhook, |request_data| async move { let payload = request_data.payload; let connector = request_data.extracted_metadata.connector; let connector_auth_details = request_data.extracted_metadata.connector_auth_type; let request_details = payload .request_details
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 125, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-372326334623076254_125_30
clm
snippet
// connector-service/backend/grpc-server/src/server/refunds.rs .get::<String>() .cloned() .unwrap_or_else(|| "RefundService".to_string()); utils::grpc_logging_wrapper( request, &service_name, self.config.clone(), common_utils::events::FlowName::IncomingWebhook, |request_data| async move { let payload = request_data.payload; let connector = request_data.extracted_metadata.connector; let connector_auth_details = request_data.extracted_metadata.connector_auth_type; let request_details = payload .request_details .map(domain_types::connector_types::RequestDetails::foreign_try_from) .ok_or_else(|| { tonic::Status::invalid_argument("missing request_details in the payload") })? .map_err(|e| e.into_grpc_status())?; let webhook_secrets = payload .webhook_secrets .map(|details| { domain_types::connector_types::ConnectorWebhookSecrets::foreign_try_from( details, ) .map_err(|e| e.into_grpc_status()) }) .transpose()?;
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 125, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-372326334623076254_125_50
clm
snippet
// connector-service/backend/grpc-server/src/server/refunds.rs .get::<String>() .cloned() .unwrap_or_else(|| "RefundService".to_string()); utils::grpc_logging_wrapper( request, &service_name, self.config.clone(), common_utils::events::FlowName::IncomingWebhook, |request_data| async move { let payload = request_data.payload; let connector = request_data.extracted_metadata.connector; let connector_auth_details = request_data.extracted_metadata.connector_auth_type; let request_details = payload .request_details .map(domain_types::connector_types::RequestDetails::foreign_try_from) .ok_or_else(|| { tonic::Status::invalid_argument("missing request_details in the payload") })? .map_err(|e| e.into_grpc_status())?; let webhook_secrets = payload .webhook_secrets .map(|details| { domain_types::connector_types::ConnectorWebhookSecrets::foreign_try_from( details, ) .map_err(|e| e.into_grpc_status()) }) .transpose()?; // Get connector data let connector_data = ConnectorData::get_connector_by_name(&connector); let source_verified = connector_data .connector .verify_webhook_source( request_details.clone(), webhook_secrets.clone(), Some(connector_auth_details.clone()), ) .switch() .map_err(|e| e.into_grpc_status())?; let content = get_refunds_webhook_content( connector_data, request_details, webhook_secrets, Some(connector_auth_details), )
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 125, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-372326334623076254_150_15
clm
snippet
// connector-service/backend/grpc-server/src/server/refunds.rs details, ) .map_err(|e| e.into_grpc_status()) }) .transpose()?; // Get connector data let connector_data = ConnectorData::get_connector_by_name(&connector); let source_verified = connector_data .connector .verify_webhook_source( request_details.clone(), webhook_secrets.clone(), Some(connector_auth_details.clone()),
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 150, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-372326334623076254_150_30
clm
snippet
// connector-service/backend/grpc-server/src/server/refunds.rs details, ) .map_err(|e| e.into_grpc_status()) }) .transpose()?; // Get connector data let connector_data = ConnectorData::get_connector_by_name(&connector); let source_verified = connector_data .connector .verify_webhook_source( request_details.clone(), webhook_secrets.clone(), Some(connector_auth_details.clone()), ) .switch() .map_err(|e| e.into_grpc_status())?; let content = get_refunds_webhook_content( connector_data, request_details, webhook_secrets, Some(connector_auth_details), ) .await .map_err(|e| e.into_grpc_status())?; let response = RefundServiceTransformResponse { event_type: WebhookEventType::WebhookRefundSuccess.into(),
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 150, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-372326334623076254_150_50
clm
snippet
// connector-service/backend/grpc-server/src/server/refunds.rs details, ) .map_err(|e| e.into_grpc_status()) }) .transpose()?; // Get connector data let connector_data = ConnectorData::get_connector_by_name(&connector); let source_verified = connector_data .connector .verify_webhook_source( request_details.clone(), webhook_secrets.clone(), Some(connector_auth_details.clone()), ) .switch() .map_err(|e| e.into_grpc_status())?; let content = get_refunds_webhook_content( connector_data, request_details, webhook_secrets, Some(connector_auth_details), ) .await .map_err(|e| e.into_grpc_status())?; let response = RefundServiceTransformResponse { event_type: WebhookEventType::WebhookRefundSuccess.into(), content: Some(content), source_verified, response_ref_id: None, }; Ok(tonic::Response::new(response)) }, ) .await } } async fn get_refunds_webhook_content( connector_data: ConnectorData<DefaultPCIHolder>, request_details: domain_types::connector_types::RequestDetails, webhook_secrets: Option<domain_types::connector_types::ConnectorWebhookSecrets>, connector_auth_details: Option<ConnectorAuthType>, ) -> CustomResult<WebhookResponseContent, ApplicationErrorResponse> { let webhook_details = connector_data .connector
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 150, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-372326334623076254_175_15
clm
snippet
// connector-service/backend/grpc-server/src/server/refunds.rs .await .map_err(|e| e.into_grpc_status())?; let response = RefundServiceTransformResponse { event_type: WebhookEventType::WebhookRefundSuccess.into(), content: Some(content), source_verified, response_ref_id: None, }; Ok(tonic::Response::new(response)) }, ) .await }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 175, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-372326334623076254_175_30
clm
snippet
// connector-service/backend/grpc-server/src/server/refunds.rs .await .map_err(|e| e.into_grpc_status())?; let response = RefundServiceTransformResponse { event_type: WebhookEventType::WebhookRefundSuccess.into(), content: Some(content), source_verified, response_ref_id: None, }; Ok(tonic::Response::new(response)) }, ) .await } } async fn get_refunds_webhook_content( connector_data: ConnectorData<DefaultPCIHolder>, request_details: domain_types::connector_types::RequestDetails, webhook_secrets: Option<domain_types::connector_types::ConnectorWebhookSecrets>, connector_auth_details: Option<ConnectorAuthType>, ) -> CustomResult<WebhookResponseContent, ApplicationErrorResponse> { let webhook_details = connector_data .connector .process_refund_webhook(request_details, webhook_secrets, connector_auth_details) .switch()?; // Generate response let response = RefundResponse::foreign_try_from(webhook_details).change_context(
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 175, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-372326334623076254_175_50
clm
snippet
// connector-service/backend/grpc-server/src/server/refunds.rs .await .map_err(|e| e.into_grpc_status())?; let response = RefundServiceTransformResponse { event_type: WebhookEventType::WebhookRefundSuccess.into(), content: Some(content), source_verified, response_ref_id: None, }; Ok(tonic::Response::new(response)) }, ) .await } } async fn get_refunds_webhook_content( connector_data: ConnectorData<DefaultPCIHolder>, request_details: domain_types::connector_types::RequestDetails, webhook_secrets: Option<domain_types::connector_types::ConnectorWebhookSecrets>, connector_auth_details: Option<ConnectorAuthType>, ) -> CustomResult<WebhookResponseContent, ApplicationErrorResponse> { let webhook_details = connector_data .connector .process_refund_webhook(request_details, webhook_secrets, connector_auth_details) .switch()?; // Generate response let response = RefundResponse::foreign_try_from(webhook_details).change_context( ApplicationErrorResponse::InternalServerError(ApiError { sub_code: "RESPONSE_CONSTRUCTION_ERROR".to_string(), error_identifier: 500, error_message: "Error while constructing response".to_string(), error_object: None, }), )?; Ok(WebhookResponseContent { content: Some( grpc_api_types::payments::webhook_response_content::Content::RefundsResponse(response), ), }) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 44, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 175, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-372326334623076254_200_15
clm
snippet
// connector-service/backend/grpc-server/src/server/refunds.rs .process_refund_webhook(request_details, webhook_secrets, connector_auth_details) .switch()?; // Generate response let response = RefundResponse::foreign_try_from(webhook_details).change_context( ApplicationErrorResponse::InternalServerError(ApiError { sub_code: "RESPONSE_CONSTRUCTION_ERROR".to_string(), error_identifier: 500, error_message: "Error while constructing response".to_string(), error_object: None, }), )?; Ok(WebhookResponseContent { content: Some(
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 200, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-372326334623076254_200_30
clm
snippet
// connector-service/backend/grpc-server/src/server/refunds.rs .process_refund_webhook(request_details, webhook_secrets, connector_auth_details) .switch()?; // Generate response let response = RefundResponse::foreign_try_from(webhook_details).change_context( ApplicationErrorResponse::InternalServerError(ApiError { sub_code: "RESPONSE_CONSTRUCTION_ERROR".to_string(), error_identifier: 500, error_message: "Error while constructing response".to_string(), error_object: None, }), )?; Ok(WebhookResponseContent { content: Some( grpc_api_types::payments::webhook_response_content::Content::RefundsResponse(response), ), }) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 19, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 200, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-372326334623076254_200_50
clm
snippet
// connector-service/backend/grpc-server/src/server/refunds.rs .process_refund_webhook(request_details, webhook_secrets, connector_auth_details) .switch()?; // Generate response let response = RefundResponse::foreign_try_from(webhook_details).change_context( ApplicationErrorResponse::InternalServerError(ApiError { sub_code: "RESPONSE_CONSTRUCTION_ERROR".to_string(), error_identifier: 500, error_message: "Error while constructing response".to_string(), error_object: None, }), )?; Ok(WebhookResponseContent { content: Some( grpc_api_types::payments::webhook_response_content::Content::RefundsResponse(response), ), }) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 19, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 200, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8474653292087038763_0_15
clm
snippet
// connector-service/backend/grpc-server/src/server/payments.rs use std::{collections::HashMap, fmt::Debug, sync::Arc}; use common_enums; use common_utils::{ errors::CustomResult, events::FlowName, lineage, metadata::MaskedMetadata, SecretSerdeValue, }; use connector_integration::types::ConnectorData; use domain_types::{ connector_flow::{ Authenticate, Authorize, Capture, CreateAccessToken, CreateConnectorCustomer, CreateOrder, CreateSessionToken, PSync, PaymentMethodToken, PostAuthenticate, PreAuthenticate, Refund, RepeatPayment, SetupMandate, Void, VoidPC, }, connector_types::{ AccessTokenRequestData, AccessTokenResponseData, ConnectorCustomerData,
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8474653292087038763_0_30
clm
snippet
// connector-service/backend/grpc-server/src/server/payments.rs use std::{collections::HashMap, fmt::Debug, sync::Arc}; use common_enums; use common_utils::{ errors::CustomResult, events::FlowName, lineage, metadata::MaskedMetadata, SecretSerdeValue, }; use connector_integration::types::ConnectorData; use domain_types::{ connector_flow::{ Authenticate, Authorize, Capture, CreateAccessToken, CreateConnectorCustomer, CreateOrder, CreateSessionToken, PSync, PaymentMethodToken, PostAuthenticate, PreAuthenticate, Refund, RepeatPayment, SetupMandate, Void, VoidPC, }, connector_types::{ AccessTokenRequestData, AccessTokenResponseData, ConnectorCustomerData, ConnectorCustomerResponse, ConnectorResponseHeaders, PaymentCreateOrderData, PaymentCreateOrderResponse, PaymentFlowData, PaymentMethodTokenResponse, PaymentMethodTokenizationData, PaymentVoidData, PaymentsAuthenticateData, PaymentsAuthorizeData, PaymentsCancelPostCaptureData, PaymentsCaptureData, PaymentsPostAuthenticateData, PaymentsPreAuthenticateData, PaymentsResponseData, PaymentsSyncData, RawConnectorRequestResponse, RefundFlowData, RefundsData, RefundsResponseData, RepeatPaymentData, SessionTokenRequestData, SessionTokenResponseData, SetupMandateRequestData, }, errors::{ApiError, ApplicationErrorResponse}, payment_method_data::{DefaultPCIHolder, PaymentMethodDataTypes, VaultTokenHolder}, router_data::{ConnectorAuthType, ErrorResponse}, router_data_v2::RouterDataV2, router_response_types, types::{
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8474653292087038763_0_50
clm
snippet
// connector-service/backend/grpc-server/src/server/payments.rs use std::{collections::HashMap, fmt::Debug, sync::Arc}; use common_enums; use common_utils::{ errors::CustomResult, events::FlowName, lineage, metadata::MaskedMetadata, SecretSerdeValue, }; use connector_integration::types::ConnectorData; use domain_types::{ connector_flow::{ Authenticate, Authorize, Capture, CreateAccessToken, CreateConnectorCustomer, CreateOrder, CreateSessionToken, PSync, PaymentMethodToken, PostAuthenticate, PreAuthenticate, Refund, RepeatPayment, SetupMandate, Void, VoidPC, }, connector_types::{ AccessTokenRequestData, AccessTokenResponseData, ConnectorCustomerData, ConnectorCustomerResponse, ConnectorResponseHeaders, PaymentCreateOrderData, PaymentCreateOrderResponse, PaymentFlowData, PaymentMethodTokenResponse, PaymentMethodTokenizationData, PaymentVoidData, PaymentsAuthenticateData, PaymentsAuthorizeData, PaymentsCancelPostCaptureData, PaymentsCaptureData, PaymentsPostAuthenticateData, PaymentsPreAuthenticateData, PaymentsResponseData, PaymentsSyncData, RawConnectorRequestResponse, RefundFlowData, RefundsData, RefundsResponseData, RepeatPaymentData, SessionTokenRequestData, SessionTokenResponseData, SetupMandateRequestData, }, errors::{ApiError, ApplicationErrorResponse}, payment_method_data::{DefaultPCIHolder, PaymentMethodDataTypes, VaultTokenHolder}, router_data::{ConnectorAuthType, ErrorResponse}, router_data_v2::RouterDataV2, router_response_types, types::{ generate_payment_capture_response, generate_payment_sync_response, generate_payment_void_post_capture_response, generate_payment_void_response, generate_refund_response, generate_repeat_payment_response, generate_setup_mandate_response, }, utils::{ForeignFrom, ForeignTryFrom}, }; use error_stack::ResultExt; use external_services::service::EventProcessingParams; use grpc_api_types::payments::{ payment_method, payment_service_server::PaymentService, DisputeResponse, PaymentServiceAuthenticateRequest, PaymentServiceAuthenticateResponse, PaymentServiceAuthorizeRequest, PaymentServiceAuthorizeResponse, PaymentServiceCaptureRequest, PaymentServiceCaptureResponse, PaymentServiceDisputeRequest, PaymentServiceGetRequest, PaymentServiceGetResponse, PaymentServicePostAuthenticateRequest, PaymentServicePostAuthenticateResponse, PaymentServicePreAuthenticateRequest, PaymentServicePreAuthenticateResponse, PaymentServiceRefundRequest, PaymentServiceRegisterRequest, PaymentServiceRegisterResponse, PaymentServiceRepeatEverythingRequest, PaymentServiceRepeatEverythingResponse, PaymentServiceTransformRequest, PaymentServiceTransformResponse,
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8474653292087038763_25_15
clm
snippet
// connector-service/backend/grpc-server/src/server/payments.rs payment_method_data::{DefaultPCIHolder, PaymentMethodDataTypes, VaultTokenHolder}, router_data::{ConnectorAuthType, ErrorResponse}, router_data_v2::RouterDataV2, router_response_types, types::{ generate_payment_capture_response, generate_payment_sync_response, generate_payment_void_post_capture_response, generate_payment_void_response, generate_refund_response, generate_repeat_payment_response, generate_setup_mandate_response, }, utils::{ForeignFrom, ForeignTryFrom}, }; use error_stack::ResultExt; use external_services::service::EventProcessingParams; use grpc_api_types::payments::{
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 25, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8474653292087038763_25_30
clm
snippet
// connector-service/backend/grpc-server/src/server/payments.rs payment_method_data::{DefaultPCIHolder, PaymentMethodDataTypes, VaultTokenHolder}, router_data::{ConnectorAuthType, ErrorResponse}, router_data_v2::RouterDataV2, router_response_types, types::{ generate_payment_capture_response, generate_payment_sync_response, generate_payment_void_post_capture_response, generate_payment_void_response, generate_refund_response, generate_repeat_payment_response, generate_setup_mandate_response, }, utils::{ForeignFrom, ForeignTryFrom}, }; use error_stack::ResultExt; use external_services::service::EventProcessingParams; use grpc_api_types::payments::{ payment_method, payment_service_server::PaymentService, DisputeResponse, PaymentServiceAuthenticateRequest, PaymentServiceAuthenticateResponse, PaymentServiceAuthorizeRequest, PaymentServiceAuthorizeResponse, PaymentServiceCaptureRequest, PaymentServiceCaptureResponse, PaymentServiceDisputeRequest, PaymentServiceGetRequest, PaymentServiceGetResponse, PaymentServicePostAuthenticateRequest, PaymentServicePostAuthenticateResponse, PaymentServicePreAuthenticateRequest, PaymentServicePreAuthenticateResponse, PaymentServiceRefundRequest, PaymentServiceRegisterRequest, PaymentServiceRegisterResponse, PaymentServiceRepeatEverythingRequest, PaymentServiceRepeatEverythingResponse, PaymentServiceTransformRequest, PaymentServiceTransformResponse, PaymentServiceVoidPostCaptureRequest, PaymentServiceVoidPostCaptureResponse, PaymentServiceVoidRequest, PaymentServiceVoidResponse, RefundResponse, WebhookTransformationStatus, }; use hyperswitch_masking::ExposeInterface;
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 25, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8474653292087038763_25_50
clm
snippet
// connector-service/backend/grpc-server/src/server/payments.rs payment_method_data::{DefaultPCIHolder, PaymentMethodDataTypes, VaultTokenHolder}, router_data::{ConnectorAuthType, ErrorResponse}, router_data_v2::RouterDataV2, router_response_types, types::{ generate_payment_capture_response, generate_payment_sync_response, generate_payment_void_post_capture_response, generate_payment_void_response, generate_refund_response, generate_repeat_payment_response, generate_setup_mandate_response, }, utils::{ForeignFrom, ForeignTryFrom}, }; use error_stack::ResultExt; use external_services::service::EventProcessingParams; use grpc_api_types::payments::{ payment_method, payment_service_server::PaymentService, DisputeResponse, PaymentServiceAuthenticateRequest, PaymentServiceAuthenticateResponse, PaymentServiceAuthorizeRequest, PaymentServiceAuthorizeResponse, PaymentServiceCaptureRequest, PaymentServiceCaptureResponse, PaymentServiceDisputeRequest, PaymentServiceGetRequest, PaymentServiceGetResponse, PaymentServicePostAuthenticateRequest, PaymentServicePostAuthenticateResponse, PaymentServicePreAuthenticateRequest, PaymentServicePreAuthenticateResponse, PaymentServiceRefundRequest, PaymentServiceRegisterRequest, PaymentServiceRegisterResponse, PaymentServiceRepeatEverythingRequest, PaymentServiceRepeatEverythingResponse, PaymentServiceTransformRequest, PaymentServiceTransformResponse, PaymentServiceVoidPostCaptureRequest, PaymentServiceVoidPostCaptureResponse, PaymentServiceVoidRequest, PaymentServiceVoidResponse, RefundResponse, WebhookTransformationStatus, }; use hyperswitch_masking::ExposeInterface; use injector::{TokenData, VaultConnectors}; use interfaces::connector_integration_v2::BoxedConnectorIntegrationV2; use tracing::info; use crate::{ configs::Config, error::{IntoGrpcStatus, PaymentAuthorizationError, ReportSwitchExt, ResultExtGrpc}, implement_connector_operation, request::RequestData, utils::{self, grpc_logging_wrapper}, }; #[derive(Debug, Clone)] struct EventParams<'a> { _connector_name: &'a str, _service_name: &'a str, request_id: &'a str, lineage_ids: &'a lineage::LineageIds<'a>, reference_id: &'a Option<String>, shadow_mode: bool,
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 25, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8474653292087038763_50_15
clm
snippet
// connector-service/backend/grpc-server/src/server/payments.rs PaymentServiceVoidPostCaptureRequest, PaymentServiceVoidPostCaptureResponse, PaymentServiceVoidRequest, PaymentServiceVoidResponse, RefundResponse, WebhookTransformationStatus, }; use hyperswitch_masking::ExposeInterface; use injector::{TokenData, VaultConnectors}; use interfaces::connector_integration_v2::BoxedConnectorIntegrationV2; use tracing::info; use crate::{ configs::Config, error::{IntoGrpcStatus, PaymentAuthorizationError, ReportSwitchExt, ResultExtGrpc}, implement_connector_operation, request::RequestData, utils::{self, grpc_logging_wrapper},
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 50, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8474653292087038763_50_30
clm
snippet
// connector-service/backend/grpc-server/src/server/payments.rs PaymentServiceVoidPostCaptureRequest, PaymentServiceVoidPostCaptureResponse, PaymentServiceVoidRequest, PaymentServiceVoidResponse, RefundResponse, WebhookTransformationStatus, }; use hyperswitch_masking::ExposeInterface; use injector::{TokenData, VaultConnectors}; use interfaces::connector_integration_v2::BoxedConnectorIntegrationV2; use tracing::info; use crate::{ configs::Config, error::{IntoGrpcStatus, PaymentAuthorizationError, ReportSwitchExt, ResultExtGrpc}, implement_connector_operation, request::RequestData, utils::{self, grpc_logging_wrapper}, }; #[derive(Debug, Clone)] struct EventParams<'a> { _connector_name: &'a str, _service_name: &'a str, request_id: &'a str, lineage_ids: &'a lineage::LineageIds<'a>, reference_id: &'a Option<String>, shadow_mode: bool, } /// Helper function for converting CardDetails to TokenData with structured types #[derive(Debug, serde::Serialize)] struct CardTokenData {
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 50, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8474653292087038763_50_50
clm
snippet
// connector-service/backend/grpc-server/src/server/payments.rs PaymentServiceVoidPostCaptureRequest, PaymentServiceVoidPostCaptureResponse, PaymentServiceVoidRequest, PaymentServiceVoidResponse, RefundResponse, WebhookTransformationStatus, }; use hyperswitch_masking::ExposeInterface; use injector::{TokenData, VaultConnectors}; use interfaces::connector_integration_v2::BoxedConnectorIntegrationV2; use tracing::info; use crate::{ configs::Config, error::{IntoGrpcStatus, PaymentAuthorizationError, ReportSwitchExt, ResultExtGrpc}, implement_connector_operation, request::RequestData, utils::{self, grpc_logging_wrapper}, }; #[derive(Debug, Clone)] struct EventParams<'a> { _connector_name: &'a str, _service_name: &'a str, request_id: &'a str, lineage_ids: &'a lineage::LineageIds<'a>, reference_id: &'a Option<String>, shadow_mode: bool, } /// Helper function for converting CardDetails to TokenData with structured types #[derive(Debug, serde::Serialize)] struct CardTokenData { card_number: String, cvv: String, exp_month: String, exp_year: String, } trait ToTokenData { fn to_token_data(&self) -> TokenData; fn to_token_data_with_vault(&self, vault_connector: VaultConnectors) -> TokenData; } impl ToTokenData for grpc_api_types::payments::CardDetails { fn to_token_data(&self) -> TokenData { self.to_token_data_with_vault(VaultConnectors::VGS) } fn to_token_data_with_vault(&self, vault_connector: VaultConnectors) -> TokenData { let card_data = CardTokenData { card_number: self .card_number
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 50, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8474653292087038763_75_15
clm
snippet
// connector-service/backend/grpc-server/src/server/payments.rs } /// Helper function for converting CardDetails to TokenData with structured types #[derive(Debug, serde::Serialize)] struct CardTokenData { card_number: String, cvv: String, exp_month: String, exp_year: String, } trait ToTokenData { fn to_token_data(&self) -> TokenData; fn to_token_data_with_vault(&self, vault_connector: VaultConnectors) -> TokenData; }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 75, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8474653292087038763_75_30
clm
snippet
// connector-service/backend/grpc-server/src/server/payments.rs } /// Helper function for converting CardDetails to TokenData with structured types #[derive(Debug, serde::Serialize)] struct CardTokenData { card_number: String, cvv: String, exp_month: String, exp_year: String, } trait ToTokenData { fn to_token_data(&self) -> TokenData; fn to_token_data_with_vault(&self, vault_connector: VaultConnectors) -> TokenData; } impl ToTokenData for grpc_api_types::payments::CardDetails { fn to_token_data(&self) -> TokenData { self.to_token_data_with_vault(VaultConnectors::VGS) } fn to_token_data_with_vault(&self, vault_connector: VaultConnectors) -> TokenData { let card_data = CardTokenData { card_number: self .card_number .as_ref() .map(|cn| cn.to_string()) .unwrap_or_default(), cvv: self .card_cvc
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 75, "struct_name": null, "total_crates": null, "trait_name": null }