From b87465f0fbd36cfba4af16445901130b49cdc2f8 Mon Sep 17 00:00:00 2001 From: Jeff Klukas Date: Mon, 3 Aug 2020 13:19:41 -0400 Subject: [PATCH] Bug 1655477 Support X-Source-Tags header --- docs/architecture/decoder_service_specification.md | 1 + .../com/mozilla/telemetry/decoder/AddMetadata.java | 3 ++- .../com/mozilla/telemetry/decoder/AddMetadataTest.java | 10 ++++++---- .../com/mozilla/telemetry/ingestion/core/Constant.java | 1 + ingestion-edge/ingestion_edge/config.py | 1 + 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/docs/architecture/decoder_service_specification.md b/docs/architecture/decoder_service_specification.md index b7f2343c6..6029dd73b 100644 --- a/docs/architecture/decoder_service_specification.md +++ b/docs/architecture/decoder_service_specification.md @@ -83,6 +83,7 @@ required group attributes { optional string dnt // header from client optional string x_pingsender_version // header from client optional string x_debug_id // header from client + optional string x_source_tags // header from client optional string user_agent_browser // from user_agent optional string user_agent_browser_version // from user_agent optional string user_agent_os // from user_agent diff --git a/ingestion-beam/src/main/java/com/mozilla/telemetry/decoder/AddMetadata.java b/ingestion-beam/src/main/java/com/mozilla/telemetry/decoder/AddMetadata.java index cb52c92d5..8176f394a 100644 --- a/ingestion-beam/src/main/java/com/mozilla/telemetry/decoder/AddMetadata.java +++ b/ingestion-beam/src/main/java/com/mozilla/telemetry/decoder/AddMetadata.java @@ -42,7 +42,8 @@ public class AddMetadata { private static final String HEADER = "header"; private static final List HEADER_ATTRIBUTES = ImmutableList // - .of(Attribute.DATE, Attribute.DNT, Attribute.X_PINGSENDER_VERSION, Attribute.X_DEBUG_ID); + .of(Attribute.DATE, Attribute.DNT, Attribute.X_PINGSENDER_VERSION, Attribute.X_DEBUG_ID, + Attribute.X_SOURCE_TAGS); private static final List URI_ATTRIBUTES = ImmutableList // .of(Attribute.URI, Attribute.APP_NAME, Attribute.APP_VERSION, Attribute.APP_UPDATE_CHANNEL, diff --git a/ingestion-beam/src/test/java/com/mozilla/telemetry/decoder/AddMetadataTest.java b/ingestion-beam/src/test/java/com/mozilla/telemetry/decoder/AddMetadataTest.java index 39c286099..e47656322 100644 --- a/ingestion-beam/src/test/java/com/mozilla/telemetry/decoder/AddMetadataTest.java +++ b/ingestion-beam/src/test/java/com/mozilla/telemetry/decoder/AddMetadataTest.java @@ -126,18 +126,20 @@ public void testPutUserAgentAttributes() throws Exception { public void testHeadersFromAttributes() throws Exception { Map attributes = ImmutableMap.of("dnt", "1", // "sample_id", "18", // + "x_source_tags", "automation, perf", // "x_debug_id", "mysession"); ObjectNode headers = AddMetadata.headersFromAttributes(attributes); - ObjectNode expected = mapToObjectNode(ImmutableMap.of("dnt", "1", "x_debug_id", "mysession")); + ObjectNode expected = mapToObjectNode(ImmutableMap.of("dnt", "1", "x_debug_id", "mysession", + "x_source_tags", "automation, perf")); assertEquals(expected, headers); } @Test public void testPutHeaderAttributes() throws Exception { - ObjectNode metadata = mapToObjectNode( - ImmutableMap.of("header", ImmutableMap.of("dnt", "1", "x_debug_id", "mysession"))); + ObjectNode metadata = mapToObjectNode(ImmutableMap.of("header", ImmutableMap.of("dnt", "1", + "x_debug_id", "mysession", "x_source_tags", "automation, perf"))); Map expected = ImmutableMap.of("dnt", "1", // - "x_debug_id", "mysession"); + "x_debug_id", "mysession", "x_source_tags", "automation, perf"); Map attributes = new HashMap<>(); AddMetadata.putHeaderAttributes(attributes, (metadata)); assertEquals(expected, attributes); diff --git a/ingestion-core/src/main/java/com/mozilla/telemetry/ingestion/core/Constant.java b/ingestion-core/src/main/java/com/mozilla/telemetry/ingestion/core/Constant.java index 3b3a4bcf4..0fc4a3fb3 100644 --- a/ingestion-core/src/main/java/com/mozilla/telemetry/ingestion/core/Constant.java +++ b/ingestion-core/src/main/java/com/mozilla/telemetry/ingestion/core/Constant.java @@ -51,6 +51,7 @@ private Attribute() { public static final String X_FORWARDED_FOR = "x_forwarded_for"; public static final String X_PINGSENDER_VERSION = "x_pingsender_version"; public static final String X_PIPELINE_PROXY = "x_pipeline_proxy"; + public static final String X_SOURCE_TAGS = "x_source_tags"; } public static class FieldName { diff --git a/ingestion-edge/ingestion_edge/config.py b/ingestion-edge/ingestion_edge/config.py index 565107ee9..a34f19606 100644 --- a/ingestion-edge/ingestion_edge/config.py +++ b/ingestion-edge/ingestion_edge/config.py @@ -61,6 +61,7 @@ class Route: "X-Pingsender-Version", "X-Pipeline-Proxy", "X-Debug-ID", + "X-Source-Tags", ] METADATA_HEADERS = {