Skip to content

Commit

Permalink
Add default metric tags to the metric scope (#230)
Browse files Browse the repository at this point in the history
  • Loading branch information
vitarb authored Oct 23, 2020
1 parent f0bbf84 commit 8fba045
Show file tree
Hide file tree
Showing 17 changed files with 85 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import io.temporal.api.workflowservice.v1.TerminateWorkflowExecutionRequest;
import io.temporal.internal.common.GrpcRetryer;
import io.temporal.internal.common.SignalWithStartWorkflowExecutionParameters;
import io.temporal.internal.metrics.MetricsTag;
import io.temporal.serviceclient.MetricsTag;
import io.temporal.serviceclient.WorkflowServiceStubs;
import java.util.Map;
import java.util.Optional;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import com.uber.m3.util.ImmutableMap;
import io.temporal.api.common.v1.WorkflowExecution;
import io.temporal.common.converter.DataConverter;
import io.temporal.internal.metrics.MetricsTag;
import io.temporal.serviceclient.MetricsTag;
import io.temporal.serviceclient.WorkflowServiceStubs;
import java.util.Map;
import java.util.Objects;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@
import io.temporal.failure.FailureConverter;
import io.temporal.internal.common.ProtobufTimeUtils;
import io.temporal.internal.common.WorkflowExecutionUtils;
import io.temporal.internal.metrics.MetricsTag;
import io.temporal.internal.metrics.MetricsType;
import io.temporal.internal.worker.LocalActivityWorker;
import io.temporal.internal.worker.SingleWorkerOptions;
import io.temporal.internal.worker.WorkflowExecutionException;
import io.temporal.internal.worker.WorkflowTaskHandler;
import io.temporal.serviceclient.MetricsTag;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.workflow.Functions;
import java.io.PrintWriter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
import io.temporal.failure.TemporalFailure;
import io.temporal.failure.TimeoutFailure;
import io.temporal.internal.common.CheckedExceptionWrapper;
import io.temporal.internal.metrics.MetricsTag;
import io.temporal.internal.metrics.MetricsType;
import io.temporal.internal.replay.FailureWrapperException;
import io.temporal.internal.worker.ActivityTaskHandler;
import io.temporal.serviceclient.MetricsTag;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.testing.SimulatedTimeoutFailure;
import java.lang.reflect.InvocationTargetException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@

package io.temporal.internal.sync;

import static io.temporal.internal.metrics.MetricsTag.NAMESPACE;

import com.google.common.base.Strings;
import com.google.common.reflect.TypeToken;
import com.uber.m3.tally.Scope;
import com.uber.m3.util.ImmutableMap;
import io.temporal.api.common.v1.WorkflowExecution;
import io.temporal.client.ActivityCompletionClient;
import io.temporal.client.BatchRequest;
Expand All @@ -38,6 +35,7 @@
import io.temporal.internal.external.ManualActivityCompletionClientFactory;
import io.temporal.internal.external.ManualActivityCompletionClientFactoryImpl;
import io.temporal.internal.sync.WorkflowInvocationHandler.InvocationType;
import io.temporal.serviceclient.MetricsTag;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.workflow.Functions;
import io.temporal.workflow.QueryMethod;
Expand Down Expand Up @@ -83,7 +81,7 @@ private WorkflowClientInternal(
workflowServiceStubs
.getOptions()
.getMetricsScope()
.tagged(new ImmutableMap.Builder<String, String>(1).put(NAMESPACE, namespace).build());
.tagged(MetricsTag.defaultTags(namespace));
this.genericClient =
new GenericWorkflowClientExternalImpl(
workflowServiceStubs, options.getNamespace(), options.getIdentity(), metricsScope);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
import io.temporal.internal.common.ProtobufTimeUtils;
import io.temporal.internal.common.RpcRetryOptions;
import io.temporal.internal.logging.LoggerTag;
import io.temporal.internal.metrics.MetricsTag;
import io.temporal.internal.metrics.MetricsType;
import io.temporal.internal.replay.FailureWrapperException;
import io.temporal.internal.worker.ActivityTaskHandler.Result;
import io.temporal.serviceclient.MetricsTag;
import io.temporal.serviceclient.WorkflowServiceStubs;
import java.util.HashMap;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
import io.temporal.api.workflowservice.v1.PollActivityTaskQueueResponse;
import io.temporal.common.RetryOptions;
import io.temporal.internal.common.ProtobufTimeUtils;
import io.temporal.internal.metrics.MetricsTag;
import io.temporal.internal.metrics.MetricsType;
import io.temporal.internal.replay.ExecuteLocalActivityParameters;
import io.temporal.serviceclient.MetricsTag;
import io.temporal.workflow.Functions;
import java.time.Duration;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
import io.temporal.internal.common.WorkflowExecutionHistory;
import io.temporal.internal.common.WorkflowExecutionUtils;
import io.temporal.internal.logging.LoggerTag;
import io.temporal.internal.metrics.MetricsTag;
import io.temporal.internal.metrics.MetricsType;
import io.temporal.serviceclient.MetricsTag;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.workflow.Functions;
import java.util.List;
Expand Down
2 changes: 1 addition & 1 deletion temporal-sdk/src/main/java/io/temporal/worker/Worker.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@
import io.temporal.common.converter.DataConverter;
import io.temporal.internal.common.InternalUtils;
import io.temporal.internal.common.WorkflowExecutionHistory;
import io.temporal.internal.metrics.MetricsTag;
import io.temporal.internal.replay.WorkflowExecutorCache;
import io.temporal.internal.sync.SyncActivityWorker;
import io.temporal.internal.sync.SyncWorkflowWorker;
import io.temporal.internal.sync.WorkflowInternal;
import io.temporal.internal.worker.PollerOptions;
import io.temporal.internal.worker.SingleWorkerOptions;
import io.temporal.internal.worker.Suspendable;
import io.temporal.serviceclient.MetricsTag;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.workflow.Functions.Func;
import io.temporal.workflow.WorkflowMethod;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
import io.temporal.client.WorkflowClient;
import io.temporal.common.converter.DataConverter;
import io.temporal.internal.common.InternalUtils;
import io.temporal.internal.metrics.MetricsTag;
import io.temporal.internal.replay.WorkflowExecutorCache;
import io.temporal.internal.worker.PollWorkflowTaskDispatcher;
import io.temporal.internal.worker.Poller;
import io.temporal.internal.worker.PollerOptions;
import io.temporal.internal.worker.WorkflowPollTaskFactory;
import io.temporal.serviceclient.MetricsTag;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
Expand Down Expand Up @@ -106,10 +106,7 @@ private WorkerFactory(WorkflowClient workflowClient, WorkerFactoryOptions factor
.getWorkflowServiceStubs()
.getOptions()
.getMetricsScope()
.tagged(
new ImmutableMap.Builder<String, String>(1)
.put(MetricsTag.NAMESPACE, workflowClient.getOptions().getNamespace())
.build());
.tagged(MetricsTag.defaultTags(workflowClient.getOptions().getNamespace()));

this.cache =
new WorkflowExecutorCache(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@
import io.temporal.api.query.v1.WorkflowQuery;
import io.temporal.api.workflowservice.v1.PollWorkflowTaskQueueResponse;
import io.temporal.common.reporter.TestStatsReporter;
import io.temporal.internal.metrics.MetricsTag;
import io.temporal.internal.metrics.MetricsType;
import io.temporal.internal.testservice.TestWorkflowService;
import io.temporal.internal.worker.SingleWorkerOptions;
import io.temporal.internal.worker.WorkflowExecutionException;
import io.temporal.serviceclient.MetricsTag;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.testUtils.HistoryUtils;
import io.temporal.worker.WorkflowImplementationOptions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
import io.temporal.common.RetryOptions;
import io.temporal.common.converter.DataConverter;
import io.temporal.failure.CanceledFailure;
import io.temporal.internal.metrics.MetricsTag;
import io.temporal.internal.metrics.MetricsType;
import io.temporal.internal.replay.ReplayWorkflowContext;
import io.temporal.internal.replay.WorkflowExecutorCache;
import io.temporal.internal.replay.WorkflowRunTaskHandler;
import io.temporal.internal.replay.WorkflowTaskResult;
import io.temporal.serviceclient.MetricsTag;
import io.temporal.testUtils.HistoryUtils;
import io.temporal.workflow.Async;
import io.temporal.workflow.CancellationScope;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
import io.temporal.client.WorkflowClientOptions;
import io.temporal.client.WorkflowOptions;
import io.temporal.common.reporter.TestStatsReporter;
import io.temporal.internal.metrics.MetricsTag;
import io.temporal.internal.metrics.MetricsType;
import io.temporal.internal.replay.WorkflowExecutorCache;
import io.temporal.serviceclient.MetricsTag;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.serviceclient.WorkflowServiceStubsOptions;
import io.temporal.testing.TestEnvironmentOptions;
Expand Down Expand Up @@ -158,8 +158,8 @@ public void whenStickyIsEnabledThenTheWorkflowIsCachedSignals() throws Exception

// Verify the workflow succeeded without having to recover from a failure
Map<String, String> tags =
new ImmutableMap.Builder<String, String>(2)
.put(MetricsTag.NAMESPACE, NAMESPACE)
new ImmutableMap.Builder<String, String>(9)
.putAll(MetricsTag.defaultTags(NAMESPACE))
.put(MetricsTag.TASK_QUEUE, taskQueueName)
.put(MetricsTag.WORKFLOW_TYPE, "GreetingSignalWorkflow")
.build();
Expand Down Expand Up @@ -258,8 +258,8 @@ public void whenStickyIsEnabledThenTheWorkflowIsCachedActivities() throws Except

// Verify the workflow succeeded without having to recover from a failure
Map<String, String> tags =
new ImmutableMap.Builder<String, String>(2)
.put(MetricsTag.NAMESPACE, NAMESPACE)
new ImmutableMap.Builder<String, String>(9)
.putAll(MetricsTag.defaultTags(NAMESPACE))
.put(MetricsTag.TASK_QUEUE, taskQueueName)
.put(MetricsTag.WORKFLOW_TYPE, "ActivitiesWorkflow")
.build();
Expand Down Expand Up @@ -299,8 +299,8 @@ public void whenStickyIsEnabledThenTheWorkflowIsCachedChildWorkflows() throws Ex

// Verify the workflow succeeded without having to recover from a failure
Map<String, String> tags =
new ImmutableMap.Builder<String, String>(2)
.put(MetricsTag.NAMESPACE, NAMESPACE)
new ImmutableMap.Builder<String, String>(9)
.putAll(MetricsTag.defaultTags(NAMESPACE))
.put(MetricsTag.TASK_QUEUE, taskQueueName)
.put(MetricsTag.WORKFLOW_TYPE, "GreetingParentWorkflow")
.build();
Expand Down Expand Up @@ -348,8 +348,8 @@ public void whenStickyIsEnabledThenTheWorkflowIsCachedMutableSideEffect() throws

// Verify the workflow succeeded without having to recover from a failure
Map<String, String> tags =
new ImmutableMap.Builder<String, String>(2)
.put(MetricsTag.NAMESPACE, NAMESPACE)
new ImmutableMap.Builder<String, String>(9)
.putAll(MetricsTag.defaultTags(NAMESPACE))
.put(MetricsTag.TASK_QUEUE, taskQueueName)
.put(MetricsTag.WORKFLOW_TYPE, "TestMutableSideEffectWorkflow")
.build();
Expand Down
Loading

0 comments on commit 8fba045

Please sign in to comment.