Skip to content

Commit

Permalink
Add resolveHeaders tag to tchannel endpoint.request metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
herainman committed Oct 31, 2018
1 parent aae3084 commit 1cbe93e
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 27 deletions.
3 changes: 2 additions & 1 deletion runtime/context.go
Expand Up @@ -64,11 +64,12 @@ const (
scopeTagHandler = "handlerid"
scopeTagError = "error"
scopeTagStatus = "status"
scopeTagProtocal = "protocal"
scopeTagProtocol = "protocol"
scopeTagHTTP = "HTTP"
scopeTagTChannel = "TChannel"
scopeTagsTargetService = "targetservice"
scopeTagsTargetEndpoint = "targetendpoint"
scopeTagResolvedHeaders = "resolvedheaders"
)

// WithEndpointField adds the endpoint information in the
Expand Down
6 changes: 3 additions & 3 deletions runtime/router.go
Expand Up @@ -124,7 +124,7 @@ func (endpoint *RouterEndpoint) HandleRequest(
scopeTags := map[string]string{
scopeTagEndpoint: endpoint.EndpointName,
scopeTagHandler: endpoint.HandlerName,
scopeTagProtocal: scopeTagHTTP,
scopeTagProtocol: scopeTagHTTP,
}

headers := map[string]string{}
Expand Down Expand Up @@ -257,7 +257,7 @@ func (router *HTTPRouter) handleNotFound(
scopeTags := map[string]string{
scopeTagEndpoint: router.notFoundEndpoint.EndpointName,
scopeTagHandler: router.notFoundEndpoint.HandlerName,
scopeTagProtocal: scopeTagHTTP,
scopeTagProtocol: scopeTagHTTP,
}

ctx := r.Context()
Expand All @@ -276,7 +276,7 @@ func (router *HTTPRouter) handleMethodNotAllowed(
scopeTags := map[string]string{
scopeTagEndpoint: router.methodNotAllowedEndpoint.EndpointName,
scopeTagHandler: router.methodNotAllowedEndpoint.HandlerName,
scopeTagProtocal: scopeTagHTTP,
scopeTagProtocol: scopeTagHTTP,
}

ctx := r.Context()
Expand Down
7 changes: 5 additions & 2 deletions runtime/tchannel_server.go
Expand Up @@ -189,7 +189,7 @@ func (s *TChannelRouter) Handle(ctx context.Context, call *tchannel.InboundCall)
scopeTagEndpoint: e.EndpointID,
scopeTagHandler: e.HandlerID,
scopeTagEndpointMethod: e.Method,
scopeTagProtocal: scopeTagTChannel,
scopeTagProtocol: scopeTagTChannel,
}

ctx = WithScopeTags(ctx, scopeTags)
Expand Down Expand Up @@ -228,7 +228,8 @@ func (s *TChannelRouter) handle(
return err
}

scopeTags := make(map[string]string)
scopeTags := map[string]string{scopeTagResolvedHeaders: "true"}
c.ctx = WithScopeTags(c.ctx, scopeTags)
c.ctx = WithEndpointRequestHeadersField(c.ctx, c.reqHeaders)
for k, v := range s.extractor.ExtractScopeTags(c.ctx) {
scopeTags[k] = v
Expand Down Expand Up @@ -264,6 +265,8 @@ func (s *TChannelRouter) handle(

func (c *tchannelInboundCall) start() {
c.startTime = time.Now()
scopeTags := map[string]string{scopeTagResolvedHeaders: "false"}
c.ctx = WithScopeTags(c.ctx, scopeTags)
c.endpoint.ContextMetrics.IncCounter(c.ctx, endpointRequest, 1)
}

Expand Down
8 changes: 4 additions & 4 deletions test/endpoints/bar/bar_metrics_test.go
Expand Up @@ -97,7 +97,7 @@ func TestCallMetrics(t *testing.T) {
"deviceversion": "carbon",
"dc": "unknown",
"host": zanzibar.GetHostname(),
"protocal": "HTTP",
"protocol": "HTTP",
}
eStatusTags := map[string]string{
"env": "test",
Expand All @@ -110,7 +110,7 @@ func TestCallMetrics(t *testing.T) {
"deviceversion": "carbon",
"dc": "unknown",
"host": zanzibar.GetHostname(),
"protocal": "HTTP",
"protocol": "HTTP",
}
for _, name := range endpointNames {
key := tally.KeyForPrefixedStringMap(name, endpointTags)
Expand Down Expand Up @@ -152,7 +152,7 @@ func TestCallMetrics(t *testing.T) {
"regionname": "san_francisco",
"device": "ios",
"deviceversion": "carbon",
"protocal": "HTTP",
"protocol": "HTTP",
}
cStatusTags := map[string]string{
"env": "test",
Expand All @@ -167,7 +167,7 @@ func TestCallMetrics(t *testing.T) {
"regionname": "san_francisco",
"device": "ios",
"deviceversion": "carbon",
"protocal": "HTTP",
"protocol": "HTTP",
}

for _, name := range httpClientNames {
Expand Down
6 changes: 3 additions & 3 deletions test/endpoints/baz/baz_metrics_test.go
Expand Up @@ -108,7 +108,7 @@ func TestCallMetrics(t *testing.T) {
"deviceversion": "carbon",
"dc": "unknown",
"host": zanzibar.GetHostname(),
"protocal": "HTTP",
"protocol": "HTTP",
}
statusTags := map[string]string{
"env": "test",
Expand All @@ -121,7 +121,7 @@ func TestCallMetrics(t *testing.T) {
"deviceversion": "carbon",
"dc": "unknown",
"host": zanzibar.GetHostname(),
"protocal": "HTTP",
"protocol": "HTTP",
}
for _, name := range endpointNames {
key := tally.KeyForPrefixedStringMap(name, endpointTags)
Expand Down Expand Up @@ -191,7 +191,7 @@ func TestCallMetrics(t *testing.T) {
"regionname": "san_francisco",
"device": "ios",
"deviceversion": "carbon",
"protocal": "HTTP",
"protocol": "HTTP",
}
for _, name := range clientNames {
key := tally.KeyForPrefixedStringMap(name, clientTags)
Expand Down
25 changes: 13 additions & 12 deletions test/endpoints/tchannel/baz/baz_metrics_test.go
Expand Up @@ -117,17 +117,18 @@ func TestCallMetrics(t *testing.T) {
"endpoint.success",
}
endpointTags := map[string]string{
"env": "test",
"service": "test-gateway",
"endpointmethod": "SimpleService__Call",
"dc": "unknown",
"host": zanzibar.GetHostname(),
"endpointid": "bazTChannel",
"handlerid": "call",
"device": "ios",
"deviceversion": "carbon",
"regionname": "san_francisco",
"protocal": "TChannel",
"env": "test",
"service": "test-gateway",
"endpointmethod": "SimpleService__Call",
"dc": "unknown",
"host": zanzibar.GetHostname(),
"endpointid": "bazTChannel",
"handlerid": "call",
"device": "ios",
"deviceversion": "carbon",
"regionname": "san_francisco",
"protocol": "TChannel",
"resolvedheaders": "true",
}

for _, name := range endpointNames {
Expand Down Expand Up @@ -197,7 +198,7 @@ func TestCallMetrics(t *testing.T) {
"host": zanzibar.GetHostname(),
"endpointid": "bazTChannel",
"handlerid": "call",
"protocal": "TChannel",
"protocol": "TChannel",
}

for _, name := range clientNames {
Expand Down
4 changes: 2 additions & 2 deletions test/health_test.go
Expand Up @@ -143,7 +143,7 @@ func TestHealthMetrics(t *testing.T) {
"deviceversion": "carbon",
"dc": "unknown",
"host": zanzibar.GetHostname(),
"protocal": "HTTP",
"protocol": "HTTP",
}
statusTags := map[string]string{
"env": "test",
Expand All @@ -156,7 +156,7 @@ func TestHealthMetrics(t *testing.T) {
"deviceversion": "carbon",
"dc": "unknown",
"host": zanzibar.GetHostname(),
"protocal": "HTTP",
"protocol": "HTTP",
}
allhostTags := map[string]string{
"env": "test",
Expand Down

0 comments on commit 1cbe93e

Please sign in to comment.