[ 
https://issues.apache.org/jira/browse/GOBBLIN-2053?focusedWorklogId=916261&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-916261
 ]

ASF GitHub Bot logged work on GOBBLIN-2053:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 24/Apr/24 21:40
            Start Date: 24/Apr/24 21:40
    Worklog Time Spent: 10m 
      Work Description: Will-Lo commented on code in PR #3933:
URL: https://github.com/apache/gobblin/pull/3933#discussion_r1578549323


##########
gobblin-metrics-libs/gobblin-metrics/src/test/java/org/apache/gobblin/metrics/OpenTelemetryMetricsTest.java:
##########
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.gobblin.metrics;
+
+import java.util.Map;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import org.apache.gobblin.configuration.ConfigurationKeys;
+import org.apache.gobblin.configuration.State;
+
+
+public class OpenTelemetryMetricsTest  {
+
+  @Test
+  void testInitializeOpenTelemetryFailsWithoutEndpoint() {
+    State opentelemetryState = new State();
+    
opentelemetryState.setProp(ConfigurationKeys.METRICS_REPORTING_OPENTELEMETRY_ENABLED,
 "true");
+    Assert.assertThrows(IllegalArgumentException.class, () -> {
+      OpenTelemetryMetrics.getInstance(opentelemetryState);
+    });
+  }
+
+  @Test
+  void testInitializeOpenTelemetrySucceedsWithEndpoint() {
+    State opentelemetryState = new State();
+    
opentelemetryState.setProp(ConfigurationKeys.METRICS_REPORTING_OPENTELEMETRY_ENABLED,
 "true");
+    
opentelemetryState.setProp(ConfigurationKeys.METRICS_REPORTING_OPENTELEMETRY_ENDPOINT,
 "http://localhost:4317";);
+    OpenTelemetryMetrics metricsProvider = 
OpenTelemetryMetrics.getInstance(opentelemetryState);
+    System.out.println(metricsProvider.metricExporter.toString());
+  }
+
+  @Test
+  void testHeadersParseCorrectly() {
+    Map<String, String> headers = OpenTelemetryMetrics.parseHttpHeaders(
+        
"{\"Content-Type\":\"application/x-protobuf\",\"headerTag\":\"tag1:value1,tag2:value2\"}");
+    Assert.assertEquals(headers.size(), 2);
+    Assert.assertEquals(headers.get("Content-Type"), "application/x-protobuf");
+    Assert.assertEquals(headers.get("headerTag"), "tag1:value1,tag2:value2");

Review Comment:
   We don't check for ordering here, it's expecting the value of this key to be 
exactly the same order as its sent in which it should since it's just a string 
value





Issue Time Tracking
-------------------

    Worklog Id:     (was: 916261)
    Time Spent: 50m  (was: 40m)

> Fix config setup to Opentelemetry metric emitter
> ------------------------------------------------
>
>                 Key: GOBBLIN-2053
>                 URL: https://issues.apache.org/jira/browse/GOBBLIN-2053
>             Project: Apache Gobblin
>          Issue Type: Improvement
>            Reporter: William Lo
>            Priority: Major
>          Time Spent: 50m
>  Remaining Estimate: 0h
>
> Opentelemetry event submitter which is used in GaaS was not propagating 
> certain tags and attributes correctly to connect to external sources.
> We want to do the following:
> 1. Add some logging when the emitter is initialized successfully
> 2. Enforce a URL if it is enabled so that it can emit to an endpoint (not 
> localhost)
> 3. Allow the user to specify headers in JSON format for forwarding metrics to 
> a metrics aggregator (e.g. Fluentbit)



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to