Skip to content

Commit

Permalink
twitter-server: add scope separator character to metric_metadata resp…
Browse files Browse the repository at this point in the history
…onse

Problem
metric_metadata.json does not return the scope separating character and consequently consumers of the endpoint would have to infer the character from full metric names.

Solution
Expose the scope separating character as a top level "separator_char" field in metrics_metadata.json.

Result
Consumers of the metric_metadata.json endpoint can now determine the scope separating character via the top level field.

JIRA Issues: CSL-10255

Differential Revision: https://phabricator.twitter.biz/D591106
  • Loading branch information
Matt Dannenberg authored and jenkins committed Dec 11, 2020
1 parent 1660132 commit 38a437b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ Note that ``PHAB_ID=#`` and ``RB_ID=#`` correspond to associated messages in com
Unreleased
----------

* Add separator_char field to the top level of the Metrics Metadata endpoint and bump the
endpoints version number to 2.1. ``PHAB_ID=D591106``

20.12.0
-------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.twitter.server.handler

import com.twitter.finagle.Service
import com.twitter.finagle.http.{MediaType, Request, Response, Uri}
import com.twitter.finagle.stats.metadataScopeSeparator
import com.twitter.io.Buf
import com.twitter.server.util.HttpUtils.newResponse
import com.twitter.server.util.{JsonConverter, MetricSchemaSource}
Expand Down Expand Up @@ -95,8 +96,9 @@ class MetricMetadataQueryHandler(source: MetricSchemaSource = new MetricSchemaSo
content = Buf.Utf8(
JsonConverter.writeToString(
Map(
"@version" -> 2.0,
"@version" -> 2.1,
"counters_latched" -> latched,
"separator_char" -> metadataScopeSeparator(),
"metrics" -> metrics
)))
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,9 @@ class MetricMetadataQueryHandlerTest extends FunSuite {
val responseStart =
"""
| {
| "@version" : 2.0,
| "@version" : 2.1,
| "counters_latched" : true,
| "separator_char" : "/",
""".stripMargin
test(testName + " when using latched counters") {
assertJsonResponse(
Expand All @@ -320,8 +321,9 @@ class MetricMetadataQueryHandlerTest extends FunSuite {
val responseStart =
"""
| {
| "@version" : 2.0,
| "@version" : 2.1,
| "counters_latched" : false,
| "separator_char" : "/",
""".stripMargin
test(testName + " when using unlatched counters") {
assertJsonResponse(
Expand Down

0 comments on commit 38a437b

Please sign in to comment.