Comments (4)
There's not out of the box. It might be a good option. That said, you could fairly easily create a custom formatter:
require 'gruf'
class MyCustomFormatter < Gruf::Interceptors::Instrumentation::RequestLogging::Formatters::Base
def format(payload)
# do custom payload things here
payload.merge!(format: 'json')
payload.to_json
end
end
Gruf.configure do |c|
c.interceptors.use(
Gruf::Interceptors::Instrumentation::RequestLogging::Interceptor,
formatter: MyCustomFormatter
)
end
from gruf.
There's not out of the box. It might be a good option. That said, you could fairly easily create a custom formatter:
require 'gruf' class MyCustomFormatter < Gruf::Interceptors::Instrumentation::RequestLogging::Formatters::Base def format(payload) # do custom payload things here payload.merge!(format: 'json') payload.to_json end end Gruf.configure do |c| c.interceptors.use( Gruf::Interceptors::Instrumentation::RequestLogging::Interceptor, formatter: MyCustomFormatter ) end
Thanks for the quick response. Though in my use case, I actually need to insert data from the response/result instead of simple static values.
A good example of what Iām looking for is the custom_payload
option for lograge:
Rails.application.configure do
config.lograge.enabled = true
config.lograge.custom_payload do |controller|
{
host: controller.request.host,
user_id: controller.current_user.try(:id)
}
end
end
from gruf.
Got it. There's a couple of ways we could solve this:
- Create another configuration option that allows a block to be passed.
- Pass the request object into formatters to allow them access.
I think i'd prefer the latter, as that doesn't introduce a new abstraction layer or configuration element, and allows custom formatters more flexibility and options when dealing with data. Thoughts?
from gruf.
Got it. There's a couple of ways we could solve this:
- Create another configuration option that allows a block to be passed.
- Pass the request object into formatters to allow them access.
I think i'd prefer the latter, as that doesn't introduce a new abstraction layer or configuration element, and allows custom formatters more flexibility and options when dealing with data. Thoughts?
I agree the latter is a better approach. It'd be weird to have gruf config options that are specific to an optional interceptor. Thanks for the quick response and getting this into PR.
from gruf.
Related Issues (20)
- StatsD to emit gRPC codes HOT 2
- Theoretical limit on number of bi directional connections HOT 3
- [Proposal] Replace ConnectionReset to Rails executor HOT 4
- GRPC::ActiveCall could not obtain a connection from the pool HOT 8
- Wrong interceptor execution order HOT 3
- Modified metadata not being passed on server-side streaming RPC HOT 2
- Gruf 2.13 seems to fail to allow connections HOT 6
- Gruf 2.13 with gRPC 1.42 causes an error and prevents RSpec from shutting down HOT 2
- Please release 2.13.2 HOT 4
- Next step in `Server:-Creating-Controllers.md` not linked HOT 1
- Starting Gruf and bind with specific controllers HOT 4
- After Zeitwerk upgrade, specs don't autoload controller names HOT 7
- Request context for interceptors to communicate information back to controllers HOT 2
- 2.16 appears to autoload the HealthCheck even if not enabled HOT 1
- Minor typo in wiki, recommended fix :) HOT 1
- Gruf.controllers_path unloaded even in client mode HOT 2
- Question: is hot code reloading for other paths possible? HOT 1
- healthcheck cannot be seperated of main thread limit HOT 1
- Autoloading in development is not thread-safe HOT 3
- enabling TLS default
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ššš
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gruf.