Serialize payload in "handle message" span
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
f4e5cb14bf
commit
003bbe9aab
3 changed files with 7 additions and 2 deletions
|
@ -156,7 +156,10 @@ impl Server {
|
||||||
let envelope = envelope.into_any().downcast::<TypedEnvelope<M>>().unwrap();
|
let envelope = envelope.into_any().downcast::<TypedEnvelope<M>>().unwrap();
|
||||||
let span = info_span!(
|
let span = info_span!(
|
||||||
"handle message",
|
"handle message",
|
||||||
payload_type = envelope.payload_type_name()
|
payload_type = envelope.payload_type_name(),
|
||||||
|
payload = serde_json::to_string_pretty(&envelope.payload)
|
||||||
|
.unwrap()
|
||||||
|
.as_str(),
|
||||||
);
|
);
|
||||||
let future = (handler)(server, *envelope);
|
let future = (handler)(server, *envelope);
|
||||||
async move {
|
async move {
|
||||||
|
|
|
@ -2,6 +2,7 @@ fn main() {
|
||||||
let mut build = prost_build::Config::new();
|
let mut build = prost_build::Config::new();
|
||||||
// build.protoc_arg("--experimental_allow_proto3_optional");
|
// build.protoc_arg("--experimental_allow_proto3_optional");
|
||||||
build
|
build
|
||||||
|
.type_attribute(".", "#[derive(serde::Serialize)]")
|
||||||
.compile_protos(&["proto/zed.proto"], &["proto"])
|
.compile_protos(&["proto/zed.proto"], &["proto"])
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ use anyhow::{anyhow, Result};
|
||||||
use async_tungstenite::tungstenite::Message as WebSocketMessage;
|
use async_tungstenite::tungstenite::Message as WebSocketMessage;
|
||||||
use futures::{SinkExt as _, StreamExt as _};
|
use futures::{SinkExt as _, StreamExt as _};
|
||||||
use prost::Message as _;
|
use prost::Message as _;
|
||||||
|
use serde::Serialize;
|
||||||
use std::any::{Any, TypeId};
|
use std::any::{Any, TypeId};
|
||||||
use std::{
|
use std::{
|
||||||
io,
|
io,
|
||||||
|
@ -11,7 +12,7 @@ use std::{
|
||||||
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/zed.messages.rs"));
|
include!(concat!(env!("OUT_DIR"), "/zed.messages.rs"));
|
||||||
|
|
||||||
pub trait EnvelopedMessage: Clone + Sized + Send + Sync + 'static {
|
pub trait EnvelopedMessage: Clone + Serialize + Sized + Send + Sync + 'static {
|
||||||
const NAME: &'static str;
|
const NAME: &'static str;
|
||||||
const PRIORITY: MessagePriority;
|
const PRIORITY: MessagePriority;
|
||||||
fn into_envelope(
|
fn into_envelope(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue