Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add context.HandlerNames() #1729

Merged
merged 8 commits into from
Feb 26, 2019
Merged

Add context.HandlerNames() #1729

merged 8 commits into from
Feb 26, 2019

Conversation

lggomez
Copy link
Contributor

@lggomez lggomez commented Jan 2, 2019

This PR adds a HandlerNames method which returns all registered handles for the context in descending order

lggomez and others added 3 commits January 2, 2019 13:40
This change adds a HandlerNames method that will return all registered handles in the context, in descending order

This is useful for debugging and troubleshooting purposes, especially in large apps
Add tests for HandlerNames
@codecov
Copy link

codecov bot commented Jan 3, 2019

Codecov Report

Merging #1729 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1729      +/-   ##
==========================================
+ Coverage   98.49%   98.49%   +<.01%     
==========================================
  Files          41       41              
  Lines        2054     2059       +5     
==========================================
+ Hits         2023     2028       +5     
  Misses         19       19              
  Partials       12       12
Impacted Files Coverage Δ
context.go 98.32% <100%> (+0.02%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d6adc8d...b03dad7. Read the comment docs.

@thinkerou
Copy link
Member

when use HandlerNames? thanks!

@lggomez
Copy link
Contributor Author

lggomez commented Jan 22, 2019

Hi @thinkerou! at work we have dozens of large services which include both ad-hoc middlewares and base ones which come from an internal framework that dynamicly injects metrics and infrastructure related middlewares upon app initialization

In some cases and during testing, problems may arise due to invalid or wrong configurations on containers that result in different middleware pipelines being applied to those instances. In one specific case, we had an unhandled panic on a goroutine that was bringing down the service, and this helped to discard configuration issues on both the app server and the framework configuration (we've had those in the past) before I moved on to review the affected service implementation

tl;dr: It's useful to dump all the active handlers when diagnosing production issues

Copy link
Member

@thinkerou thinkerou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! LGTM.

@thinkerou thinkerou added this to the 1.4 milestone Feb 23, 2019
@thinkerou thinkerou merged commit 62749f0 into gin-gonic:master Feb 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants