Skip to content

Instantly share code, notes, and snippets.

@jwilm
Created February 10, 2022 23:07
Show Gist options
  • Save jwilm/a6144959268a55e3b35326fe4be26100 to your computer and use it in GitHub Desktop.
Save jwilm/a6144959268a55e3b35326fe4be26100 to your computer and use it in GitHub Desktop.
Detecting large refinery events
diff --git a/route/route.go b/route/route.go
index d0f7ee8..0a92708 100644
--- a/route/route.go
+++ b/route/route.go
@@ -396,6 +396,29 @@ func (r *Router) processEvent(ev *types.Event, reqID interface{}) error {
WithField("request_id", reqID).
WithString("api_host", ev.APIHost).
WithString("dataset", ev.Dataset)
+ var err error
+
+ jsonString, err := json.Marshal(ev.Data)
+ if err == nil {
+ dataSizeBytes := len(jsonString)
+ // Log some data about large events so that we can diagnose where they
+ // are coming from.
+ if dataSizeBytes > 50000 {
+ log := r.iopLogger.Error()
+ var serviceName string
+ var spanName string
+
+ if svcName, ok := ev.Data["service.name"]; ok {
+ serviceName = svcName.(string)
+ }
+ if spnName, ok := ev.Data["name"]; ok {
+ spanName = spnName.(string)
+ }
+ log.WithString("service_name", serviceName).
+ WithString("span_name", spanName).
+ Logf("large event detected")
+ }
+ }
// extract trace ID, route to self or peer, pass on to collector
// TODO make trace ID field configurable
@@ -432,7 +455,6 @@ func (r *Router) processEvent(ev *types.Event, reqID interface{}) error {
}
// we're supposed to handle it
- var err error
span := &types.Span{
Event: *ev,
TraceID: traceID,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment