tasker-engine 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +22 -0
- data/README.md +443 -0
- data/Rakefile +10 -0
- data/app/controllers/tasker/analytics_controller.rb +179 -0
- data/app/controllers/tasker/application_controller.rb +45 -0
- data/app/controllers/tasker/graphql_controller.rb +193 -0
- data/app/controllers/tasker/handlers_controller.rb +217 -0
- data/app/controllers/tasker/health_controller.rb +229 -0
- data/app/controllers/tasker/metrics_controller.rb +111 -0
- data/app/controllers/tasker/page_sort.rb +97 -0
- data/app/controllers/tasker/task_diagrams_controller.rb +30 -0
- data/app/controllers/tasker/tasks_controller.rb +123 -0
- data/app/controllers/tasker/workflow_steps_controller.rb +69 -0
- data/app/graphql/examples/all_tasks.graphql +22 -0
- data/app/graphql/examples/pending_tasks.graphql +23 -0
- data/app/graphql/tasker/graph_ql_types/annotation_type.rb +14 -0
- data/app/graphql/tasker/graph_ql_types/base_argument.rb +9 -0
- data/app/graphql/tasker/graph_ql_types/base_connection.rb +11 -0
- data/app/graphql/tasker/graph_ql_types/base_edge.rb +10 -0
- data/app/graphql/tasker/graph_ql_types/base_enum.rb +9 -0
- data/app/graphql/tasker/graph_ql_types/base_field.rb +10 -0
- data/app/graphql/tasker/graph_ql_types/base_input_object.rb +10 -0
- data/app/graphql/tasker/graph_ql_types/base_interface.rb +14 -0
- data/app/graphql/tasker/graph_ql_types/base_object.rb +10 -0
- data/app/graphql/tasker/graph_ql_types/base_scalar.rb +9 -0
- data/app/graphql/tasker/graph_ql_types/base_union.rb +11 -0
- data/app/graphql/tasker/graph_ql_types/dependent_system_object_map_type.rb +18 -0
- data/app/graphql/tasker/graph_ql_types/dependent_system_type.rb +13 -0
- data/app/graphql/tasker/graph_ql_types/mutation_type.rb +16 -0
- data/app/graphql/tasker/graph_ql_types/named_step_type.rb +16 -0
- data/app/graphql/tasker/graph_ql_types/named_task_type.rb +14 -0
- data/app/graphql/tasker/graph_ql_types/named_tasks_named_step_type.rb +19 -0
- data/app/graphql/tasker/graph_ql_types/node_type.rb +12 -0
- data/app/graphql/tasker/graph_ql_types/query_type.rb +20 -0
- data/app/graphql/tasker/graph_ql_types/task_annotation_type.rb +17 -0
- data/app/graphql/tasker/graph_ql_types/task_interface.rb +17 -0
- data/app/graphql/tasker/graph_ql_types/task_type.rb +26 -0
- data/app/graphql/tasker/graph_ql_types/workflow_step_type.rb +154 -0
- data/app/graphql/tasker/graph_ql_types.rb +42 -0
- data/app/graphql/tasker/mutations/base_mutation.rb +13 -0
- data/app/graphql/tasker/mutations/cancel_step.rb +29 -0
- data/app/graphql/tasker/mutations/cancel_task.rb +29 -0
- data/app/graphql/tasker/mutations/create_task.rb +52 -0
- data/app/graphql/tasker/mutations/update_step.rb +36 -0
- data/app/graphql/tasker/mutations/update_task.rb +41 -0
- data/app/graphql/tasker/queries/all_annotation_types.rb +17 -0
- data/app/graphql/tasker/queries/all_tasks.rb +23 -0
- data/app/graphql/tasker/queries/base_query.rb +9 -0
- data/app/graphql/tasker/queries/helpers.rb +16 -0
- data/app/graphql/tasker/queries/one_step.rb +24 -0
- data/app/graphql/tasker/queries/one_task.rb +18 -0
- data/app/graphql/tasker/queries/tasks_by_annotation.rb +31 -0
- data/app/graphql/tasker/queries/tasks_by_status.rb +30 -0
- data/app/graphql/tasker/tasker_rails_schema.rb +52 -0
- data/app/jobs/tasker/application_job.rb +8 -0
- data/app/jobs/tasker/metrics_export_job.rb +252 -0
- data/app/jobs/tasker/task_runner_job.rb +224 -0
- data/app/models/tasker/annotation_type.rb +26 -0
- data/app/models/tasker/application_record.rb +70 -0
- data/app/models/tasker/dependent_system.rb +26 -0
- data/app/models/tasker/dependent_system_object_map.rb +64 -0
- data/app/models/tasker/diagram/edge.rb +106 -0
- data/app/models/tasker/diagram/flowchart.rb +137 -0
- data/app/models/tasker/diagram/node.rb +99 -0
- data/app/models/tasker/named_step.rb +41 -0
- data/app/models/tasker/named_task.rb +121 -0
- data/app/models/tasker/named_tasks_named_step.rb +82 -0
- data/app/models/tasker/step_dag_relationship.rb +65 -0
- data/app/models/tasker/step_readiness_status.rb +59 -0
- data/app/models/tasker/task.rb +424 -0
- data/app/models/tasker/task_annotation.rb +36 -0
- data/app/models/tasker/task_diagram.rb +332 -0
- data/app/models/tasker/task_execution_context.rb +29 -0
- data/app/models/tasker/task_namespace.rb +41 -0
- data/app/models/tasker/task_transition.rb +235 -0
- data/app/models/tasker/workflow_step.rb +461 -0
- data/app/models/tasker/workflow_step_edge.rb +94 -0
- data/app/models/tasker/workflow_step_transition.rb +434 -0
- data/app/serializers/tasker/annotation_type_serializer.rb +8 -0
- data/app/serializers/tasker/handler_serializer.rb +109 -0
- data/app/serializers/tasker/task_annotation_serializer.rb +32 -0
- data/app/serializers/tasker/task_serializer.rb +168 -0
- data/app/serializers/tasker/workflow_step_serializer.rb +27 -0
- data/app/services/tasker/analytics_service.rb +409 -0
- data/app/views/tasker/task/_diagram.html.erb +32 -0
- data/config/initializers/dry_struct.rb +11 -0
- data/config/initializers/statesman.rb +6 -0
- data/config/initializers/tasker_orchestration.rb +17 -0
- data/config/initializers/time_formats.rb +4 -0
- data/config/routes.rb +34 -0
- data/config/tasker/subscriptions/example_integrations.yml +67 -0
- data/config/tasker/system_events.yml +305 -0
- data/db/functions/calculate_dependency_levels_v01.sql +45 -0
- data/db/functions/get_analytics_metrics_v01.sql +137 -0
- data/db/functions/get_slowest_steps_v01.sql +82 -0
- data/db/functions/get_slowest_tasks_v01.sql +96 -0
- data/db/functions/get_step_readiness_status_batch_v01.sql +140 -0
- data/db/functions/get_step_readiness_status_v01.sql +139 -0
- data/db/functions/get_system_health_counts_v01.sql +108 -0
- data/db/functions/get_task_execution_context_v01.sql +108 -0
- data/db/functions/get_task_execution_contexts_batch_v01.sql +104 -0
- data/db/init/schema.sql +2277 -0
- data/db/migrate/20250701165431_initial_tasker_schema.rb +116 -0
- data/db/views/tasker_step_dag_relationships_v01.sql +69 -0
- data/docs/APPLICATION_GENERATOR.md +384 -0
- data/docs/AUTH.md +1780 -0
- data/docs/CIRCUIT_BREAKER.md +224 -0
- data/docs/DEVELOPER_GUIDE.md +2665 -0
- data/docs/EVENT_SYSTEM.md +637 -0
- data/docs/EXECUTION_CONFIGURATION.md +341 -0
- data/docs/FLOW_CHART.md +149 -0
- data/docs/HEALTH.md +542 -0
- data/docs/METRICS.md +731 -0
- data/docs/OPTIMIZATION_PLAN.md +1479 -0
- data/docs/OVERVIEW.md +552 -0
- data/docs/QUICK_START.md +270 -0
- data/docs/REGISTRY_SYSTEMS.md +373 -0
- data/docs/REST_API.md +632 -0
- data/docs/ROADMAP.md +221 -0
- data/docs/SQL_FUNCTIONS.md +1408 -0
- data/docs/TASK_DIAGRAM.md +252 -0
- data/docs/TASK_EXECUTION_CONTROL_FLOW.md +237 -0
- data/docs/TELEMETRY.md +795 -0
- data/docs/TROUBLESHOOTING.md +756 -0
- data/docs/TaskHandlerGenerator.html +255 -0
- data/docs/Tasker/Analysis/RuntimeGraphAnalyzer.html +907 -0
- data/docs/Tasker/Analysis/TemplateGraphAnalyzer.html +1236 -0
- data/docs/Tasker/Analysis.html +117 -0
- data/docs/Tasker/AnalyticsController.html +450 -0
- data/docs/Tasker/AnalyticsService/BottleneckAnalytics.html +816 -0
- data/docs/Tasker/AnalyticsService/PerformanceAnalytics.html +586 -0
- data/docs/Tasker/AnalyticsService.html +2221 -0
- data/docs/Tasker/AnnotationType.html +137 -0
- data/docs/Tasker/AnnotationTypeSerializer.html +124 -0
- data/docs/Tasker/ApplicationController.html +147 -0
- data/docs/Tasker/ApplicationJob.html +128 -0
- data/docs/Tasker/ApplicationRecord.html +378 -0
- data/docs/Tasker/Authentication/AuthenticationError.html +124 -0
- data/docs/Tasker/Authentication/ConfigurationError.html +124 -0
- data/docs/Tasker/Authentication/Coordinator.html +242 -0
- data/docs/Tasker/Authentication/Interface.html +560 -0
- data/docs/Tasker/Authentication/InterfaceError.html +124 -0
- data/docs/Tasker/Authentication/NoneAuthenticator.html +338 -0
- data/docs/Tasker/Authentication.html +119 -0
- data/docs/Tasker/Authorization/AuthorizationError.html +139 -0
- data/docs/Tasker/Authorization/BaseCoordinator.html +927 -0
- data/docs/Tasker/Authorization/ConfigurationError.html +153 -0
- data/docs/Tasker/Authorization/ResourceConstants/ACTIONS.html +428 -0
- data/docs/Tasker/Authorization/ResourceConstants/RESOURCES.html +365 -0
- data/docs/Tasker/Authorization/ResourceConstants.html +146 -0
- data/docs/Tasker/Authorization/ResourceRegistry.html +882 -0
- data/docs/Tasker/Authorization/UnauthorizedError.html +153 -0
- data/docs/Tasker/Authorization.html +582 -0
- data/docs/Tasker/CacheCapabilities.html +167 -0
- data/docs/Tasker/CacheStrategy.html +1297 -0
- data/docs/Tasker/Concerns/Authenticatable.html +116 -0
- data/docs/Tasker/Concerns/Authorizable/AdminStatusChecker.html +256 -0
- data/docs/Tasker/Concerns/Authorizable.html +816 -0
- data/docs/Tasker/Concerns/ControllerAuthorizable.html +157 -0
- data/docs/Tasker/Concerns/EventPublisher.html +4023 -0
- data/docs/Tasker/Concerns/IdempotentStateTransitions.html +806 -0
- data/docs/Tasker/Concerns/LifecycleEventHelpers.html +129 -0
- data/docs/Tasker/Concerns/OrchestrationPublisher.html +129 -0
- data/docs/Tasker/Concerns/StateMachineBase/ClassMethods.html +1075 -0
- data/docs/Tasker/Concerns/StateMachineBase/StateMachineBase/ClassMethods.html +191 -0
- data/docs/Tasker/Concerns/StateMachineBase/StateMachineBase.html +126 -0
- data/docs/Tasker/Concerns/StateMachineBase.html +153 -0
- data/docs/Tasker/Concerns/StructuredLogging.html +1413 -0
- data/docs/Tasker/Concerns.html +117 -0
- data/docs/Tasker/Configuration/AuthConfiguration.html +1023 -0
- data/docs/Tasker/Configuration/ConfigurationProxy.html +581 -0
- data/docs/Tasker/Configuration/DatabaseConfiguration.html +475 -0
- data/docs/Tasker/Configuration/EngineConfiguration.html +1265 -0
- data/docs/Tasker/Configuration/HealthConfiguration.html +791 -0
- data/docs/Tasker/Configuration/TelemetryConfiguration.html +1308 -0
- data/docs/Tasker/Configuration/TelemetryConfigurationProxy.html +388 -0
- data/docs/Tasker/Configuration.html +1669 -0
- data/docs/Tasker/ConfigurationError.html +143 -0
- data/docs/Tasker/ConfiguredTask.html +514 -0
- data/docs/Tasker/Constants/EventDefinitions.html +590 -0
- data/docs/Tasker/Constants/LifecycleEvents.html +137 -0
- data/docs/Tasker/Constants/ObservabilityEvents/Step.html +152 -0
- data/docs/Tasker/Constants/ObservabilityEvents/Task.html +142 -0
- data/docs/Tasker/Constants/ObservabilityEvents.html +126 -0
- data/docs/Tasker/Constants/RegistryEvents.html +285 -0
- data/docs/Tasker/Constants/StepEvents.html +177 -0
- data/docs/Tasker/Constants/TaskEvents.html +167 -0
- data/docs/Tasker/Constants/TaskExecution/ExecutionStatus.html +207 -0
- data/docs/Tasker/Constants/TaskExecution/HealthStatus.html +191 -0
- data/docs/Tasker/Constants/TaskExecution/RecommendedAction.html +207 -0
- data/docs/Tasker/Constants/TaskExecution.html +126 -0
- data/docs/Tasker/Constants/TaskFinalization/ErrorMessages.html +132 -0
- data/docs/Tasker/Constants/TaskFinalization/PendingReasons.html +207 -0
- data/docs/Tasker/Constants/TaskFinalization/ReenqueueReasons.html +239 -0
- data/docs/Tasker/Constants/TaskFinalization.html +126 -0
- data/docs/Tasker/Constants/TaskStatuses.html +223 -0
- data/docs/Tasker/Constants/TestEvents.html +163 -0
- data/docs/Tasker/Constants/WorkflowEvents.html +222 -0
- data/docs/Tasker/Constants/WorkflowStepStatuses.html +223 -0
- data/docs/Tasker/Constants.html +561 -0
- data/docs/Tasker/DependentSystem.html +137 -0
- data/docs/Tasker/DependentSystemObjectMap.html +250 -0
- data/docs/Tasker/DetectorRegistry.html +598 -0
- data/docs/Tasker/Diagram/Edge.html +1191 -0
- data/docs/Tasker/Diagram/Flowchart.html +1539 -0
- data/docs/Tasker/Diagram/Node.html +1165 -0
- data/docs/Tasker/Diagram.html +117 -0
- data/docs/Tasker/Engine.html +215 -0
- data/docs/Tasker/Error.html +139 -0
- data/docs/Tasker/Events/Bus.html +1226 -0
- data/docs/Tasker/Events/Catalog/CatalogPrinter.html +258 -0
- data/docs/Tasker/Events/Catalog/CustomEventRegistrar.html +276 -0
- data/docs/Tasker/Events/Catalog/ExamplePayloadGenerator.html +294 -0
- data/docs/Tasker/Events/Catalog.html +1291 -0
- data/docs/Tasker/Events/CustomRegistry.html +943 -0
- data/docs/Tasker/Events/DefinitionLoader.html +575 -0
- data/docs/Tasker/Events/EventPayloadBuilder/ErrorInfoExtractor.html +286 -0
- data/docs/Tasker/Events/EventPayloadBuilder/StepPayloadBuilder.html +312 -0
- data/docs/Tasker/Events/EventPayloadBuilder.html +664 -0
- data/docs/Tasker/Events/Publisher.html +365 -0
- data/docs/Tasker/Events/Subscribers/BaseSubscriber/ErrorCategorizer/ErrorTypeClassifier.html +1128 -0
- data/docs/Tasker/Events/Subscribers/BaseSubscriber/ErrorCategorizer.html +270 -0
- data/docs/Tasker/Events/Subscribers/BaseSubscriber/MetricTagsExtractor.html +266 -0
- data/docs/Tasker/Events/Subscribers/BaseSubscriber.html +2556 -0
- data/docs/Tasker/Events/Subscribers/MetricsSubscriber.html +723 -0
- data/docs/Tasker/Events/Subscribers/TelemetrySubscriber.html +2251 -0
- data/docs/Tasker/Events/Subscribers.html +117 -0
- data/docs/Tasker/Events/SubscriptionLoader.html +493 -0
- data/docs/Tasker/Events.html +294 -0
- data/docs/Tasker/EventsGenerator.html +459 -0
- data/docs/Tasker/Functions/FunctionBasedAnalyticsMetrics/AnalyticsMetrics.html +135 -0
- data/docs/Tasker/Functions/FunctionBasedAnalyticsMetrics.html +412 -0
- data/docs/Tasker/Functions/FunctionBasedDependencyLevels.html +598 -0
- data/docs/Tasker/Functions/FunctionBasedSlowestSteps/SlowestStep.html +135 -0
- data/docs/Tasker/Functions/FunctionBasedSlowestSteps.html +453 -0
- data/docs/Tasker/Functions/FunctionBasedSlowestTasks/SlowestTask.html +135 -0
- data/docs/Tasker/Functions/FunctionBasedSlowestTasks.html +453 -0
- data/docs/Tasker/Functions/FunctionBasedStepReadinessStatus.html +1457 -0
- data/docs/Tasker/Functions/FunctionBasedSystemHealthCounts/HealthMetrics.html +135 -0
- data/docs/Tasker/Functions/FunctionBasedSystemHealthCounts.html +370 -0
- data/docs/Tasker/Functions/FunctionBasedTaskExecutionContext.html +1250 -0
- data/docs/Tasker/Functions/FunctionWrapper.html +479 -0
- data/docs/Tasker/Functions.html +117 -0
- data/docs/Tasker/Generators/AuthenticatorGenerator/UsageInstructionsFormatter.html +244 -0
- data/docs/Tasker/Generators/AuthenticatorGenerator.html +373 -0
- data/docs/Tasker/Generators/AuthorizationCoordinatorGenerator.html +430 -0
- data/docs/Tasker/Generators/SubscriberGenerator.html +377 -0
- data/docs/Tasker/Generators/TaskHandlerGenerator.html +263 -0
- data/docs/Tasker/Generators.html +117 -0
- data/docs/Tasker/GraphQLTypes/AnnotationType.html +132 -0
- data/docs/Tasker/GraphQLTypes/BaseArgument.html +124 -0
- data/docs/Tasker/GraphQLTypes/BaseConnection.html +124 -0
- data/docs/Tasker/GraphQLTypes/BaseEdge.html +130 -0
- data/docs/Tasker/GraphQLTypes/BaseEnum.html +124 -0
- data/docs/Tasker/GraphQLTypes/BaseField.html +124 -0
- data/docs/Tasker/GraphQLTypes/BaseInputObject.html +124 -0
- data/docs/Tasker/GraphQLTypes/BaseInterface.html +116 -0
- data/docs/Tasker/GraphQLTypes/BaseObject.html +128 -0
- data/docs/Tasker/GraphQLTypes/BaseScalar.html +124 -0
- data/docs/Tasker/GraphQLTypes/BaseUnion.html +124 -0
- data/docs/Tasker/GraphQLTypes/DependentSystemObjectMapType.html +132 -0
- data/docs/Tasker/GraphQLTypes/DependentSystemType.html +132 -0
- data/docs/Tasker/GraphQLTypes/MutationType.html +132 -0
- data/docs/Tasker/GraphQLTypes/NamedStepType.html +132 -0
- data/docs/Tasker/GraphQLTypes/NamedTaskType.html +132 -0
- data/docs/Tasker/GraphQLTypes/NamedTasksNamedStepType.html +132 -0
- data/docs/Tasker/GraphQLTypes/NodeType.html +118 -0
- data/docs/Tasker/GraphQLTypes/QueryType.html +139 -0
- data/docs/Tasker/GraphQLTypes/TaskAnnotationType.html +132 -0
- data/docs/Tasker/GraphQLTypes/TaskInterface.html +111 -0
- data/docs/Tasker/GraphQLTypes/TaskType.html +201 -0
- data/docs/Tasker/GraphQLTypes/WorkflowStepType.html +694 -0
- data/docs/Tasker/GraphQLTypes.html +130 -0
- data/docs/Tasker/GraphqlController.html +251 -0
- data/docs/Tasker/HandlerFactory.html +1518 -0
- data/docs/Tasker/HandlerSerializer.html +682 -0
- data/docs/Tasker/HandlersController.html +574 -0
- data/docs/Tasker/HashIdentityStrategy.html +278 -0
- data/docs/Tasker/Health/ReadinessChecker.html +712 -0
- data/docs/Tasker/Health/StatusChecker.html +653 -0
- data/docs/Tasker/Health.html +117 -0
- data/docs/Tasker/HealthController.html +523 -0
- data/docs/Tasker/IdentityStrategy.html +276 -0
- data/docs/Tasker/InvalidTaskHandlerConfig.html +135 -0
- data/docs/Tasker/LifecycleEvents/Events/Step.html +162 -0
- data/docs/Tasker/LifecycleEvents/Events/Task.html +162 -0
- data/docs/Tasker/LifecycleEvents/Events.html +204 -0
- data/docs/Tasker/LifecycleEvents/Publisher.html +132 -0
- data/docs/Tasker/LifecycleEvents.html +799 -0
- data/docs/Tasker/Logging/CorrelationIdGenerator.html +688 -0
- data/docs/Tasker/Logging.html +115 -0
- data/docs/Tasker/MetricsController.html +293 -0
- data/docs/Tasker/MetricsExportJob.html +414 -0
- data/docs/Tasker/Mutations/BaseMutation.html +128 -0
- data/docs/Tasker/Mutations/CancelStep.html +219 -0
- data/docs/Tasker/Mutations/CancelTask.html +221 -0
- data/docs/Tasker/Mutations/CreateTask.html +243 -0
- data/docs/Tasker/Mutations/UpdateStep.html +243 -0
- data/docs/Tasker/Mutations/UpdateTask.html +243 -0
- data/docs/Tasker/Mutations.html +117 -0
- data/docs/Tasker/NamedStep.html +216 -0
- data/docs/Tasker/NamedTask.html +910 -0
- data/docs/Tasker/NamedTasksNamedStep.html +435 -0
- data/docs/Tasker/Orchestration/BackoffCalculator.html +404 -0
- data/docs/Tasker/Orchestration/ConnectionBuilder/ConfigValidator.html +258 -0
- data/docs/Tasker/Orchestration/ConnectionBuilder.html +435 -0
- data/docs/Tasker/Orchestration/ConnectionPoolIntelligence.html +513 -0
- data/docs/Tasker/Orchestration/Coordinator.html +641 -0
- data/docs/Tasker/Orchestration/FutureStateAnalyzer.html +1045 -0
- data/docs/Tasker/Orchestration/Orchestrator.html +679 -0
- data/docs/Tasker/Orchestration/PluginIntegration.html +1127 -0
- data/docs/Tasker/Orchestration/ResponseProcessor.html +504 -0
- data/docs/Tasker/Orchestration/RetryHeaderParser.html +304 -0
- data/docs/Tasker/Orchestration/StepExecutor.html +995 -0
- data/docs/Tasker/Orchestration/StepSequenceFactory.html +644 -0
- data/docs/Tasker/Orchestration/TaskFinalizer/BlockageChecker.html +264 -0
- data/docs/Tasker/Orchestration/TaskFinalizer/ContextManager.html +254 -0
- data/docs/Tasker/Orchestration/TaskFinalizer/DelayCalculator.html +556 -0
- data/docs/Tasker/Orchestration/TaskFinalizer/FinalizationDecisionMaker.html +348 -0
- data/docs/Tasker/Orchestration/TaskFinalizer/FinalizationProcessor.html +286 -0
- data/docs/Tasker/Orchestration/TaskFinalizer/ReasonDeterminer.html +432 -0
- data/docs/Tasker/Orchestration/TaskFinalizer/ReenqueueManager.html +296 -0
- data/docs/Tasker/Orchestration/TaskFinalizer/UnclearStateHandler.html +314 -0
- data/docs/Tasker/Orchestration/TaskFinalizer.html +1212 -0
- data/docs/Tasker/Orchestration/TaskInitializer.html +766 -0
- data/docs/Tasker/Orchestration/TaskReenqueuer.html +506 -0
- data/docs/Tasker/Orchestration/ViableStepDiscovery.html +442 -0
- data/docs/Tasker/Orchestration/WorkflowCoordinator.html +510 -0
- data/docs/Tasker/Orchestration.html +130 -0
- data/docs/Tasker/PageSort/PageSortParamsBuilder.html +296 -0
- data/docs/Tasker/PageSort.html +247 -0
- data/docs/Tasker/PermanentError.html +518 -0
- data/docs/Tasker/ProceduralError.html +147 -0
- data/docs/Tasker/Queries/AllAnnotationTypes.html +217 -0
- data/docs/Tasker/Queries/AllTasks.html +221 -0
- data/docs/Tasker/Queries/BaseQuery.html +128 -0
- data/docs/Tasker/Queries/Helpers.html +187 -0
- data/docs/Tasker/Queries/OneStep.html +225 -0
- data/docs/Tasker/Queries/OneTask.html +217 -0
- data/docs/Tasker/Queries/TasksByAnnotation.html +231 -0
- data/docs/Tasker/Queries/TasksByStatus.html +233 -0
- data/docs/Tasker/Queries.html +119 -0
- data/docs/Tasker/Railtie.html +124 -0
- data/docs/Tasker/Registry/BaseRegistry.html +1690 -0
- data/docs/Tasker/Registry/EventPublisher.html +667 -0
- data/docs/Tasker/Registry/InterfaceValidator.html +569 -0
- data/docs/Tasker/Registry/RegistrationError.html +132 -0
- data/docs/Tasker/Registry/RegistryError.html +139 -0
- data/docs/Tasker/Registry/StatisticsCollector.html +841 -0
- data/docs/Tasker/Registry/SubscriberRegistry.html +1504 -0
- data/docs/Tasker/Registry/ValidationError.html +132 -0
- data/docs/Tasker/Registry.html +119 -0
- data/docs/Tasker/RetryableError.html +515 -0
- data/docs/Tasker/StateMachine/Compatibility.html +282 -0
- data/docs/Tasker/StateMachine/InvalidStateTransition.html +135 -0
- data/docs/Tasker/StateMachine/StepStateMachine/StandardizedPayloadBuilder.html +260 -0
- data/docs/Tasker/StateMachine/StepStateMachine.html +2215 -0
- data/docs/Tasker/StateMachine/TaskStateMachine.html +734 -0
- data/docs/Tasker/StateMachine.html +602 -0
- data/docs/Tasker/StepDagRelationship.html +657 -0
- data/docs/Tasker/StepHandler/Api/Config.html +1091 -0
- data/docs/Tasker/StepHandler/Api.html +884 -0
- data/docs/Tasker/StepHandler/AutomaticEventPublishing.html +321 -0
- data/docs/Tasker/StepHandler/Base.html +970 -0
- data/docs/Tasker/StepHandler.html +119 -0
- data/docs/Tasker/StepReadinessStatus.html +836 -0
- data/docs/Tasker/Task.html +2575 -0
- data/docs/Tasker/TaskAnnotation.html +137 -0
- data/docs/Tasker/TaskAnnotationSerializer.html +124 -0
- data/docs/Tasker/TaskBuilder/StepNameValidator.html +264 -0
- data/docs/Tasker/TaskBuilder/StepTemplateDefiner.html +264 -0
- data/docs/Tasker/TaskBuilder.html +764 -0
- data/docs/Tasker/TaskDiagram/StepToStepEdgeBuilder.html +260 -0
- data/docs/Tasker/TaskDiagram/TaskToRootStepEdgeBuilder.html +290 -0
- data/docs/Tasker/TaskDiagram.html +548 -0
- data/docs/Tasker/TaskDiagramsController.html +240 -0
- data/docs/Tasker/TaskExecutionContext.html +469 -0
- data/docs/Tasker/TaskHandler/ClassMethods/StepTemplateDefiner/ClassBasedEventRegistrar.html +238 -0
- data/docs/Tasker/TaskHandler/ClassMethods/StepTemplateDefiner/YamlEventRegistrar.html +254 -0
- data/docs/Tasker/TaskHandler/ClassMethods/StepTemplateDefiner.html +988 -0
- data/docs/Tasker/TaskHandler/ClassMethods.html +357 -0
- data/docs/Tasker/TaskHandler/InstanceMethods.html +1396 -0
- data/docs/Tasker/TaskHandler/StepGroup.html +1748 -0
- data/docs/Tasker/TaskHandler.html +271 -0
- data/docs/Tasker/TaskNamespace.html +312 -0
- data/docs/Tasker/TaskRunnerJob.html +406 -0
- data/docs/Tasker/TaskSerializer.html +474 -0
- data/docs/Tasker/TaskTransition.html +1517 -0
- data/docs/Tasker/TaskWorkflowSummary.html +988 -0
- data/docs/Tasker/TaskerRailsSchema/InvalidObjectTypeError.html +132 -0
- data/docs/Tasker/TaskerRailsSchema/TypeResolutionError.html +139 -0
- data/docs/Tasker/TaskerRailsSchema/UnknownInterfaceError.html +132 -0
- data/docs/Tasker/TaskerRailsSchema.html +384 -0
- data/docs/Tasker/TasksController.html +595 -0
- data/docs/Tasker/Telemetry/EventMapping.html +1307 -0
- data/docs/Tasker/Telemetry/EventRouter.html +2178 -0
- data/docs/Tasker/Telemetry/Events/ExportEvents.html +246 -0
- data/docs/Tasker/Telemetry/Events.html +115 -0
- data/docs/Tasker/Telemetry/ExportCoordinator/DistributedLockTimeoutError.html +135 -0
- data/docs/Tasker/Telemetry/ExportCoordinator.html +2137 -0
- data/docs/Tasker/Telemetry/IntelligentCacheManager.html +1083 -0
- data/docs/Tasker/Telemetry/LogBackend.html +1088 -0
- data/docs/Tasker/Telemetry/MetricTypes/Counter.html +1054 -0
- data/docs/Tasker/Telemetry/MetricTypes/Gauge.html +1270 -0
- data/docs/Tasker/Telemetry/MetricTypes/Histogram.html +1492 -0
- data/docs/Tasker/Telemetry/MetricTypes.html +153 -0
- data/docs/Tasker/Telemetry/MetricsBackend.html +2510 -0
- data/docs/Tasker/Telemetry/MetricsExportService.html +578 -0
- data/docs/Tasker/Telemetry/PluginRegistry.html +1774 -0
- data/docs/Tasker/Telemetry/Plugins/BaseExporter.html +1835 -0
- data/docs/Tasker/Telemetry/Plugins/CsvExporter.html +768 -0
- data/docs/Tasker/Telemetry/Plugins/JsonExporter.html +747 -0
- data/docs/Tasker/Telemetry/Plugins.html +117 -0
- data/docs/Tasker/Telemetry/PrometheusExporter.html +481 -0
- data/docs/Tasker/Telemetry/TraceBackend.html +891 -0
- data/docs/Tasker/Telemetry.html +130 -0
- data/docs/Tasker/Types/AuthConfig.html +886 -0
- data/docs/Tasker/Types/BackoffConfig.html +1063 -0
- data/docs/Tasker/Types/BaseConfig.html +227 -0
- data/docs/Tasker/Types/CacheConfig.html +1731 -0
- data/docs/Tasker/Types/DatabaseConfig.html +388 -0
- data/docs/Tasker/Types/DependencyGraph.html +526 -0
- data/docs/Tasker/Types/DependencyGraphConfig.html +753 -0
- data/docs/Tasker/Types/EngineConfig.html +1181 -0
- data/docs/Tasker/Types/ExecutionConfig.html +1963 -0
- data/docs/Tasker/Types/GraphEdge.html +517 -0
- data/docs/Tasker/Types/GraphMetadata.html +781 -0
- data/docs/Tasker/Types/GraphNode.html +694 -0
- data/docs/Tasker/Types/HealthConfig.html +784 -0
- data/docs/Tasker/Types/StepSequence.html +353 -0
- data/docs/Tasker/Types/StepTemplate.html +1193 -0
- data/docs/Tasker/Types/TaskRequest.html +1179 -0
- data/docs/Tasker/Types/TelemetryConfig.html +2746 -0
- data/docs/Tasker/Types.html +154 -0
- data/docs/Tasker/WorkflowStep/StepFinder.html +282 -0
- data/docs/Tasker/WorkflowStep.html +2724 -0
- data/docs/Tasker/WorkflowStepEdge.html +304 -0
- data/docs/Tasker/WorkflowStepSerializer.html +305 -0
- data/docs/Tasker/WorkflowStepTransition/TransitionDescriptionFormatter.html +282 -0
- data/docs/Tasker/WorkflowStepTransition.html +2201 -0
- data/docs/Tasker/WorkflowStepsController.html +462 -0
- data/docs/Tasker.html +452 -0
- data/docs/VISION.md +584 -0
- data/docs/WHY.md +21 -0
- data/docs/_index.html +2375 -0
- data/docs/class_list.html +54 -0
- data/docs/css/common.css +1 -0
- data/docs/css/full_list.css +58 -0
- data/docs/css/style.css +503 -0
- data/docs/events/migration_plan_outcomes.md +80 -0
- data/docs/file.README.html +541 -0
- data/docs/file_list.html +59 -0
- data/docs/frames.html +22 -0
- data/docs/index.html +541 -0
- data/docs/js/app.js +344 -0
- data/docs/js/full_list.js +242 -0
- data/docs/js/jquery.js +4 -0
- data/docs/method_list.html +9182 -0
- data/docs/top-level-namespace.html +110 -0
- data/lib/generators/tasker/authenticator_generator.rb +301 -0
- data/lib/generators/tasker/authorization_coordinator_generator.rb +139 -0
- data/lib/generators/tasker/events_generator.rb +91 -0
- data/lib/generators/tasker/subscriber_generator.rb +107 -0
- data/lib/generators/tasker/task_handler_generator.rb +138 -0
- data/lib/generators/tasker/templates/api_token_authenticator.rb.erb +113 -0
- data/lib/generators/tasker/templates/api_token_authenticator_spec.rb.erb +144 -0
- data/lib/generators/tasker/templates/authorization_coordinator.rb.erb +95 -0
- data/lib/generators/tasker/templates/authorization_coordinator_spec.rb.erb +142 -0
- data/lib/generators/tasker/templates/custom_authenticator.rb.erb +108 -0
- data/lib/generators/tasker/templates/custom_authenticator_spec.rb.erb +162 -0
- data/lib/generators/tasker/templates/custom_events.yml.erb +62 -0
- data/lib/generators/tasker/templates/custom_subscriber.rb.erb +72 -0
- data/lib/generators/tasker/templates/devise_authenticator.rb.erb +101 -0
- data/lib/generators/tasker/templates/devise_authenticator_spec.rb.erb +126 -0
- data/lib/generators/tasker/templates/initialize.rb.erb +202 -0
- data/lib/generators/tasker/templates/jwt_authenticator.rb.erb +144 -0
- data/lib/generators/tasker/templates/jwt_authenticator_spec.rb.erb +298 -0
- data/lib/generators/tasker/templates/metrics_subscriber.rb.erb +258 -0
- data/lib/generators/tasker/templates/metrics_subscriber_spec.rb.erb +308 -0
- data/lib/generators/tasker/templates/omniauth_authenticator.rb.erb +135 -0
- data/lib/generators/tasker/templates/omniauth_authenticator_spec.rb.erb +196 -0
- data/lib/generators/tasker/templates/opentelemetry_initializer.rb +52 -0
- data/lib/generators/tasker/templates/subscriber.rb.erb +64 -0
- data/lib/generators/tasker/templates/subscriber_spec.rb.erb +80 -0
- data/lib/generators/tasker/templates/task_config.yaml.erb +117 -0
- data/lib/generators/tasker/templates/task_handler.rb.erb +59 -0
- data/lib/generators/tasker/templates/task_handler_spec.rb.erb +159 -0
- data/lib/tasker/analysis/runtime_graph_analyzer.rb +1168 -0
- data/lib/tasker/analysis/template_graph_analyzer.rb +328 -0
- data/lib/tasker/authentication/coordinator.rb +78 -0
- data/lib/tasker/authentication/errors.rb +9 -0
- data/lib/tasker/authentication/interface.rb +36 -0
- data/lib/tasker/authentication/none_authenticator.rb +26 -0
- data/lib/tasker/authorization/base_coordinator.rb +112 -0
- data/lib/tasker/authorization/errors.rb +26 -0
- data/lib/tasker/authorization/resource_constants.rb +74 -0
- data/lib/tasker/authorization/resource_registry.rb +143 -0
- data/lib/tasker/authorization.rb +75 -0
- data/lib/tasker/cache_capabilities.rb +131 -0
- data/lib/tasker/cache_strategy.rb +469 -0
- data/lib/tasker/concerns/authenticatable.rb +41 -0
- data/lib/tasker/concerns/authorizable.rb +204 -0
- data/lib/tasker/concerns/controller_authorizable.rb +124 -0
- data/lib/tasker/concerns/event_publisher.rb +716 -0
- data/lib/tasker/concerns/idempotent_state_transitions.rb +128 -0
- data/lib/tasker/concerns/state_machine_base.rb +218 -0
- data/lib/tasker/concerns/structured_logging.rb +387 -0
- data/lib/tasker/configuration.rb +325 -0
- data/lib/tasker/constants/event_definitions.rb +147 -0
- data/lib/tasker/constants/registry_events.rb +54 -0
- data/lib/tasker/constants.rb +417 -0
- data/lib/tasker/engine.rb +90 -0
- data/lib/tasker/errors.rb +90 -0
- data/lib/tasker/events/catalog.rb +432 -0
- data/lib/tasker/events/custom_registry.rb +175 -0
- data/lib/tasker/events/definition_loader.rb +199 -0
- data/lib/tasker/events/event_payload_builder.rb +461 -0
- data/lib/tasker/events/publisher.rb +149 -0
- data/lib/tasker/events/subscribers/base_subscriber.rb +601 -0
- data/lib/tasker/events/subscribers/metrics_subscriber.rb +120 -0
- data/lib/tasker/events/subscribers/telemetry_subscriber.rb +462 -0
- data/lib/tasker/events/subscription_loader.rb +161 -0
- data/lib/tasker/events.rb +37 -0
- data/lib/tasker/functions/function_based_analytics_metrics.rb +103 -0
- data/lib/tasker/functions/function_based_dependency_levels.rb +54 -0
- data/lib/tasker/functions/function_based_slowest_steps.rb +84 -0
- data/lib/tasker/functions/function_based_slowest_tasks.rb +84 -0
- data/lib/tasker/functions/function_based_step_readiness_status.rb +183 -0
- data/lib/tasker/functions/function_based_system_health_counts.rb +94 -0
- data/lib/tasker/functions/function_based_task_execution_context.rb +148 -0
- data/lib/tasker/functions/function_wrapper.rb +42 -0
- data/lib/tasker/functions.rb +12 -0
- data/lib/tasker/handler_factory.rb +322 -0
- data/lib/tasker/health/readiness_checker.rb +186 -0
- data/lib/tasker/health/status_checker.rb +203 -0
- data/lib/tasker/identity_strategy.rb +38 -0
- data/lib/tasker/logging/correlation_id_generator.rb +120 -0
- data/lib/tasker/orchestration/backoff_calculator.rb +184 -0
- data/lib/tasker/orchestration/connection_builder.rb +122 -0
- data/lib/tasker/orchestration/connection_pool_intelligence.rb +177 -0
- data/lib/tasker/orchestration/coordinator.rb +119 -0
- data/lib/tasker/orchestration/future_state_analyzer.rb +137 -0
- data/lib/tasker/orchestration/plugin_integration.rb +124 -0
- data/lib/tasker/orchestration/response_processor.rb +168 -0
- data/lib/tasker/orchestration/retry_header_parser.rb +78 -0
- data/lib/tasker/orchestration/step_executor.rb +941 -0
- data/lib/tasker/orchestration/step_sequence_factory.rb +67 -0
- data/lib/tasker/orchestration/task_finalizer.rb +564 -0
- data/lib/tasker/orchestration/task_initializer.rb +140 -0
- data/lib/tasker/orchestration/task_reenqueuer.rb +71 -0
- data/lib/tasker/orchestration/viable_step_discovery.rb +65 -0
- data/lib/tasker/orchestration/workflow_coordinator.rb +294 -0
- data/lib/tasker/orchestration.rb +45 -0
- data/lib/tasker/railtie.rb +9 -0
- data/lib/tasker/registry/base_registry.rb +177 -0
- data/lib/tasker/registry/event_publisher.rb +91 -0
- data/lib/tasker/registry/interface_validator.rb +140 -0
- data/lib/tasker/registry/statistics_collector.rb +381 -0
- data/lib/tasker/registry/subscriber_registry.rb +285 -0
- data/lib/tasker/registry.rb +22 -0
- data/lib/tasker/state_machine/step_state_machine.rb +508 -0
- data/lib/tasker/state_machine/task_state_machine.rb +192 -0
- data/lib/tasker/state_machine.rb +83 -0
- data/lib/tasker/step_handler/api.rb +410 -0
- data/lib/tasker/step_handler/base.rb +206 -0
- data/lib/tasker/task_builder.rb +432 -0
- data/lib/tasker/task_handler/class_methods.rb +324 -0
- data/lib/tasker/task_handler/instance_methods.rb +293 -0
- data/lib/tasker/task_handler/step_group.rb +182 -0
- data/lib/tasker/task_handler.rb +43 -0
- data/lib/tasker/telemetry/event_mapping.rb +126 -0
- data/lib/tasker/telemetry/event_router.rb +318 -0
- data/lib/tasker/telemetry/events/export_events.rb +38 -0
- data/lib/tasker/telemetry/export_coordinator.rb +497 -0
- data/lib/tasker/telemetry/intelligent_cache_manager.rb +508 -0
- data/lib/tasker/telemetry/log_backend.rb +224 -0
- data/lib/tasker/telemetry/metric_types.rb +368 -0
- data/lib/tasker/telemetry/metrics_backend.rb +1227 -0
- data/lib/tasker/telemetry/metrics_export_service.rb +392 -0
- data/lib/tasker/telemetry/plugin_registry.rb +333 -0
- data/lib/tasker/telemetry/plugins/base_exporter.rb +246 -0
- data/lib/tasker/telemetry/plugins/csv_exporter.rb +198 -0
- data/lib/tasker/telemetry/plugins/json_exporter.rb +141 -0
- data/lib/tasker/telemetry/prometheus_exporter.rb +249 -0
- data/lib/tasker/telemetry/trace_backend.rb +186 -0
- data/lib/tasker/telemetry.rb +59 -0
- data/lib/tasker/types/auth_config.rb +81 -0
- data/lib/tasker/types/backoff_config.rb +142 -0
- data/lib/tasker/types/cache_config.rb +257 -0
- data/lib/tasker/types/database_config.rb +39 -0
- data/lib/tasker/types/dependency_graph.rb +225 -0
- data/lib/tasker/types/dependency_graph_config.rb +149 -0
- data/lib/tasker/types/engine_config.rb +131 -0
- data/lib/tasker/types/execution_config.rb +289 -0
- data/lib/tasker/types/health_config.rb +84 -0
- data/lib/tasker/types/step_sequence.rb +24 -0
- data/lib/tasker/types/step_template.rb +63 -0
- data/lib/tasker/types/task_request.rb +60 -0
- data/lib/tasker/types/telemetry_config.rb +273 -0
- data/lib/tasker/types.rb +64 -0
- data/lib/tasker/version.rb +7 -0
- data/lib/tasker.rb +82 -0
- data/lib/tasks/tasker_tasks.rake +302 -0
- metadata +958 -0
@@ -0,0 +1,2510 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>
|
7
|
+
Class: Tasker::Telemetry::MetricsBackend
|
8
|
+
|
9
|
+
— Documentation by YARD 0.9.37
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../../css/style.css" type="text/css" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../../css/common.css" type="text/css" />
|
16
|
+
|
17
|
+
<script type="text/javascript">
|
18
|
+
pathId = "Tasker::Telemetry::MetricsBackend";
|
19
|
+
relpath = '../../';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="../../class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="../../_index.html">Index (M)</a> »
|
40
|
+
<span class='title'><span class='object_link'><a href="../../Tasker.html" title="Tasker (module)">Tasker</a></span></span> » <span class='title'><span class='object_link'><a href="../Telemetry.html" title="Tasker::Telemetry (module)">Telemetry</a></span></span>
|
41
|
+
»
|
42
|
+
<span class="title">MetricsBackend</span>
|
43
|
+
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div id="search">
|
47
|
+
|
48
|
+
<a class="full_list_link" id="class_list_link"
|
49
|
+
href="../../class_list.html">
|
50
|
+
|
51
|
+
<svg width="24" height="24">
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
+
</svg>
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<div id="content"><h1>Class: Tasker::Telemetry::MetricsBackend
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
69
|
+
<dl>
|
70
|
+
<dt>Inherits:</dt>
|
71
|
+
<dd>
|
72
|
+
<span class="inheritName">Object</span>
|
73
|
+
|
74
|
+
<ul class="fullTree">
|
75
|
+
<li>Object</li>
|
76
|
+
|
77
|
+
<li class="next">Tasker::Telemetry::MetricsBackend</li>
|
78
|
+
|
79
|
+
</ul>
|
80
|
+
<a href="#" class="inheritanceTree">show all</a>
|
81
|
+
|
82
|
+
</dd>
|
83
|
+
</dl>
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
<dl>
|
91
|
+
<dt>Includes:</dt>
|
92
|
+
<dd>Singleton</dd>
|
93
|
+
</dl>
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
<dl>
|
101
|
+
<dt>Defined in:</dt>
|
102
|
+
<dd>lib/tasker/telemetry/metrics_backend.rb</dd>
|
103
|
+
</dl>
|
104
|
+
|
105
|
+
</div>
|
106
|
+
|
107
|
+
<h2>Overview</h2><div class="docstring">
|
108
|
+
<div class="discussion">
|
109
|
+
|
110
|
+
<p>MetricsBackend provides thread-safe, high-performance native metrics collection</p>
|
111
|
+
|
112
|
+
<p>This class implements Tasker’s core metrics storage system with thread-safe operations, automatic EventRouter integration, and zero-overhead metric collection. It follows the singleton pattern consistent with HandlerFactory and Events::Publisher.</p>
|
113
|
+
|
114
|
+
<p><strong>Phase 4.2.2.3 Enhancement: Hybrid Rails Cache Architecture</strong> The backend now supports cache-agnostic dual storage combining in-memory performance with Rails.cache persistence and cross-container coordination.</p>
|
115
|
+
|
116
|
+
<p>The backend supports three core metric types: - Counter: Monotonically increasing values (requests, errors, completions) - Gauge: Values that can go up/down (active connections, queue depth) - Histogram: Statistical distributions (latencies, sizes, durations)</p>
|
117
|
+
|
118
|
+
<p><strong>Cache Store Compatibility:</strong> - Redis/Memcached: Full coordination with atomic operations and locking - File/Memory stores: Local-only mode with clear degradation messaging - Automatic feature detection with appropriate strategy selection</p>
|
119
|
+
|
120
|
+
|
121
|
+
</div>
|
122
|
+
</div>
|
123
|
+
<div class="tags">
|
124
|
+
|
125
|
+
<div class="examples">
|
126
|
+
<h4 class="tag_title">Examples:</h4>
|
127
|
+
|
128
|
+
|
129
|
+
<h5 class="example_title"><div class='inline'>
|
130
|
+
<p>Basic usage</p>
|
131
|
+
</div></h5>
|
132
|
+
|
133
|
+
<pre class="example code"><code><span class='id identifier rubyid_backend'>backend</span> <span class='op'>=</span> <span class='const'>MetricsBackend</span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span>
|
134
|
+
<span class='id identifier rubyid_backend'>backend</span><span class='period'>.</span><span class='id identifier rubyid_counter'>counter</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>api_requests_total</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_increment'>increment</span>
|
135
|
+
<span class='id identifier rubyid_backend'>backend</span><span class='period'>.</span><span class='id identifier rubyid_gauge'>gauge</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>active_tasks</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_set'>set</span><span class='lparen'>(</span><span class='int'>42</span><span class='rparen'>)</span>
|
136
|
+
<span class='id identifier rubyid_backend'>backend</span><span class='period'>.</span><span class='id identifier rubyid_histogram'>histogram</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>task_duration_seconds</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_observe'>observe</span><span class='lparen'>(</span><span class='float'>1.45</span><span class='rparen'>)</span></code></pre>
|
137
|
+
|
138
|
+
|
139
|
+
<h5 class="example_title"><div class='inline'>
|
140
|
+
<p>EventRouter integration</p>
|
141
|
+
</div></h5>
|
142
|
+
|
143
|
+
<pre class="example code"><code><span class='comment'># Automatic metric collection based on event routing
|
144
|
+
</span><span class='id identifier rubyid_backend'>backend</span><span class='period'>.</span><span class='id identifier rubyid_handle_event'>handle_event</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>task.completed</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='lbrace'>{</span> <span class='label'>duration:</span> <span class='float'>2.1</span><span class='comma'>,</span> <span class='label'>status:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>success</span><span class='tstring_end'>'</span></span> <span class='rbrace'>}</span><span class='rparen'>)</span></code></pre>
|
145
|
+
|
146
|
+
|
147
|
+
<h5 class="example_title"><div class='inline'>
|
148
|
+
<p>Cache synchronization</p>
|
149
|
+
</div></h5>
|
150
|
+
|
151
|
+
<pre class="example code"><code><span class='id identifier rubyid_backend'>backend</span><span class='period'>.</span><span class='id identifier rubyid_sync_to_cache!'>sync_to_cache!</span> <span class='comment'># Periodic background sync
|
152
|
+
</span><span class='id identifier rubyid_backend'>backend</span><span class='period'>.</span><span class='id identifier rubyid_export_distributed_metrics'>export_distributed_metrics</span> <span class='comment'># Cross-container export</span></code></pre>
|
153
|
+
|
154
|
+
</div>
|
155
|
+
|
156
|
+
|
157
|
+
</div>
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
<h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
|
162
|
+
<ul class="summary">
|
163
|
+
|
164
|
+
<li class="public ">
|
165
|
+
<span class="summary_signature">
|
166
|
+
|
167
|
+
<a href="#cache_capabilities-instance_method" title="#cache_capabilities (instance method)">#<strong>cache_capabilities</strong> ⇒ Hash </a>
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
</span>
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
<span class="note title readonly">readonly</span>
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
<span class="summary_desc"><div class='inline'>
|
187
|
+
<p>Cache capabilities detected at initialization.</p>
|
188
|
+
</div></span>
|
189
|
+
|
190
|
+
</li>
|
191
|
+
|
192
|
+
|
193
|
+
<li class="public ">
|
194
|
+
<span class="summary_signature">
|
195
|
+
|
196
|
+
<a href="#cache_strategy-instance_method" title="#cache_strategy (instance method)">#<strong>cache_strategy</strong> ⇒ Tasker::CacheStrategy </a>
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
</span>
|
201
|
+
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
<span class="note title readonly">readonly</span>
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
<span class="summary_desc"><div class='inline'>
|
216
|
+
<p>Cache strategy for this instance.</p>
|
217
|
+
</div></span>
|
218
|
+
|
219
|
+
</li>
|
220
|
+
|
221
|
+
|
222
|
+
<li class="public ">
|
223
|
+
<span class="summary_signature">
|
224
|
+
|
225
|
+
<a href="#created_at-instance_method" title="#created_at (instance method)">#<strong>created_at</strong> ⇒ Time </a>
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
</span>
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
|
234
|
+
<span class="note title readonly">readonly</span>
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
|
244
|
+
<span class="summary_desc"><div class='inline'>
|
245
|
+
<p>Backend creation timestamp for monitoring.</p>
|
246
|
+
</div></span>
|
247
|
+
|
248
|
+
</li>
|
249
|
+
|
250
|
+
|
251
|
+
<li class="public ">
|
252
|
+
<span class="summary_signature">
|
253
|
+
|
254
|
+
<a href="#event_router-instance_method" title="#event_router (instance method)">#<strong>event_router</strong> ⇒ EventRouter </a>
|
255
|
+
|
256
|
+
|
257
|
+
|
258
|
+
</span>
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
<span class="note title readonly">readonly</span>
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
<span class="summary_desc"><div class='inline'>
|
274
|
+
<p>EventRouter instance for intelligent event routing.</p>
|
275
|
+
</div></span>
|
276
|
+
|
277
|
+
</li>
|
278
|
+
|
279
|
+
|
280
|
+
<li class="public ">
|
281
|
+
<span class="summary_signature">
|
282
|
+
|
283
|
+
<a href="#instance_id-instance_method" title="#instance_id (instance method)">#<strong>instance_id</strong> ⇒ String </a>
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
</span>
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
|
292
|
+
<span class="note title readonly">readonly</span>
|
293
|
+
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
|
302
|
+
<span class="summary_desc"><div class='inline'>
|
303
|
+
<p>Unique instance identifier for distributed coordination.</p>
|
304
|
+
</div></span>
|
305
|
+
|
306
|
+
</li>
|
307
|
+
|
308
|
+
|
309
|
+
<li class="public ">
|
310
|
+
<span class="summary_signature">
|
311
|
+
|
312
|
+
<a href="#metrics-instance_method" title="#metrics (instance method)">#<strong>metrics</strong> ⇒ Concurrent::Hash </a>
|
313
|
+
|
314
|
+
|
315
|
+
|
316
|
+
</span>
|
317
|
+
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
<span class="note title readonly">readonly</span>
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
<span class="summary_desc"><div class='inline'>
|
332
|
+
<p>Core metric registry storing all active metrics Using ConcurrentHash for thread-safe operations without locks.</p>
|
333
|
+
</div></span>
|
334
|
+
|
335
|
+
</li>
|
336
|
+
|
337
|
+
|
338
|
+
<li class="public ">
|
339
|
+
<span class="summary_signature">
|
340
|
+
|
341
|
+
<a href="#sync_config-instance_method" title="#sync_config (instance method)">#<strong>sync_config</strong> ⇒ Hash </a>
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
</span>
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
|
350
|
+
<span class="note title readonly">readonly</span>
|
351
|
+
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
|
358
|
+
|
359
|
+
|
360
|
+
<span class="summary_desc"><div class='inline'>
|
361
|
+
<p>Configuration for cache synchronization.</p>
|
362
|
+
</div></span>
|
363
|
+
|
364
|
+
</li>
|
365
|
+
|
366
|
+
|
367
|
+
<li class="public ">
|
368
|
+
<span class="summary_signature">
|
369
|
+
|
370
|
+
<a href="#sync_strategy-instance_method" title="#sync_strategy (instance method)">#<strong>sync_strategy</strong> ⇒ Symbol </a>
|
371
|
+
|
372
|
+
|
373
|
+
|
374
|
+
</span>
|
375
|
+
|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
<span class="note title readonly">readonly</span>
|
380
|
+
|
381
|
+
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
|
386
|
+
|
387
|
+
|
388
|
+
|
389
|
+
<span class="summary_desc"><div class='inline'>
|
390
|
+
<p>Selected sync strategy based on cache capabilities.</p>
|
391
|
+
</div></span>
|
392
|
+
|
393
|
+
</li>
|
394
|
+
|
395
|
+
|
396
|
+
</ul>
|
397
|
+
|
398
|
+
|
399
|
+
|
400
|
+
|
401
|
+
|
402
|
+
<h2>
|
403
|
+
Instance Method Summary
|
404
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
405
|
+
</h2>
|
406
|
+
|
407
|
+
<ul class="summary">
|
408
|
+
|
409
|
+
<li class="public ">
|
410
|
+
<span class="summary_signature">
|
411
|
+
|
412
|
+
<a href="#all_metrics-instance_method" title="#all_metrics (instance method)">#<strong>all_metrics</strong> ⇒ Hash </a>
|
413
|
+
|
414
|
+
|
415
|
+
|
416
|
+
</span>
|
417
|
+
|
418
|
+
|
419
|
+
|
420
|
+
|
421
|
+
|
422
|
+
|
423
|
+
|
424
|
+
|
425
|
+
|
426
|
+
<span class="summary_desc"><div class='inline'>
|
427
|
+
<p>Get all registered metrics.</p>
|
428
|
+
</div></span>
|
429
|
+
|
430
|
+
</li>
|
431
|
+
|
432
|
+
|
433
|
+
<li class="public ">
|
434
|
+
<span class="summary_signature">
|
435
|
+
|
436
|
+
<a href="#clear!-instance_method" title="#clear! (instance method)">#<strong>clear!</strong> ⇒ Integer </a>
|
437
|
+
|
438
|
+
|
439
|
+
|
440
|
+
</span>
|
441
|
+
|
442
|
+
|
443
|
+
|
444
|
+
|
445
|
+
|
446
|
+
|
447
|
+
|
448
|
+
|
449
|
+
|
450
|
+
<span class="summary_desc"><div class='inline'>
|
451
|
+
<p>Clear all metrics (primarily for testing).</p>
|
452
|
+
</div></span>
|
453
|
+
|
454
|
+
</li>
|
455
|
+
|
456
|
+
|
457
|
+
<li class="public ">
|
458
|
+
<span class="summary_signature">
|
459
|
+
|
460
|
+
<a href="#counter-instance_method" title="#counter (instance method)">#<strong>counter</strong>(name, **labels) ⇒ MetricTypes::Counter </a>
|
461
|
+
|
462
|
+
|
463
|
+
|
464
|
+
</span>
|
465
|
+
|
466
|
+
|
467
|
+
|
468
|
+
|
469
|
+
|
470
|
+
|
471
|
+
|
472
|
+
|
473
|
+
|
474
|
+
<span class="summary_desc"><div class='inline'>
|
475
|
+
<p>Get or create a counter metric.</p>
|
476
|
+
</div></span>
|
477
|
+
|
478
|
+
</li>
|
479
|
+
|
480
|
+
|
481
|
+
<li class="public ">
|
482
|
+
<span class="summary_signature">
|
483
|
+
|
484
|
+
<a href="#export-instance_method" title="#export (instance method)">#<strong>export</strong> ⇒ Hash </a>
|
485
|
+
|
486
|
+
|
487
|
+
|
488
|
+
</span>
|
489
|
+
|
490
|
+
|
491
|
+
|
492
|
+
|
493
|
+
|
494
|
+
|
495
|
+
|
496
|
+
|
497
|
+
|
498
|
+
<span class="summary_desc"><div class='inline'>
|
499
|
+
<p>Export all metrics to a format suitable for monitoring systems.</p>
|
500
|
+
</div></span>
|
501
|
+
|
502
|
+
</li>
|
503
|
+
|
504
|
+
|
505
|
+
<li class="public ">
|
506
|
+
<span class="summary_signature">
|
507
|
+
|
508
|
+
<a href="#export_distributed_metrics-instance_method" title="#export_distributed_metrics (instance method)">#<strong>export_distributed_metrics</strong>(include_instances: false) ⇒ Hash </a>
|
509
|
+
|
510
|
+
|
511
|
+
|
512
|
+
</span>
|
513
|
+
|
514
|
+
|
515
|
+
|
516
|
+
|
517
|
+
|
518
|
+
|
519
|
+
|
520
|
+
|
521
|
+
|
522
|
+
<span class="summary_desc"><div class='inline'>
|
523
|
+
<p>Export metrics with distributed coordination when supported.</p>
|
524
|
+
</div></span>
|
525
|
+
|
526
|
+
</li>
|
527
|
+
|
528
|
+
|
529
|
+
<li class="public ">
|
530
|
+
<span class="summary_signature">
|
531
|
+
|
532
|
+
<a href="#gauge-instance_method" title="#gauge (instance method)">#<strong>gauge</strong>(name, **labels) ⇒ MetricTypes::Gauge </a>
|
533
|
+
|
534
|
+
|
535
|
+
|
536
|
+
</span>
|
537
|
+
|
538
|
+
|
539
|
+
|
540
|
+
|
541
|
+
|
542
|
+
|
543
|
+
|
544
|
+
|
545
|
+
|
546
|
+
<span class="summary_desc"><div class='inline'>
|
547
|
+
<p>Get or create a gauge metric.</p>
|
548
|
+
</div></span>
|
549
|
+
|
550
|
+
</li>
|
551
|
+
|
552
|
+
|
553
|
+
<li class="public ">
|
554
|
+
<span class="summary_signature">
|
555
|
+
|
556
|
+
<a href="#handle_event-instance_method" title="#handle_event (instance method)">#<strong>handle_event</strong>(event_name, payload = {}) ⇒ Boolean </a>
|
557
|
+
|
558
|
+
|
559
|
+
|
560
|
+
</span>
|
561
|
+
|
562
|
+
|
563
|
+
|
564
|
+
|
565
|
+
|
566
|
+
|
567
|
+
|
568
|
+
|
569
|
+
|
570
|
+
<span class="summary_desc"><div class='inline'>
|
571
|
+
<p>Handle an event from EventRouter and collect appropriate metrics.</p>
|
572
|
+
</div></span>
|
573
|
+
|
574
|
+
</li>
|
575
|
+
|
576
|
+
|
577
|
+
<li class="public ">
|
578
|
+
<span class="summary_signature">
|
579
|
+
|
580
|
+
<a href="#histogram-instance_method" title="#histogram (instance method)">#<strong>histogram</strong>(name, buckets: nil, **labels) ⇒ MetricTypes::Histogram </a>
|
581
|
+
|
582
|
+
|
583
|
+
|
584
|
+
</span>
|
585
|
+
|
586
|
+
|
587
|
+
|
588
|
+
|
589
|
+
|
590
|
+
|
591
|
+
|
592
|
+
|
593
|
+
|
594
|
+
<span class="summary_desc"><div class='inline'>
|
595
|
+
<p>Get or create a histogram metric.</p>
|
596
|
+
</div></span>
|
597
|
+
|
598
|
+
</li>
|
599
|
+
|
600
|
+
|
601
|
+
<li class="public ">
|
602
|
+
<span class="summary_signature">
|
603
|
+
|
604
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong> ⇒ MetricsBackend </a>
|
605
|
+
|
606
|
+
|
607
|
+
|
608
|
+
</span>
|
609
|
+
|
610
|
+
|
611
|
+
<span class="note title constructor">constructor</span>
|
612
|
+
|
613
|
+
|
614
|
+
|
615
|
+
|
616
|
+
|
617
|
+
|
618
|
+
|
619
|
+
|
620
|
+
<span class="summary_desc"><div class='inline'>
|
621
|
+
<p>Initialize the metrics backend.</p>
|
622
|
+
</div></span>
|
623
|
+
|
624
|
+
</li>
|
625
|
+
|
626
|
+
|
627
|
+
<li class="public ">
|
628
|
+
<span class="summary_signature">
|
629
|
+
|
630
|
+
<a href="#register_event_router-instance_method" title="#register_event_router (instance method)">#<strong>register_event_router</strong>(router) ⇒ EventRouter </a>
|
631
|
+
|
632
|
+
|
633
|
+
|
634
|
+
</span>
|
635
|
+
|
636
|
+
|
637
|
+
|
638
|
+
|
639
|
+
|
640
|
+
|
641
|
+
|
642
|
+
|
643
|
+
|
644
|
+
<span class="summary_desc"><div class='inline'>
|
645
|
+
<p>Register the EventRouter for intelligent routing.</p>
|
646
|
+
</div></span>
|
647
|
+
|
648
|
+
</li>
|
649
|
+
|
650
|
+
|
651
|
+
<li class="public ">
|
652
|
+
<span class="summary_signature">
|
653
|
+
|
654
|
+
<a href="#stats-instance_method" title="#stats (instance method)">#<strong>stats</strong> ⇒ Hash </a>
|
655
|
+
|
656
|
+
|
657
|
+
|
658
|
+
</span>
|
659
|
+
|
660
|
+
|
661
|
+
|
662
|
+
|
663
|
+
|
664
|
+
|
665
|
+
|
666
|
+
|
667
|
+
|
668
|
+
<span class="summary_desc"><div class='inline'>
|
669
|
+
<p>Get summary statistics about the metrics backend.</p>
|
670
|
+
</div></span>
|
671
|
+
|
672
|
+
</li>
|
673
|
+
|
674
|
+
|
675
|
+
<li class="public ">
|
676
|
+
<span class="summary_signature">
|
677
|
+
|
678
|
+
<a href="#sync_to_cache!-instance_method" title="#sync_to_cache! (instance method)">#<strong>sync_to_cache!</strong> ⇒ Hash </a>
|
679
|
+
|
680
|
+
|
681
|
+
|
682
|
+
</span>
|
683
|
+
|
684
|
+
|
685
|
+
|
686
|
+
|
687
|
+
|
688
|
+
|
689
|
+
|
690
|
+
|
691
|
+
|
692
|
+
<span class="summary_desc"><div class='inline'>
|
693
|
+
<p>Synchronize in-memory metrics to Rails.cache using detected strategy.</p>
|
694
|
+
</div></span>
|
695
|
+
|
696
|
+
</li>
|
697
|
+
|
698
|
+
|
699
|
+
</ul>
|
700
|
+
|
701
|
+
|
702
|
+
|
703
|
+
<div id="constructor_details" class="method_details_list">
|
704
|
+
<h2>Constructor Details</h2>
|
705
|
+
|
706
|
+
<div class="method_details first">
|
707
|
+
<h3 class="signature first" id="initialize-instance_method">
|
708
|
+
|
709
|
+
#<strong>initialize</strong> ⇒ <tt><span class='object_link'><a href="" title="Tasker::Telemetry::MetricsBackend (class)">MetricsBackend</a></span></tt>
|
710
|
+
|
711
|
+
|
712
|
+
|
713
|
+
|
714
|
+
|
715
|
+
</h3><div class="docstring">
|
716
|
+
<div class="discussion">
|
717
|
+
|
718
|
+
<p>Initialize the metrics backend</p>
|
719
|
+
|
720
|
+
<p>Sets up thread-safe storage, integrates with EventRouter, and configures cache capabilities for hybrid architecture. Called automatically via singleton pattern.</p>
|
721
|
+
|
722
|
+
|
723
|
+
</div>
|
724
|
+
</div>
|
725
|
+
<div class="tags">
|
726
|
+
|
727
|
+
|
728
|
+
</div><table class="source_code">
|
729
|
+
<tr>
|
730
|
+
<td>
|
731
|
+
<pre class="lines">
|
732
|
+
|
733
|
+
|
734
|
+
84
|
735
|
+
85
|
736
|
+
86
|
737
|
+
87
|
738
|
+
88
|
739
|
+
89
|
740
|
+
90
|
741
|
+
91
|
742
|
+
92
|
743
|
+
93
|
744
|
+
94
|
745
|
+
95
|
746
|
+
96
|
747
|
+
97
|
748
|
+
98
|
749
|
+
99
|
750
|
+
100
|
751
|
+
101
|
752
|
+
102
|
753
|
+
103
|
754
|
+
104</pre>
|
755
|
+
</td>
|
756
|
+
<td>
|
757
|
+
<pre class="code"><span class="info file"># File 'lib/tasker/telemetry/metrics_backend.rb', line 84</span>
|
758
|
+
|
759
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span>
|
760
|
+
<span class='ivar'>@metrics</span> <span class='op'>=</span> <span class='const'>Concurrent</span><span class='op'>::</span><span class='const'>Hash</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
|
761
|
+
<span class='ivar'>@event_router</span> <span class='op'>=</span> <span class='kw'>nil</span>
|
762
|
+
<span class='ivar'>@local_buffer</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
763
|
+
<span class='ivar'>@last_sync</span> <span class='op'>=</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_current'>current</span>
|
764
|
+
<span class='ivar'>@created_at</span> <span class='op'>=</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_current'>current</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span>
|
765
|
+
|
766
|
+
<span class='comment'># Thread-safe metric creation lock
|
767
|
+
</span> <span class='ivar'>@metric_creation_lock</span> <span class='op'>=</span> <span class='const'>Mutex</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
|
768
|
+
|
769
|
+
<span class='comment'># Use unified cache strategy for capability detection
|
770
|
+
</span> <span class='ivar'>@cache_strategy</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../../Tasker.html" title="Tasker (module)">Tasker</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../CacheStrategy.html" title="Tasker::CacheStrategy (class)">CacheStrategy</a></span></span><span class='period'>.</span><span class='id identifier rubyid_detect'><span class='object_link'><a href="../CacheStrategy.html#detect-class_method" title="Tasker::CacheStrategy.detect (method)">detect</a></span></span>
|
771
|
+
<span class='ivar'>@instance_id</span> <span class='op'>=</span> <span class='ivar'>@cache_strategy</span><span class='period'>.</span><span class='id identifier rubyid_instance_id'>instance_id</span>
|
772
|
+
<span class='ivar'>@sync_strategy</span> <span class='op'>=</span> <span class='ivar'>@cache_strategy</span><span class='period'>.</span><span class='id identifier rubyid_coordination_mode'>coordination_mode</span>
|
773
|
+
|
774
|
+
<span class='comment'># Extract capabilities for backward compatibility
|
775
|
+
</span> <span class='ivar'>@cache_capabilities</span> <span class='op'>=</span> <span class='ivar'>@cache_strategy</span><span class='period'>.</span><span class='id identifier rubyid_export_capabilities'>export_capabilities</span>
|
776
|
+
<span class='ivar'>@sync_config</span> <span class='op'>=</span> <span class='id identifier rubyid_configure_sync_parameters'>configure_sync_parameters</span>
|
777
|
+
|
778
|
+
<span class='id identifier rubyid_log_cache_strategy_selection'>log_cache_strategy_selection</span>
|
779
|
+
<span class='kw'>end</span></pre>
|
780
|
+
</td>
|
781
|
+
</tr>
|
782
|
+
</table>
|
783
|
+
</div>
|
784
|
+
|
785
|
+
</div>
|
786
|
+
|
787
|
+
<div id="instance_attr_details" class="attr_details">
|
788
|
+
<h2>Instance Attribute Details</h2>
|
789
|
+
|
790
|
+
|
791
|
+
<span id=""></span>
|
792
|
+
<div class="method_details first">
|
793
|
+
<h3 class="signature first" id="cache_capabilities-instance_method">
|
794
|
+
|
795
|
+
#<strong>cache_capabilities</strong> ⇒ <tt>Hash</tt> <span class="extras">(readonly)</span>
|
796
|
+
|
797
|
+
|
798
|
+
|
799
|
+
|
800
|
+
|
801
|
+
</h3><div class="docstring">
|
802
|
+
<div class="discussion">
|
803
|
+
|
804
|
+
<p>Cache capabilities detected at initialization</p>
|
805
|
+
|
806
|
+
|
807
|
+
</div>
|
808
|
+
</div>
|
809
|
+
<div class="tags">
|
810
|
+
|
811
|
+
<p class="tag_title">Returns:</p>
|
812
|
+
<ul class="return">
|
813
|
+
|
814
|
+
<li>
|
815
|
+
|
816
|
+
|
817
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
818
|
+
|
819
|
+
|
820
|
+
|
821
|
+
—
|
822
|
+
<div class='inline'>
|
823
|
+
<p>Detected Rails.cache capabilities</p>
|
824
|
+
</div>
|
825
|
+
|
826
|
+
</li>
|
827
|
+
|
828
|
+
</ul>
|
829
|
+
|
830
|
+
</div><table class="source_code">
|
831
|
+
<tr>
|
832
|
+
<td>
|
833
|
+
<pre class="lines">
|
834
|
+
|
835
|
+
|
836
|
+
61
|
837
|
+
62
|
838
|
+
63</pre>
|
839
|
+
</td>
|
840
|
+
<td>
|
841
|
+
<pre class="code"><span class="info file"># File 'lib/tasker/telemetry/metrics_backend.rb', line 61</span>
|
842
|
+
|
843
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_cache_capabilities'>cache_capabilities</span>
|
844
|
+
<span class='ivar'>@cache_capabilities</span>
|
845
|
+
<span class='kw'>end</span></pre>
|
846
|
+
</td>
|
847
|
+
</tr>
|
848
|
+
</table>
|
849
|
+
</div>
|
850
|
+
|
851
|
+
|
852
|
+
<span id=""></span>
|
853
|
+
<div class="method_details ">
|
854
|
+
<h3 class="signature " id="cache_strategy-instance_method">
|
855
|
+
|
856
|
+
#<strong>cache_strategy</strong> ⇒ <tt><span class='object_link'><a href="../CacheStrategy.html" title="Tasker::CacheStrategy (class)">Tasker::CacheStrategy</a></span></tt> <span class="extras">(readonly)</span>
|
857
|
+
|
858
|
+
|
859
|
+
|
860
|
+
|
861
|
+
|
862
|
+
</h3><div class="docstring">
|
863
|
+
<div class="discussion">
|
864
|
+
|
865
|
+
<p>Cache strategy for this instance</p>
|
866
|
+
|
867
|
+
|
868
|
+
</div>
|
869
|
+
</div>
|
870
|
+
<div class="tags">
|
871
|
+
|
872
|
+
<p class="tag_title">Returns:</p>
|
873
|
+
<ul class="return">
|
874
|
+
|
875
|
+
<li>
|
876
|
+
|
877
|
+
|
878
|
+
<span class='type'>(<tt><span class='object_link'><a href="../CacheStrategy.html" title="Tasker::CacheStrategy (class)">Tasker::CacheStrategy</a></span></tt>)</span>
|
879
|
+
|
880
|
+
|
881
|
+
|
882
|
+
—
|
883
|
+
<div class='inline'>
|
884
|
+
<p>The cache strategy for this instance</p>
|
885
|
+
</div>
|
886
|
+
|
887
|
+
</li>
|
888
|
+
|
889
|
+
</ul>
|
890
|
+
|
891
|
+
</div><table class="source_code">
|
892
|
+
<tr>
|
893
|
+
<td>
|
894
|
+
<pre class="lines">
|
895
|
+
|
896
|
+
|
897
|
+
77
|
898
|
+
78
|
899
|
+
79</pre>
|
900
|
+
</td>
|
901
|
+
<td>
|
902
|
+
<pre class="code"><span class="info file"># File 'lib/tasker/telemetry/metrics_backend.rb', line 77</span>
|
903
|
+
|
904
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_cache_strategy'>cache_strategy</span>
|
905
|
+
<span class='ivar'>@cache_strategy</span>
|
906
|
+
<span class='kw'>end</span></pre>
|
907
|
+
</td>
|
908
|
+
</tr>
|
909
|
+
</table>
|
910
|
+
</div>
|
911
|
+
|
912
|
+
|
913
|
+
<span id=""></span>
|
914
|
+
<div class="method_details ">
|
915
|
+
<h3 class="signature " id="created_at-instance_method">
|
916
|
+
|
917
|
+
#<strong>created_at</strong> ⇒ <tt>Time</tt> <span class="extras">(readonly)</span>
|
918
|
+
|
919
|
+
|
920
|
+
|
921
|
+
|
922
|
+
|
923
|
+
</h3><div class="docstring">
|
924
|
+
<div class="discussion">
|
925
|
+
|
926
|
+
<p>Backend creation timestamp for monitoring</p>
|
927
|
+
|
928
|
+
|
929
|
+
</div>
|
930
|
+
</div>
|
931
|
+
<div class="tags">
|
932
|
+
|
933
|
+
<p class="tag_title">Returns:</p>
|
934
|
+
<ul class="return">
|
935
|
+
|
936
|
+
<li>
|
937
|
+
|
938
|
+
|
939
|
+
<span class='type'>(<tt>Time</tt>)</span>
|
940
|
+
|
941
|
+
|
942
|
+
|
943
|
+
—
|
944
|
+
<div class='inline'>
|
945
|
+
<p>When this backend was initialized</p>
|
946
|
+
</div>
|
947
|
+
|
948
|
+
</li>
|
949
|
+
|
950
|
+
</ul>
|
951
|
+
|
952
|
+
</div><table class="source_code">
|
953
|
+
<tr>
|
954
|
+
<td>
|
955
|
+
<pre class="lines">
|
956
|
+
|
957
|
+
|
958
|
+
57
|
959
|
+
58
|
960
|
+
59</pre>
|
961
|
+
</td>
|
962
|
+
<td>
|
963
|
+
<pre class="code"><span class="info file"># File 'lib/tasker/telemetry/metrics_backend.rb', line 57</span>
|
964
|
+
|
965
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_created_at'>created_at</span>
|
966
|
+
<span class='ivar'>@created_at</span>
|
967
|
+
<span class='kw'>end</span></pre>
|
968
|
+
</td>
|
969
|
+
</tr>
|
970
|
+
</table>
|
971
|
+
</div>
|
972
|
+
|
973
|
+
|
974
|
+
<span id=""></span>
|
975
|
+
<div class="method_details ">
|
976
|
+
<h3 class="signature " id="event_router-instance_method">
|
977
|
+
|
978
|
+
#<strong>event_router</strong> ⇒ <tt><span class='object_link'><a href="EventRouter.html" title="Tasker::Telemetry::EventRouter (class)">EventRouter</a></span></tt> <span class="extras">(readonly)</span>
|
979
|
+
|
980
|
+
|
981
|
+
|
982
|
+
|
983
|
+
|
984
|
+
</h3><div class="docstring">
|
985
|
+
<div class="discussion">
|
986
|
+
|
987
|
+
<p>EventRouter instance for intelligent event routing</p>
|
988
|
+
|
989
|
+
|
990
|
+
</div>
|
991
|
+
</div>
|
992
|
+
<div class="tags">
|
993
|
+
|
994
|
+
<p class="tag_title">Returns:</p>
|
995
|
+
<ul class="return">
|
996
|
+
|
997
|
+
<li>
|
998
|
+
|
999
|
+
|
1000
|
+
<span class='type'>(<tt><span class='object_link'><a href="EventRouter.html" title="Tasker::Telemetry::EventRouter (class)">EventRouter</a></span></tt>)</span>
|
1001
|
+
|
1002
|
+
|
1003
|
+
|
1004
|
+
—
|
1005
|
+
<div class='inline'>
|
1006
|
+
<p>The configured event router</p>
|
1007
|
+
</div>
|
1008
|
+
|
1009
|
+
</li>
|
1010
|
+
|
1011
|
+
</ul>
|
1012
|
+
|
1013
|
+
</div><table class="source_code">
|
1014
|
+
<tr>
|
1015
|
+
<td>
|
1016
|
+
<pre class="lines">
|
1017
|
+
|
1018
|
+
|
1019
|
+
53
|
1020
|
+
54
|
1021
|
+
55</pre>
|
1022
|
+
</td>
|
1023
|
+
<td>
|
1024
|
+
<pre class="code"><span class="info file"># File 'lib/tasker/telemetry/metrics_backend.rb', line 53</span>
|
1025
|
+
|
1026
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_event_router'>event_router</span>
|
1027
|
+
<span class='ivar'>@event_router</span>
|
1028
|
+
<span class='kw'>end</span></pre>
|
1029
|
+
</td>
|
1030
|
+
</tr>
|
1031
|
+
</table>
|
1032
|
+
</div>
|
1033
|
+
|
1034
|
+
|
1035
|
+
<span id=""></span>
|
1036
|
+
<div class="method_details ">
|
1037
|
+
<h3 class="signature " id="instance_id-instance_method">
|
1038
|
+
|
1039
|
+
#<strong>instance_id</strong> ⇒ <tt>String</tt> <span class="extras">(readonly)</span>
|
1040
|
+
|
1041
|
+
|
1042
|
+
|
1043
|
+
|
1044
|
+
|
1045
|
+
</h3><div class="docstring">
|
1046
|
+
<div class="discussion">
|
1047
|
+
|
1048
|
+
<p>Unique instance identifier for distributed coordination</p>
|
1049
|
+
|
1050
|
+
|
1051
|
+
</div>
|
1052
|
+
</div>
|
1053
|
+
<div class="tags">
|
1054
|
+
|
1055
|
+
<p class="tag_title">Returns:</p>
|
1056
|
+
<ul class="return">
|
1057
|
+
|
1058
|
+
<li>
|
1059
|
+
|
1060
|
+
|
1061
|
+
<span class='type'>(<tt>String</tt>)</span>
|
1062
|
+
|
1063
|
+
|
1064
|
+
|
1065
|
+
—
|
1066
|
+
<div class='inline'>
|
1067
|
+
<p>Hostname-PID identifier for this instance</p>
|
1068
|
+
</div>
|
1069
|
+
|
1070
|
+
</li>
|
1071
|
+
|
1072
|
+
</ul>
|
1073
|
+
|
1074
|
+
</div><table class="source_code">
|
1075
|
+
<tr>
|
1076
|
+
<td>
|
1077
|
+
<pre class="lines">
|
1078
|
+
|
1079
|
+
|
1080
|
+
69
|
1081
|
+
70
|
1082
|
+
71</pre>
|
1083
|
+
</td>
|
1084
|
+
<td>
|
1085
|
+
<pre class="code"><span class="info file"># File 'lib/tasker/telemetry/metrics_backend.rb', line 69</span>
|
1086
|
+
|
1087
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_instance_id'>instance_id</span>
|
1088
|
+
<span class='ivar'>@instance_id</span>
|
1089
|
+
<span class='kw'>end</span></pre>
|
1090
|
+
</td>
|
1091
|
+
</tr>
|
1092
|
+
</table>
|
1093
|
+
</div>
|
1094
|
+
|
1095
|
+
|
1096
|
+
<span id=""></span>
|
1097
|
+
<div class="method_details ">
|
1098
|
+
<h3 class="signature " id="metrics-instance_method">
|
1099
|
+
|
1100
|
+
#<strong>metrics</strong> ⇒ <tt>Concurrent::Hash</tt> <span class="extras">(readonly)</span>
|
1101
|
+
|
1102
|
+
|
1103
|
+
|
1104
|
+
|
1105
|
+
|
1106
|
+
</h3><div class="docstring">
|
1107
|
+
<div class="discussion">
|
1108
|
+
|
1109
|
+
<p>Core metric registry storing all active metrics Using ConcurrentHash for thread-safe operations without locks</p>
|
1110
|
+
|
1111
|
+
|
1112
|
+
</div>
|
1113
|
+
</div>
|
1114
|
+
<div class="tags">
|
1115
|
+
|
1116
|
+
<p class="tag_title">Returns:</p>
|
1117
|
+
<ul class="return">
|
1118
|
+
|
1119
|
+
<li>
|
1120
|
+
|
1121
|
+
|
1122
|
+
<span class='type'>(<tt>Concurrent::Hash</tt>)</span>
|
1123
|
+
|
1124
|
+
|
1125
|
+
|
1126
|
+
—
|
1127
|
+
<div class='inline'>
|
1128
|
+
<p>Thread-safe metric storage</p>
|
1129
|
+
</div>
|
1130
|
+
|
1131
|
+
</li>
|
1132
|
+
|
1133
|
+
</ul>
|
1134
|
+
|
1135
|
+
</div><table class="source_code">
|
1136
|
+
<tr>
|
1137
|
+
<td>
|
1138
|
+
<pre class="lines">
|
1139
|
+
|
1140
|
+
|
1141
|
+
49
|
1142
|
+
50
|
1143
|
+
51</pre>
|
1144
|
+
</td>
|
1145
|
+
<td>
|
1146
|
+
<pre class="code"><span class="info file"># File 'lib/tasker/telemetry/metrics_backend.rb', line 49</span>
|
1147
|
+
|
1148
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_metrics'>metrics</span>
|
1149
|
+
<span class='ivar'>@metrics</span>
|
1150
|
+
<span class='kw'>end</span></pre>
|
1151
|
+
</td>
|
1152
|
+
</tr>
|
1153
|
+
</table>
|
1154
|
+
</div>
|
1155
|
+
|
1156
|
+
|
1157
|
+
<span id=""></span>
|
1158
|
+
<div class="method_details ">
|
1159
|
+
<h3 class="signature " id="sync_config-instance_method">
|
1160
|
+
|
1161
|
+
#<strong>sync_config</strong> ⇒ <tt>Hash</tt> <span class="extras">(readonly)</span>
|
1162
|
+
|
1163
|
+
|
1164
|
+
|
1165
|
+
|
1166
|
+
|
1167
|
+
</h3><div class="docstring">
|
1168
|
+
<div class="discussion">
|
1169
|
+
|
1170
|
+
<p>Configuration for cache synchronization</p>
|
1171
|
+
|
1172
|
+
|
1173
|
+
</div>
|
1174
|
+
</div>
|
1175
|
+
<div class="tags">
|
1176
|
+
|
1177
|
+
<p class="tag_title">Returns:</p>
|
1178
|
+
<ul class="return">
|
1179
|
+
|
1180
|
+
<li>
|
1181
|
+
|
1182
|
+
|
1183
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
1184
|
+
|
1185
|
+
|
1186
|
+
|
1187
|
+
—
|
1188
|
+
<div class='inline'>
|
1189
|
+
<p>Sync configuration parameters</p>
|
1190
|
+
</div>
|
1191
|
+
|
1192
|
+
</li>
|
1193
|
+
|
1194
|
+
</ul>
|
1195
|
+
|
1196
|
+
</div><table class="source_code">
|
1197
|
+
<tr>
|
1198
|
+
<td>
|
1199
|
+
<pre class="lines">
|
1200
|
+
|
1201
|
+
|
1202
|
+
73
|
1203
|
+
74
|
1204
|
+
75</pre>
|
1205
|
+
</td>
|
1206
|
+
<td>
|
1207
|
+
<pre class="code"><span class="info file"># File 'lib/tasker/telemetry/metrics_backend.rb', line 73</span>
|
1208
|
+
|
1209
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_sync_config'>sync_config</span>
|
1210
|
+
<span class='ivar'>@sync_config</span>
|
1211
|
+
<span class='kw'>end</span></pre>
|
1212
|
+
</td>
|
1213
|
+
</tr>
|
1214
|
+
</table>
|
1215
|
+
</div>
|
1216
|
+
|
1217
|
+
|
1218
|
+
<span id=""></span>
|
1219
|
+
<div class="method_details ">
|
1220
|
+
<h3 class="signature " id="sync_strategy-instance_method">
|
1221
|
+
|
1222
|
+
#<strong>sync_strategy</strong> ⇒ <tt>Symbol</tt> <span class="extras">(readonly)</span>
|
1223
|
+
|
1224
|
+
|
1225
|
+
|
1226
|
+
|
1227
|
+
|
1228
|
+
</h3><div class="docstring">
|
1229
|
+
<div class="discussion">
|
1230
|
+
|
1231
|
+
<p>Selected sync strategy based on cache capabilities</p>
|
1232
|
+
|
1233
|
+
|
1234
|
+
</div>
|
1235
|
+
</div>
|
1236
|
+
<div class="tags">
|
1237
|
+
|
1238
|
+
<p class="tag_title">Returns:</p>
|
1239
|
+
<ul class="return">
|
1240
|
+
|
1241
|
+
<li>
|
1242
|
+
|
1243
|
+
|
1244
|
+
<span class='type'>(<tt>Symbol</tt>)</span>
|
1245
|
+
|
1246
|
+
|
1247
|
+
|
1248
|
+
—
|
1249
|
+
<div class='inline'>
|
1250
|
+
<p>One of :distributed_atomic, :distributed_basic, :local_only</p>
|
1251
|
+
</div>
|
1252
|
+
|
1253
|
+
</li>
|
1254
|
+
|
1255
|
+
</ul>
|
1256
|
+
|
1257
|
+
</div><table class="source_code">
|
1258
|
+
<tr>
|
1259
|
+
<td>
|
1260
|
+
<pre class="lines">
|
1261
|
+
|
1262
|
+
|
1263
|
+
65
|
1264
|
+
66
|
1265
|
+
67</pre>
|
1266
|
+
</td>
|
1267
|
+
<td>
|
1268
|
+
<pre class="code"><span class="info file"># File 'lib/tasker/telemetry/metrics_backend.rb', line 65</span>
|
1269
|
+
|
1270
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_sync_strategy'>sync_strategy</span>
|
1271
|
+
<span class='ivar'>@sync_strategy</span>
|
1272
|
+
<span class='kw'>end</span></pre>
|
1273
|
+
</td>
|
1274
|
+
</tr>
|
1275
|
+
</table>
|
1276
|
+
</div>
|
1277
|
+
|
1278
|
+
</div>
|
1279
|
+
|
1280
|
+
|
1281
|
+
<div id="instance_method_details" class="method_details_list">
|
1282
|
+
<h2>Instance Method Details</h2>
|
1283
|
+
|
1284
|
+
|
1285
|
+
<div class="method_details first">
|
1286
|
+
<h3 class="signature first" id="all_metrics-instance_method">
|
1287
|
+
|
1288
|
+
#<strong>all_metrics</strong> ⇒ <tt>Hash</tt>
|
1289
|
+
|
1290
|
+
|
1291
|
+
|
1292
|
+
|
1293
|
+
|
1294
|
+
</h3><div class="docstring">
|
1295
|
+
<div class="discussion">
|
1296
|
+
|
1297
|
+
<p>Get all registered metrics</p>
|
1298
|
+
|
1299
|
+
<p>Returns a thread-safe snapshot of all current metrics for export to monitoring systems like Prometheus.</p>
|
1300
|
+
|
1301
|
+
|
1302
|
+
</div>
|
1303
|
+
</div>
|
1304
|
+
<div class="tags">
|
1305
|
+
|
1306
|
+
<p class="tag_title">Returns:</p>
|
1307
|
+
<ul class="return">
|
1308
|
+
|
1309
|
+
<li>
|
1310
|
+
|
1311
|
+
|
1312
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
1313
|
+
|
1314
|
+
|
1315
|
+
|
1316
|
+
—
|
1317
|
+
<div class='inline'>
|
1318
|
+
<p>All metrics keyed by metric key</p>
|
1319
|
+
</div>
|
1320
|
+
|
1321
|
+
</li>
|
1322
|
+
|
1323
|
+
</ul>
|
1324
|
+
|
1325
|
+
</div><table class="source_code">
|
1326
|
+
<tr>
|
1327
|
+
<td>
|
1328
|
+
<pre class="lines">
|
1329
|
+
|
1330
|
+
|
1331
|
+
319
|
1332
|
+
320
|
1333
|
+
321
|
1334
|
+
322
|
1335
|
+
323</pre>
|
1336
|
+
</td>
|
1337
|
+
<td>
|
1338
|
+
<pre class="code"><span class="info file"># File 'lib/tasker/telemetry/metrics_backend.rb', line 319</span>
|
1339
|
+
|
1340
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_all_metrics'>all_metrics</span>
|
1341
|
+
<span class='ivar'>@metrics</span><span class='period'>.</span><span class='id identifier rubyid_each_with_object'>each_with_object</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_metric'>metric</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='id identifier rubyid_result'>result</span><span class='op'>|</span>
|
1342
|
+
<span class='id identifier rubyid_result'>result</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_metric'>metric</span>
|
1343
|
+
<span class='kw'>end</span>
|
1344
|
+
<span class='kw'>end</span></pre>
|
1345
|
+
</td>
|
1346
|
+
</tr>
|
1347
|
+
</table>
|
1348
|
+
</div>
|
1349
|
+
|
1350
|
+
<div class="method_details ">
|
1351
|
+
<h3 class="signature " id="clear!-instance_method">
|
1352
|
+
|
1353
|
+
#<strong>clear!</strong> ⇒ <tt>Integer</tt>
|
1354
|
+
|
1355
|
+
|
1356
|
+
|
1357
|
+
|
1358
|
+
|
1359
|
+
</h3><div class="docstring">
|
1360
|
+
<div class="discussion">
|
1361
|
+
|
1362
|
+
<p>Clear all metrics (primarily for testing)</p>
|
1363
|
+
|
1364
|
+
|
1365
|
+
</div>
|
1366
|
+
</div>
|
1367
|
+
<div class="tags">
|
1368
|
+
|
1369
|
+
<p class="tag_title">Returns:</p>
|
1370
|
+
<ul class="return">
|
1371
|
+
|
1372
|
+
<li>
|
1373
|
+
|
1374
|
+
|
1375
|
+
<span class='type'>(<tt>Integer</tt>)</span>
|
1376
|
+
|
1377
|
+
|
1378
|
+
|
1379
|
+
—
|
1380
|
+
<div class='inline'>
|
1381
|
+
<p>Number of metrics cleared</p>
|
1382
|
+
</div>
|
1383
|
+
|
1384
|
+
</li>
|
1385
|
+
|
1386
|
+
</ul>
|
1387
|
+
|
1388
|
+
</div><table class="source_code">
|
1389
|
+
<tr>
|
1390
|
+
<td>
|
1391
|
+
<pre class="lines">
|
1392
|
+
|
1393
|
+
|
1394
|
+
359
|
1395
|
+
360
|
1396
|
+
361
|
1397
|
+
362
|
1398
|
+
363</pre>
|
1399
|
+
</td>
|
1400
|
+
<td>
|
1401
|
+
<pre class="code"><span class="info file"># File 'lib/tasker/telemetry/metrics_backend.rb', line 359</span>
|
1402
|
+
|
1403
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_clear!'>clear!</span>
|
1404
|
+
<span class='id identifier rubyid_cleared_count'>cleared_count</span> <span class='op'>=</span> <span class='ivar'>@metrics</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span>
|
1405
|
+
<span class='ivar'>@metrics</span><span class='period'>.</span><span class='id identifier rubyid_clear'>clear</span>
|
1406
|
+
<span class='id identifier rubyid_cleared_count'>cleared_count</span>
|
1407
|
+
<span class='kw'>end</span></pre>
|
1408
|
+
</td>
|
1409
|
+
</tr>
|
1410
|
+
</table>
|
1411
|
+
</div>
|
1412
|
+
|
1413
|
+
<div class="method_details ">
|
1414
|
+
<h3 class="signature " id="counter-instance_method">
|
1415
|
+
|
1416
|
+
#<strong>counter</strong>(name, **labels) ⇒ <tt><span class='object_link'><a href="MetricTypes/Counter.html" title="Tasker::Telemetry::MetricTypes::Counter (class)">MetricTypes::Counter</a></span></tt>
|
1417
|
+
|
1418
|
+
|
1419
|
+
|
1420
|
+
|
1421
|
+
|
1422
|
+
</h3><div class="docstring">
|
1423
|
+
<div class="discussion">
|
1424
|
+
|
1425
|
+
<p>Get or create a counter metric</p>
|
1426
|
+
|
1427
|
+
<p>Counters are thread-safe and support only increment operations. They’re ideal for counting events, requests, errors, etc.</p>
|
1428
|
+
|
1429
|
+
|
1430
|
+
</div>
|
1431
|
+
</div>
|
1432
|
+
<div class="tags">
|
1433
|
+
|
1434
|
+
<div class="examples">
|
1435
|
+
<h4 class="tag_title">Examples:</h4>
|
1436
|
+
|
1437
|
+
|
1438
|
+
<pre class="example code"><code><span class='id identifier rubyid_counter'>counter</span> <span class='op'>=</span> <span class='id identifier rubyid_backend'>backend</span><span class='period'>.</span><span class='id identifier rubyid_counter'>counter</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>http_requests_total</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>endpoint:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>/api/tasks</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
1439
|
+
<span class='id identifier rubyid_counter'>counter</span><span class='period'>.</span><span class='id identifier rubyid_increment'>increment</span><span class='lparen'>(</span><span class='int'>5</span><span class='rparen'>)</span></code></pre>
|
1440
|
+
|
1441
|
+
</div>
|
1442
|
+
<p class="tag_title">Parameters:</p>
|
1443
|
+
<ul class="param">
|
1444
|
+
|
1445
|
+
<li>
|
1446
|
+
|
1447
|
+
<span class='name'>name</span>
|
1448
|
+
|
1449
|
+
|
1450
|
+
<span class='type'>(<tt>String</tt>)</span>
|
1451
|
+
|
1452
|
+
|
1453
|
+
|
1454
|
+
—
|
1455
|
+
<div class='inline'>
|
1456
|
+
<p>The metric name</p>
|
1457
|
+
</div>
|
1458
|
+
|
1459
|
+
</li>
|
1460
|
+
|
1461
|
+
<li>
|
1462
|
+
|
1463
|
+
<span class='name'>labels</span>
|
1464
|
+
|
1465
|
+
|
1466
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
1467
|
+
|
1468
|
+
|
1469
|
+
|
1470
|
+
—
|
1471
|
+
<div class='inline'>
|
1472
|
+
<p>Optional dimensional labels</p>
|
1473
|
+
</div>
|
1474
|
+
|
1475
|
+
</li>
|
1476
|
+
|
1477
|
+
</ul>
|
1478
|
+
|
1479
|
+
<p class="tag_title">Returns:</p>
|
1480
|
+
<ul class="return">
|
1481
|
+
|
1482
|
+
<li>
|
1483
|
+
|
1484
|
+
|
1485
|
+
<span class='type'>(<tt><span class='object_link'><a href="MetricTypes/Counter.html" title="Tasker::Telemetry::MetricTypes::Counter (class)">MetricTypes::Counter</a></span></tt>)</span>
|
1486
|
+
|
1487
|
+
|
1488
|
+
|
1489
|
+
—
|
1490
|
+
<div class='inline'>
|
1491
|
+
<p>The counter instance</p>
|
1492
|
+
</div>
|
1493
|
+
|
1494
|
+
</li>
|
1495
|
+
|
1496
|
+
</ul>
|
1497
|
+
<p class="tag_title">Raises:</p>
|
1498
|
+
<ul class="raise">
|
1499
|
+
|
1500
|
+
<li>
|
1501
|
+
|
1502
|
+
|
1503
|
+
<span class='type'>(<tt>ArgumentError</tt>)</span>
|
1504
|
+
|
1505
|
+
|
1506
|
+
|
1507
|
+
—
|
1508
|
+
<div class='inline'>
|
1509
|
+
<p>If name is invalid</p>
|
1510
|
+
</div>
|
1511
|
+
|
1512
|
+
</li>
|
1513
|
+
|
1514
|
+
</ul>
|
1515
|
+
|
1516
|
+
</div><table class="source_code">
|
1517
|
+
<tr>
|
1518
|
+
<td>
|
1519
|
+
<pre class="lines">
|
1520
|
+
|
1521
|
+
|
1522
|
+
130
|
1523
|
+
131
|
1524
|
+
132
|
1525
|
+
133
|
1526
|
+
134</pre>
|
1527
|
+
</td>
|
1528
|
+
<td>
|
1529
|
+
<pre class="code"><span class="info file"># File 'lib/tasker/telemetry/metrics_backend.rb', line 130</span>
|
1530
|
+
|
1531
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_counter'>counter</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_labels'>labels</span><span class='rparen'>)</span>
|
1532
|
+
<span class='id identifier rubyid_get_or_create_metric'>get_or_create_metric</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_labels'>labels</span><span class='comma'>,</span> <span class='symbol'>:counter</span><span class='rparen'>)</span> <span class='kw'>do</span>
|
1533
|
+
<span class='const'><span class='object_link'><a href="MetricTypes.html" title="Tasker::Telemetry::MetricTypes (module)">MetricTypes</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="MetricTypes/Counter.html" title="Tasker::Telemetry::MetricTypes::Counter (class)">Counter</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="MetricTypes/Counter.html#initialize-instance_method" title="Tasker::Telemetry::MetricTypes::Counter#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='label'>labels:</span> <span class='id identifier rubyid_labels'>labels</span><span class='rparen'>)</span>
|
1534
|
+
<span class='kw'>end</span>
|
1535
|
+
<span class='kw'>end</span></pre>
|
1536
|
+
</td>
|
1537
|
+
</tr>
|
1538
|
+
</table>
|
1539
|
+
</div>
|
1540
|
+
|
1541
|
+
<div class="method_details ">
|
1542
|
+
<h3 class="signature " id="export-instance_method">
|
1543
|
+
|
1544
|
+
#<strong>export</strong> ⇒ <tt>Hash</tt>
|
1545
|
+
|
1546
|
+
|
1547
|
+
|
1548
|
+
|
1549
|
+
|
1550
|
+
</h3><div class="docstring">
|
1551
|
+
<div class="discussion">
|
1552
|
+
|
1553
|
+
<p>Export all metrics to a format suitable for monitoring systems</p>
|
1554
|
+
|
1555
|
+
<p>Provides a comprehensive export of all metric data including metadata, current values, and statistical information.</p>
|
1556
|
+
|
1557
|
+
|
1558
|
+
</div>
|
1559
|
+
</div>
|
1560
|
+
<div class="tags">
|
1561
|
+
|
1562
|
+
<p class="tag_title">Returns:</p>
|
1563
|
+
<ul class="return">
|
1564
|
+
|
1565
|
+
<li>
|
1566
|
+
|
1567
|
+
|
1568
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
1569
|
+
|
1570
|
+
|
1571
|
+
|
1572
|
+
—
|
1573
|
+
<div class='inline'>
|
1574
|
+
<p>Comprehensive metric export data</p>
|
1575
|
+
</div>
|
1576
|
+
|
1577
|
+
</li>
|
1578
|
+
|
1579
|
+
</ul>
|
1580
|
+
|
1581
|
+
</div><table class="source_code">
|
1582
|
+
<tr>
|
1583
|
+
<td>
|
1584
|
+
<pre class="lines">
|
1585
|
+
|
1586
|
+
|
1587
|
+
331
|
1588
|
+
332
|
1589
|
+
333
|
1590
|
+
334
|
1591
|
+
335
|
1592
|
+
336
|
1593
|
+
337
|
1594
|
+
338</pre>
|
1595
|
+
</td>
|
1596
|
+
<td>
|
1597
|
+
<pre class="code"><span class="info file"># File 'lib/tasker/telemetry/metrics_backend.rb', line 331</span>
|
1598
|
+
|
1599
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_export'>export</span>
|
1600
|
+
<span class='lbrace'>{</span>
|
1601
|
+
<span class='label'>timestamp:</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_current'>current</span><span class='comma'>,</span>
|
1602
|
+
<span class='label'>backend_created_at:</span> <span class='ivar'>@created_at</span><span class='comma'>,</span>
|
1603
|
+
<span class='label'>total_metrics:</span> <span class='ivar'>@metrics</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span><span class='comma'>,</span>
|
1604
|
+
<span class='label'>metrics:</span> <span class='id identifier rubyid_all_metrics'>all_metrics</span><span class='period'>.</span><span class='id identifier rubyid_transform_values'>transform_values</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:to_h</span><span class='rparen'>)</span>
|
1605
|
+
<span class='rbrace'>}</span>
|
1606
|
+
<span class='kw'>end</span></pre>
|
1607
|
+
</td>
|
1608
|
+
</tr>
|
1609
|
+
</table>
|
1610
|
+
</div>
|
1611
|
+
|
1612
|
+
<div class="method_details ">
|
1613
|
+
<h3 class="signature " id="export_distributed_metrics-instance_method">
|
1614
|
+
|
1615
|
+
#<strong>export_distributed_metrics</strong>(include_instances: false) ⇒ <tt>Hash</tt>
|
1616
|
+
|
1617
|
+
|
1618
|
+
|
1619
|
+
|
1620
|
+
|
1621
|
+
</h3><div class="docstring">
|
1622
|
+
<div class="discussion">
|
1623
|
+
|
1624
|
+
<p>Export metrics with distributed coordination when supported</p>
|
1625
|
+
|
1626
|
+
<p>This method aggregates metrics across containers when possible, falls back to local export for limited cache stores.</p>
|
1627
|
+
|
1628
|
+
|
1629
|
+
</div>
|
1630
|
+
</div>
|
1631
|
+
<div class="tags">
|
1632
|
+
<p class="tag_title">Parameters:</p>
|
1633
|
+
<ul class="param">
|
1634
|
+
|
1635
|
+
<li>
|
1636
|
+
|
1637
|
+
<span class='name'>include_instances</span>
|
1638
|
+
|
1639
|
+
|
1640
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
1641
|
+
|
1642
|
+
|
1643
|
+
<em class="default">(defaults to: <tt>false</tt>)</em>
|
1644
|
+
|
1645
|
+
|
1646
|
+
—
|
1647
|
+
<div class='inline'>
|
1648
|
+
<p>Whether to include per-instance metrics</p>
|
1649
|
+
</div>
|
1650
|
+
|
1651
|
+
</li>
|
1652
|
+
|
1653
|
+
</ul>
|
1654
|
+
|
1655
|
+
<p class="tag_title">Returns:</p>
|
1656
|
+
<ul class="return">
|
1657
|
+
|
1658
|
+
<li>
|
1659
|
+
|
1660
|
+
|
1661
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
1662
|
+
|
1663
|
+
|
1664
|
+
|
1665
|
+
—
|
1666
|
+
<div class='inline'>
|
1667
|
+
<p>Export data with aggregated metrics when available</p>
|
1668
|
+
</div>
|
1669
|
+
|
1670
|
+
</li>
|
1671
|
+
|
1672
|
+
</ul>
|
1673
|
+
|
1674
|
+
</div><table class="source_code">
|
1675
|
+
<tr>
|
1676
|
+
<td>
|
1677
|
+
<pre class="lines">
|
1678
|
+
|
1679
|
+
|
1680
|
+
228
|
1681
|
+
229
|
1682
|
+
230
|
1683
|
+
231
|
1684
|
+
232
|
1685
|
+
233
|
1686
|
+
234
|
1687
|
+
235
|
1688
|
+
236
|
1689
|
+
237</pre>
|
1690
|
+
</td>
|
1691
|
+
<td>
|
1692
|
+
<pre class="code"><span class="info file"># File 'lib/tasker/telemetry/metrics_backend.rb', line 228</span>
|
1693
|
+
|
1694
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_export_distributed_metrics'>export_distributed_metrics</span><span class='lparen'>(</span><span class='label'>include_instances:</span> <span class='kw'>false</span><span class='rparen'>)</span>
|
1695
|
+
<span class='kw'>case</span> <span class='ivar'>@sync_strategy</span>
|
1696
|
+
<span class='kw'>when</span> <span class='symbol'>:distributed_atomic</span><span class='comma'>,</span> <span class='symbol'>:distributed_basic</span>
|
1697
|
+
<span class='id identifier rubyid_aggregate_from_distributed_cache'>aggregate_from_distributed_cache</span><span class='lparen'>(</span><span class='label'>include_instances:</span> <span class='id identifier rubyid_include_instances'>include_instances</span><span class='rparen'>)</span>
|
1698
|
+
<span class='kw'>when</span> <span class='symbol'>:local_only</span>
|
1699
|
+
<span class='id identifier rubyid_export_local_metrics_with_warning'>export_local_metrics_with_warning</span>
|
1700
|
+
<span class='kw'>else</span>
|
1701
|
+
<span class='id identifier rubyid_export'>export</span> <span class='comment'># Fallback to standard local export
|
1702
|
+
</span> <span class='kw'>end</span>
|
1703
|
+
<span class='kw'>end</span></pre>
|
1704
|
+
</td>
|
1705
|
+
</tr>
|
1706
|
+
</table>
|
1707
|
+
</div>
|
1708
|
+
|
1709
|
+
<div class="method_details ">
|
1710
|
+
<h3 class="signature " id="gauge-instance_method">
|
1711
|
+
|
1712
|
+
#<strong>gauge</strong>(name, **labels) ⇒ <tt><span class='object_link'><a href="MetricTypes/Gauge.html" title="Tasker::Telemetry::MetricTypes::Gauge (class)">MetricTypes::Gauge</a></span></tt>
|
1713
|
+
|
1714
|
+
|
1715
|
+
|
1716
|
+
|
1717
|
+
|
1718
|
+
</h3><div class="docstring">
|
1719
|
+
<div class="discussion">
|
1720
|
+
|
1721
|
+
<p>Get or create a gauge metric</p>
|
1722
|
+
|
1723
|
+
<p>Gauges are thread-safe and support set, increment, and decrement operations. They’re ideal for values that fluctuate like connections, queue depth, etc.</p>
|
1724
|
+
|
1725
|
+
|
1726
|
+
</div>
|
1727
|
+
</div>
|
1728
|
+
<div class="tags">
|
1729
|
+
|
1730
|
+
<div class="examples">
|
1731
|
+
<h4 class="tag_title">Examples:</h4>
|
1732
|
+
|
1733
|
+
|
1734
|
+
<pre class="example code"><code><span class='id identifier rubyid_gauge'>gauge</span> <span class='op'>=</span> <span class='id identifier rubyid_backend'>backend</span><span class='period'>.</span><span class='id identifier rubyid_gauge'>gauge</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>active_connections</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>service:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>api</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
1735
|
+
<span class='id identifier rubyid_gauge'>gauge</span><span class='period'>.</span><span class='id identifier rubyid_set'>set</span><span class='lparen'>(</span><span class='int'>100</span><span class='rparen'>)</span>
|
1736
|
+
<span class='id identifier rubyid_gauge'>gauge</span><span class='period'>.</span><span class='id identifier rubyid_increment'>increment</span><span class='lparen'>(</span><span class='int'>5</span><span class='rparen'>)</span></code></pre>
|
1737
|
+
|
1738
|
+
</div>
|
1739
|
+
<p class="tag_title">Parameters:</p>
|
1740
|
+
<ul class="param">
|
1741
|
+
|
1742
|
+
<li>
|
1743
|
+
|
1744
|
+
<span class='name'>name</span>
|
1745
|
+
|
1746
|
+
|
1747
|
+
<span class='type'>(<tt>String</tt>)</span>
|
1748
|
+
|
1749
|
+
|
1750
|
+
|
1751
|
+
—
|
1752
|
+
<div class='inline'>
|
1753
|
+
<p>The metric name</p>
|
1754
|
+
</div>
|
1755
|
+
|
1756
|
+
</li>
|
1757
|
+
|
1758
|
+
<li>
|
1759
|
+
|
1760
|
+
<span class='name'>labels</span>
|
1761
|
+
|
1762
|
+
|
1763
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
1764
|
+
|
1765
|
+
|
1766
|
+
|
1767
|
+
—
|
1768
|
+
<div class='inline'>
|
1769
|
+
<p>Optional dimensional labels</p>
|
1770
|
+
</div>
|
1771
|
+
|
1772
|
+
</li>
|
1773
|
+
|
1774
|
+
</ul>
|
1775
|
+
|
1776
|
+
<p class="tag_title">Returns:</p>
|
1777
|
+
<ul class="return">
|
1778
|
+
|
1779
|
+
<li>
|
1780
|
+
|
1781
|
+
|
1782
|
+
<span class='type'>(<tt><span class='object_link'><a href="MetricTypes/Gauge.html" title="Tasker::Telemetry::MetricTypes::Gauge (class)">MetricTypes::Gauge</a></span></tt>)</span>
|
1783
|
+
|
1784
|
+
|
1785
|
+
|
1786
|
+
—
|
1787
|
+
<div class='inline'>
|
1788
|
+
<p>The gauge instance</p>
|
1789
|
+
</div>
|
1790
|
+
|
1791
|
+
</li>
|
1792
|
+
|
1793
|
+
</ul>
|
1794
|
+
<p class="tag_title">Raises:</p>
|
1795
|
+
<ul class="raise">
|
1796
|
+
|
1797
|
+
<li>
|
1798
|
+
|
1799
|
+
|
1800
|
+
<span class='type'>(<tt>ArgumentError</tt>)</span>
|
1801
|
+
|
1802
|
+
|
1803
|
+
|
1804
|
+
—
|
1805
|
+
<div class='inline'>
|
1806
|
+
<p>If name is invalid</p>
|
1807
|
+
</div>
|
1808
|
+
|
1809
|
+
</li>
|
1810
|
+
|
1811
|
+
</ul>
|
1812
|
+
|
1813
|
+
</div><table class="source_code">
|
1814
|
+
<tr>
|
1815
|
+
<td>
|
1816
|
+
<pre class="lines">
|
1817
|
+
|
1818
|
+
|
1819
|
+
150
|
1820
|
+
151
|
1821
|
+
152
|
1822
|
+
153
|
1823
|
+
154</pre>
|
1824
|
+
</td>
|
1825
|
+
<td>
|
1826
|
+
<pre class="code"><span class="info file"># File 'lib/tasker/telemetry/metrics_backend.rb', line 150</span>
|
1827
|
+
|
1828
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_gauge'>gauge</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_labels'>labels</span><span class='rparen'>)</span>
|
1829
|
+
<span class='id identifier rubyid_get_or_create_metric'>get_or_create_metric</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_labels'>labels</span><span class='comma'>,</span> <span class='symbol'>:gauge</span><span class='rparen'>)</span> <span class='kw'>do</span>
|
1830
|
+
<span class='const'><span class='object_link'><a href="MetricTypes.html" title="Tasker::Telemetry::MetricTypes (module)">MetricTypes</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="MetricTypes/Gauge.html" title="Tasker::Telemetry::MetricTypes::Gauge (class)">Gauge</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="MetricTypes/Gauge.html#initialize-instance_method" title="Tasker::Telemetry::MetricTypes::Gauge#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='label'>labels:</span> <span class='id identifier rubyid_labels'>labels</span><span class='rparen'>)</span>
|
1831
|
+
<span class='kw'>end</span>
|
1832
|
+
<span class='kw'>end</span></pre>
|
1833
|
+
</td>
|
1834
|
+
</tr>
|
1835
|
+
</table>
|
1836
|
+
</div>
|
1837
|
+
|
1838
|
+
<div class="method_details ">
|
1839
|
+
<h3 class="signature " id="handle_event-instance_method">
|
1840
|
+
|
1841
|
+
#<strong>handle_event</strong>(event_name, payload = {}) ⇒ <tt>Boolean</tt>
|
1842
|
+
|
1843
|
+
|
1844
|
+
|
1845
|
+
|
1846
|
+
|
1847
|
+
</h3><div class="docstring">
|
1848
|
+
<div class="discussion">
|
1849
|
+
|
1850
|
+
<p>Handle an event from EventRouter and collect appropriate metrics</p>
|
1851
|
+
|
1852
|
+
<p>This method is called by EventRouter when an event should be routed to the metrics backend. It automatically creates and updates metrics based on event type and payload.</p>
|
1853
|
+
|
1854
|
+
|
1855
|
+
</div>
|
1856
|
+
</div>
|
1857
|
+
<div class="tags">
|
1858
|
+
|
1859
|
+
<div class="examples">
|
1860
|
+
<h4 class="tag_title">Examples:</h4>
|
1861
|
+
|
1862
|
+
|
1863
|
+
<h5 class="example_title"><div class='inline'>
|
1864
|
+
<p>Automatic usage via EventRouter</p>
|
1865
|
+
</div></h5>
|
1866
|
+
|
1867
|
+
<pre class="example code"><code><span class='comment'># EventRouter calls this automatically:
|
1868
|
+
</span><span class='id identifier rubyid_backend'>backend</span><span class='period'>.</span><span class='id identifier rubyid_handle_event'>handle_event</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>task.completed</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='lbrace'>{</span>
|
1869
|
+
<span class='label'>task_id:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>123</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
1870
|
+
<span class='label'>duration:</span> <span class='float'>2.45</span><span class='comma'>,</span>
|
1871
|
+
<span class='label'>status:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>success</span><span class='tstring_end'>'</span></span>
|
1872
|
+
<span class='rbrace'>}</span><span class='rparen'>)</span></code></pre>
|
1873
|
+
|
1874
|
+
</div>
|
1875
|
+
<p class="tag_title">Parameters:</p>
|
1876
|
+
<ul class="param">
|
1877
|
+
|
1878
|
+
<li>
|
1879
|
+
|
1880
|
+
<span class='name'>event_name</span>
|
1881
|
+
|
1882
|
+
|
1883
|
+
<span class='type'>(<tt>String</tt>)</span>
|
1884
|
+
|
1885
|
+
|
1886
|
+
|
1887
|
+
—
|
1888
|
+
<div class='inline'>
|
1889
|
+
<p>The lifecycle event name</p>
|
1890
|
+
</div>
|
1891
|
+
|
1892
|
+
</li>
|
1893
|
+
|
1894
|
+
<li>
|
1895
|
+
|
1896
|
+
<span class='name'>payload</span>
|
1897
|
+
|
1898
|
+
|
1899
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
1900
|
+
|
1901
|
+
|
1902
|
+
<em class="default">(defaults to: <tt>{}</tt>)</em>
|
1903
|
+
|
1904
|
+
|
1905
|
+
—
|
1906
|
+
<div class='inline'>
|
1907
|
+
<p>Event payload with metric data</p>
|
1908
|
+
</div>
|
1909
|
+
|
1910
|
+
</li>
|
1911
|
+
|
1912
|
+
</ul>
|
1913
|
+
|
1914
|
+
<p class="tag_title">Returns:</p>
|
1915
|
+
<ul class="return">
|
1916
|
+
|
1917
|
+
<li>
|
1918
|
+
|
1919
|
+
|
1920
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
1921
|
+
|
1922
|
+
|
1923
|
+
|
1924
|
+
—
|
1925
|
+
<div class='inline'>
|
1926
|
+
<p>True if metrics were collected successfully</p>
|
1927
|
+
</div>
|
1928
|
+
|
1929
|
+
</li>
|
1930
|
+
|
1931
|
+
</ul>
|
1932
|
+
|
1933
|
+
</div><table class="source_code">
|
1934
|
+
<tr>
|
1935
|
+
<td>
|
1936
|
+
<pre class="lines">
|
1937
|
+
|
1938
|
+
|
1939
|
+
257
|
1940
|
+
258
|
1941
|
+
259
|
1942
|
+
260
|
1943
|
+
261
|
1944
|
+
262
|
1945
|
+
263
|
1946
|
+
264
|
1947
|
+
265
|
1948
|
+
266
|
1949
|
+
267
|
1950
|
+
268
|
1951
|
+
269
|
1952
|
+
270
|
1953
|
+
271
|
1954
|
+
272
|
1955
|
+
273
|
1956
|
+
274
|
1957
|
+
275
|
1958
|
+
276
|
1959
|
+
277
|
1960
|
+
278
|
1961
|
+
279
|
1962
|
+
280
|
1963
|
+
281
|
1964
|
+
282
|
1965
|
+
283
|
1966
|
+
284
|
1967
|
+
285
|
1968
|
+
286
|
1969
|
+
287
|
1970
|
+
288
|
1971
|
+
289
|
1972
|
+
290
|
1973
|
+
291
|
1974
|
+
292
|
1975
|
+
293
|
1976
|
+
294
|
1977
|
+
295
|
1978
|
+
296
|
1979
|
+
297
|
1980
|
+
298
|
1981
|
+
299
|
1982
|
+
300
|
1983
|
+
301
|
1984
|
+
302
|
1985
|
+
303
|
1986
|
+
304
|
1987
|
+
305
|
1988
|
+
306
|
1989
|
+
307
|
1990
|
+
308
|
1991
|
+
309
|
1992
|
+
310
|
1993
|
+
311</pre>
|
1994
|
+
</td>
|
1995
|
+
<td>
|
1996
|
+
<pre class="code"><span class="info file"># File 'lib/tasker/telemetry/metrics_backend.rb', line 257</span>
|
1997
|
+
|
1998
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_handle_event'>handle_event</span><span class='lparen'>(</span><span class='id identifier rubyid_event_name'>event_name</span><span class='comma'>,</span> <span class='id identifier rubyid_payload'>payload</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
1999
|
+
<span class='kw'>return</span> <span class='kw'>false</span> <span class='kw'>unless</span> <span class='id identifier rubyid_payload'>payload</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Hash</span><span class='rparen'>)</span>
|
2000
|
+
|
2001
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_event_name'>event_name</span>
|
2002
|
+
<span class='kw'>when</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>\.started$</span><span class='regexp_end'>/</span></span>
|
2003
|
+
<span class='comment'># Task/Step started events -> increment counter
|
2004
|
+
</span> <span class='id identifier rubyid_counter'>counter</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_extract_entity_type'>extract_entity_type</span><span class='lparen'>(</span><span class='id identifier rubyid_event_name'>event_name</span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_content'>_started_total</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_extract_labels'>extract_labels</span><span class='lparen'>(</span><span class='id identifier rubyid_payload'>payload</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_increment'>increment</span>
|
2005
|
+
|
2006
|
+
<span class='kw'>when</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>\.completed$</span><span class='regexp_end'>/</span></span>
|
2007
|
+
<span class='comment'># Task/Step completed events -> counter + duration histogram
|
2008
|
+
</span> <span class='id identifier rubyid_entity_type'>entity_type</span> <span class='op'>=</span> <span class='id identifier rubyid_extract_entity_type'>extract_entity_type</span><span class='lparen'>(</span><span class='id identifier rubyid_event_name'>event_name</span><span class='rparen'>)</span>
|
2009
|
+
<span class='id identifier rubyid_labels'>labels</span> <span class='op'>=</span> <span class='id identifier rubyid_extract_labels'>extract_labels</span><span class='lparen'>(</span><span class='id identifier rubyid_payload'>payload</span><span class='rparen'>)</span>
|
2010
|
+
|
2011
|
+
<span class='id identifier rubyid_counter'>counter</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_entity_type'>entity_type</span><span class='embexpr_end'>}</span><span class='tstring_content'>_completed_total</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_labels'>labels</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_increment'>increment</span>
|
2012
|
+
|
2013
|
+
<span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_duration'>duration</span> <span class='op'>=</span> <span class='id identifier rubyid_extract_duration'>extract_duration</span><span class='lparen'>(</span><span class='id identifier rubyid_payload'>payload</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
2014
|
+
<span class='id identifier rubyid_histogram'>histogram</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_entity_type'>entity_type</span><span class='embexpr_end'>}</span><span class='tstring_content'>_duration_seconds</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_labels'>labels</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_observe'>observe</span><span class='lparen'>(</span><span class='id identifier rubyid_duration'>duration</span><span class='rparen'>)</span>
|
2015
|
+
<span class='kw'>end</span>
|
2016
|
+
|
2017
|
+
<span class='kw'>when</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>\.failed$</span><span class='regexp_end'>/</span></span>
|
2018
|
+
<span class='comment'># Task/Step failed events -> error counter + duration histogram
|
2019
|
+
</span> <span class='id identifier rubyid_entity_type'>entity_type</span> <span class='op'>=</span> <span class='id identifier rubyid_extract_entity_type'>extract_entity_type</span><span class='lparen'>(</span><span class='id identifier rubyid_event_name'>event_name</span><span class='rparen'>)</span>
|
2020
|
+
<span class='id identifier rubyid_labels'>labels</span> <span class='op'>=</span> <span class='id identifier rubyid_extract_labels'>extract_labels</span><span class='lparen'>(</span><span class='id identifier rubyid_payload'>payload</span><span class='rparen'>)</span>
|
2021
|
+
|
2022
|
+
<span class='id identifier rubyid_counter'>counter</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_entity_type'>entity_type</span><span class='embexpr_end'>}</span><span class='tstring_content'>_failed_total</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_labels'>labels</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_increment'>increment</span>
|
2023
|
+
|
2024
|
+
<span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_duration'>duration</span> <span class='op'>=</span> <span class='id identifier rubyid_extract_duration'>extract_duration</span><span class='lparen'>(</span><span class='id identifier rubyid_payload'>payload</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
2025
|
+
<span class='id identifier rubyid_histogram'>histogram</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_entity_type'>entity_type</span><span class='embexpr_end'>}</span><span class='tstring_content'>_duration_seconds</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_labels'>labels</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_observe'>observe</span><span class='lparen'>(</span><span class='id identifier rubyid_duration'>duration</span><span class='rparen'>)</span>
|
2026
|
+
<span class='kw'>end</span>
|
2027
|
+
|
2028
|
+
<span class='kw'>when</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>\.cancelled$</span><span class='regexp_end'>/</span></span>
|
2029
|
+
<span class='comment'># Task/Step cancelled events -> cancellation counter
|
2030
|
+
</span> <span class='id identifier rubyid_counter'>counter</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_extract_entity_type'>extract_entity_type</span><span class='lparen'>(</span><span class='id identifier rubyid_event_name'>event_name</span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_content'>_cancelled_total</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_extract_labels'>extract_labels</span><span class='lparen'>(</span><span class='id identifier rubyid_payload'>payload</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_increment'>increment</span>
|
2031
|
+
|
2032
|
+
<span class='kw'>when</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>workflow\.iteration</span><span class='regexp_end'>/</span></span>
|
2033
|
+
<span class='comment'># Workflow iteration events -> gauge for active tasks
|
2034
|
+
</span> <span class='id identifier rubyid_gauge'>gauge</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>workflow_active_tasks</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_set'>set</span><span class='lparen'>(</span><span class='id identifier rubyid_payload'>payload</span><span class='lbracket'>[</span><span class='symbol'>:active_task_count</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_payload'>payload</span><span class='lbracket'>[</span><span class='symbol'>:active_task_count</span><span class='rbracket'>]</span>
|
2035
|
+
|
2036
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_payload'>payload</span><span class='lbracket'>[</span><span class='symbol'>:iteration_duration</span><span class='rbracket'>]</span>
|
2037
|
+
<span class='id identifier rubyid_histogram'>histogram</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>workflow_iteration_duration_seconds</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_observe'>observe</span><span class='lparen'>(</span><span class='id identifier rubyid_payload'>payload</span><span class='lbracket'>[</span><span class='symbol'>:iteration_duration</span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
2038
|
+
<span class='kw'>end</span>
|
2039
|
+
|
2040
|
+
<span class='kw'>when</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>system\.health</span><span class='regexp_end'>/</span></span>
|
2041
|
+
<span class='comment'># System health events -> health gauges
|
2042
|
+
</span> <span class='id identifier rubyid_gauge'>gauge</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>system_healthy_tasks</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_set'>set</span><span class='lparen'>(</span><span class='id identifier rubyid_payload'>payload</span><span class='lbracket'>[</span><span class='symbol'>:healthy_task_count</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_payload'>payload</span><span class='lbracket'>[</span><span class='symbol'>:healthy_task_count</span><span class='rbracket'>]</span>
|
2043
|
+
|
2044
|
+
<span class='id identifier rubyid_gauge'>gauge</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>system_failed_tasks</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_set'>set</span><span class='lparen'>(</span><span class='id identifier rubyid_payload'>payload</span><span class='lbracket'>[</span><span class='symbol'>:failed_task_count</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_payload'>payload</span><span class='lbracket'>[</span><span class='symbol'>:failed_task_count</span><span class='rbracket'>]</span>
|
2045
|
+
<span class='kw'>end</span>
|
2046
|
+
|
2047
|
+
<span class='kw'>true</span>
|
2048
|
+
<span class='kw'>rescue</span> <span class='const'>StandardError</span> <span class='op'>=></span> <span class='id identifier rubyid_e'>e</span>
|
2049
|
+
<span class='comment'># Fail gracefully - metrics collection should never break the application
|
2050
|
+
</span> <span class='id identifier rubyid_warn'>warn</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>MetricsBackend failed to handle event </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_event_name'>event_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_message'>message</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span>
|
2051
|
+
<span class='kw'>false</span>
|
2052
|
+
<span class='kw'>end</span></pre>
|
2053
|
+
</td>
|
2054
|
+
</tr>
|
2055
|
+
</table>
|
2056
|
+
</div>
|
2057
|
+
|
2058
|
+
<div class="method_details ">
|
2059
|
+
<h3 class="signature " id="histogram-instance_method">
|
2060
|
+
|
2061
|
+
#<strong>histogram</strong>(name, buckets: nil, **labels) ⇒ <tt><span class='object_link'><a href="MetricTypes/Histogram.html" title="Tasker::Telemetry::MetricTypes::Histogram (class)">MetricTypes::Histogram</a></span></tt>
|
2062
|
+
|
2063
|
+
|
2064
|
+
|
2065
|
+
|
2066
|
+
|
2067
|
+
</h3><div class="docstring">
|
2068
|
+
<div class="discussion">
|
2069
|
+
|
2070
|
+
<p>Get or create a histogram metric</p>
|
2071
|
+
|
2072
|
+
<p>Histograms are thread-safe and provide statistical analysis of observed values. They’re ideal for measuring durations, sizes, and distributions.</p>
|
2073
|
+
|
2074
|
+
|
2075
|
+
</div>
|
2076
|
+
</div>
|
2077
|
+
<div class="tags">
|
2078
|
+
|
2079
|
+
<div class="examples">
|
2080
|
+
<h4 class="tag_title">Examples:</h4>
|
2081
|
+
|
2082
|
+
|
2083
|
+
<pre class="example code"><code><span class='id identifier rubyid_histogram'>histogram</span> <span class='op'>=</span> <span class='id identifier rubyid_backend'>backend</span><span class='period'>.</span><span class='id identifier rubyid_histogram'>histogram</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>request_duration_seconds</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>method:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>POST</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
2084
|
+
<span class='id identifier rubyid_histogram'>histogram</span><span class='period'>.</span><span class='id identifier rubyid_observe'>observe</span><span class='lparen'>(</span><span class='float'>0.145</span><span class='rparen'>)</span></code></pre>
|
2085
|
+
|
2086
|
+
</div>
|
2087
|
+
<p class="tag_title">Parameters:</p>
|
2088
|
+
<ul class="param">
|
2089
|
+
|
2090
|
+
<li>
|
2091
|
+
|
2092
|
+
<span class='name'>name</span>
|
2093
|
+
|
2094
|
+
|
2095
|
+
<span class='type'>(<tt>String</tt>)</span>
|
2096
|
+
|
2097
|
+
|
2098
|
+
|
2099
|
+
—
|
2100
|
+
<div class='inline'>
|
2101
|
+
<p>The metric name</p>
|
2102
|
+
</div>
|
2103
|
+
|
2104
|
+
</li>
|
2105
|
+
|
2106
|
+
<li>
|
2107
|
+
|
2108
|
+
<span class='name'>labels</span>
|
2109
|
+
|
2110
|
+
|
2111
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
2112
|
+
|
2113
|
+
|
2114
|
+
|
2115
|
+
—
|
2116
|
+
<div class='inline'>
|
2117
|
+
<p>Optional dimensional labels</p>
|
2118
|
+
</div>
|
2119
|
+
|
2120
|
+
</li>
|
2121
|
+
|
2122
|
+
<li>
|
2123
|
+
|
2124
|
+
<span class='name'>buckets</span>
|
2125
|
+
|
2126
|
+
|
2127
|
+
<span class='type'>(<tt>Array<Numeric></tt>)</span>
|
2128
|
+
|
2129
|
+
|
2130
|
+
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
2131
|
+
|
2132
|
+
|
2133
|
+
—
|
2134
|
+
<div class='inline'>
|
2135
|
+
<p>Optional custom bucket boundaries</p>
|
2136
|
+
</div>
|
2137
|
+
|
2138
|
+
</li>
|
2139
|
+
|
2140
|
+
</ul>
|
2141
|
+
|
2142
|
+
<p class="tag_title">Returns:</p>
|
2143
|
+
<ul class="return">
|
2144
|
+
|
2145
|
+
<li>
|
2146
|
+
|
2147
|
+
|
2148
|
+
<span class='type'>(<tt><span class='object_link'><a href="MetricTypes/Histogram.html" title="Tasker::Telemetry::MetricTypes::Histogram (class)">MetricTypes::Histogram</a></span></tt>)</span>
|
2149
|
+
|
2150
|
+
|
2151
|
+
|
2152
|
+
—
|
2153
|
+
<div class='inline'>
|
2154
|
+
<p>The histogram instance</p>
|
2155
|
+
</div>
|
2156
|
+
|
2157
|
+
</li>
|
2158
|
+
|
2159
|
+
</ul>
|
2160
|
+
<p class="tag_title">Raises:</p>
|
2161
|
+
<ul class="raise">
|
2162
|
+
|
2163
|
+
<li>
|
2164
|
+
|
2165
|
+
|
2166
|
+
<span class='type'>(<tt>ArgumentError</tt>)</span>
|
2167
|
+
|
2168
|
+
|
2169
|
+
|
2170
|
+
—
|
2171
|
+
<div class='inline'>
|
2172
|
+
<p>If name is invalid or buckets are malformed</p>
|
2173
|
+
</div>
|
2174
|
+
|
2175
|
+
</li>
|
2176
|
+
|
2177
|
+
</ul>
|
2178
|
+
|
2179
|
+
</div><table class="source_code">
|
2180
|
+
<tr>
|
2181
|
+
<td>
|
2182
|
+
<pre class="lines">
|
2183
|
+
|
2184
|
+
|
2185
|
+
170
|
2186
|
+
171
|
2187
|
+
172
|
2188
|
+
173
|
2189
|
+
174
|
2190
|
+
175
|
2191
|
+
176
|
2192
|
+
177
|
2193
|
+
178</pre>
|
2194
|
+
</td>
|
2195
|
+
<td>
|
2196
|
+
<pre class="code"><span class="info file"># File 'lib/tasker/telemetry/metrics_backend.rb', line 170</span>
|
2197
|
+
|
2198
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_histogram'>histogram</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='label'>buckets:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_labels'>labels</span><span class='rparen'>)</span>
|
2199
|
+
<span class='id identifier rubyid_get_or_create_metric'>get_or_create_metric</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_labels'>labels</span><span class='comma'>,</span> <span class='symbol'>:histogram</span><span class='rparen'>)</span> <span class='kw'>do</span>
|
2200
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_buckets'>buckets</span>
|
2201
|
+
<span class='const'><span class='object_link'><a href="MetricTypes.html" title="Tasker::Telemetry::MetricTypes (module)">MetricTypes</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="MetricTypes/Histogram.html" title="Tasker::Telemetry::MetricTypes::Histogram (class)">Histogram</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="MetricTypes/Histogram.html#initialize-instance_method" title="Tasker::Telemetry::MetricTypes::Histogram#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='label'>labels:</span> <span class='id identifier rubyid_labels'>labels</span><span class='comma'>,</span> <span class='label'>buckets:</span> <span class='id identifier rubyid_buckets'>buckets</span><span class='rparen'>)</span>
|
2202
|
+
<span class='kw'>else</span>
|
2203
|
+
<span class='const'><span class='object_link'><a href="MetricTypes.html" title="Tasker::Telemetry::MetricTypes (module)">MetricTypes</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="MetricTypes/Histogram.html" title="Tasker::Telemetry::MetricTypes::Histogram (class)">Histogram</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="MetricTypes/Histogram.html#initialize-instance_method" title="Tasker::Telemetry::MetricTypes::Histogram#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='label'>labels:</span> <span class='id identifier rubyid_labels'>labels</span><span class='rparen'>)</span>
|
2204
|
+
<span class='kw'>end</span>
|
2205
|
+
<span class='kw'>end</span>
|
2206
|
+
<span class='kw'>end</span></pre>
|
2207
|
+
</td>
|
2208
|
+
</tr>
|
2209
|
+
</table>
|
2210
|
+
</div>
|
2211
|
+
|
2212
|
+
<div class="method_details ">
|
2213
|
+
<h3 class="signature " id="register_event_router-instance_method">
|
2214
|
+
|
2215
|
+
#<strong>register_event_router</strong>(router) ⇒ <tt><span class='object_link'><a href="EventRouter.html" title="Tasker::Telemetry::EventRouter (class)">EventRouter</a></span></tt>
|
2216
|
+
|
2217
|
+
|
2218
|
+
|
2219
|
+
|
2220
|
+
|
2221
|
+
</h3><div class="docstring">
|
2222
|
+
<div class="discussion">
|
2223
|
+
|
2224
|
+
<p>Register the EventRouter for intelligent routing</p>
|
2225
|
+
|
2226
|
+
<p>This method is called by EventRouter during configuration to enable automatic metric collection based on routing decisions.</p>
|
2227
|
+
|
2228
|
+
|
2229
|
+
</div>
|
2230
|
+
</div>
|
2231
|
+
<div class="tags">
|
2232
|
+
<p class="tag_title">Parameters:</p>
|
2233
|
+
<ul class="param">
|
2234
|
+
|
2235
|
+
<li>
|
2236
|
+
|
2237
|
+
<span class='name'>router</span>
|
2238
|
+
|
2239
|
+
|
2240
|
+
<span class='type'>(<tt><span class='object_link'><a href="EventRouter.html" title="Tasker::Telemetry::EventRouter (class)">EventRouter</a></span></tt>)</span>
|
2241
|
+
|
2242
|
+
|
2243
|
+
|
2244
|
+
—
|
2245
|
+
<div class='inline'>
|
2246
|
+
<p>The configured event router</p>
|
2247
|
+
</div>
|
2248
|
+
|
2249
|
+
</li>
|
2250
|
+
|
2251
|
+
</ul>
|
2252
|
+
|
2253
|
+
<p class="tag_title">Returns:</p>
|
2254
|
+
<ul class="return">
|
2255
|
+
|
2256
|
+
<li>
|
2257
|
+
|
2258
|
+
|
2259
|
+
<span class='type'>(<tt><span class='object_link'><a href="EventRouter.html" title="Tasker::Telemetry::EventRouter (class)">EventRouter</a></span></tt>)</span>
|
2260
|
+
|
2261
|
+
|
2262
|
+
|
2263
|
+
—
|
2264
|
+
<div class='inline'>
|
2265
|
+
<p>The registered router</p>
|
2266
|
+
</div>
|
2267
|
+
|
2268
|
+
</li>
|
2269
|
+
|
2270
|
+
</ul>
|
2271
|
+
|
2272
|
+
</div><table class="source_code">
|
2273
|
+
<tr>
|
2274
|
+
<td>
|
2275
|
+
<pre class="lines">
|
2276
|
+
|
2277
|
+
|
2278
|
+
113
|
2279
|
+
114
|
2280
|
+
115</pre>
|
2281
|
+
</td>
|
2282
|
+
<td>
|
2283
|
+
<pre class="code"><span class="info file"># File 'lib/tasker/telemetry/metrics_backend.rb', line 113</span>
|
2284
|
+
|
2285
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_register_event_router'>register_event_router</span><span class='lparen'>(</span><span class='id identifier rubyid_router'>router</span><span class='rparen'>)</span>
|
2286
|
+
<span class='ivar'>@event_router</span> <span class='op'>=</span> <span class='id identifier rubyid_router'>router</span>
|
2287
|
+
<span class='kw'>end</span></pre>
|
2288
|
+
</td>
|
2289
|
+
</tr>
|
2290
|
+
</table>
|
2291
|
+
</div>
|
2292
|
+
|
2293
|
+
<div class="method_details ">
|
2294
|
+
<h3 class="signature " id="stats-instance_method">
|
2295
|
+
|
2296
|
+
#<strong>stats</strong> ⇒ <tt>Hash</tt>
|
2297
|
+
|
2298
|
+
|
2299
|
+
|
2300
|
+
|
2301
|
+
|
2302
|
+
</h3><div class="docstring">
|
2303
|
+
<div class="discussion">
|
2304
|
+
|
2305
|
+
<p>Get summary statistics about the metrics backend</p>
|
2306
|
+
|
2307
|
+
|
2308
|
+
</div>
|
2309
|
+
</div>
|
2310
|
+
<div class="tags">
|
2311
|
+
|
2312
|
+
<p class="tag_title">Returns:</p>
|
2313
|
+
<ul class="return">
|
2314
|
+
|
2315
|
+
<li>
|
2316
|
+
|
2317
|
+
|
2318
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
2319
|
+
|
2320
|
+
|
2321
|
+
|
2322
|
+
—
|
2323
|
+
<div class='inline'>
|
2324
|
+
<p>Backend statistics and health information</p>
|
2325
|
+
</div>
|
2326
|
+
|
2327
|
+
</li>
|
2328
|
+
|
2329
|
+
</ul>
|
2330
|
+
|
2331
|
+
</div><table class="source_code">
|
2332
|
+
<tr>
|
2333
|
+
<td>
|
2334
|
+
<pre class="lines">
|
2335
|
+
|
2336
|
+
|
2337
|
+
343
|
2338
|
+
344
|
2339
|
+
345
|
2340
|
+
346
|
2341
|
+
347
|
2342
|
+
348
|
2343
|
+
349
|
2344
|
+
350
|
2345
|
+
351
|
2346
|
+
352
|
2347
|
+
353
|
2348
|
+
354</pre>
|
2349
|
+
</td>
|
2350
|
+
<td>
|
2351
|
+
<pre class="code"><span class="info file"># File 'lib/tasker/telemetry/metrics_backend.rb', line 343</span>
|
2352
|
+
|
2353
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_stats'>stats</span>
|
2354
|
+
<span class='id identifier rubyid_metric_types'>metric_types</span> <span class='op'>=</span> <span class='id identifier rubyid_all_metrics'>all_metrics</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span><span class='period'>.</span><span class='id identifier rubyid_group_by'>group_by</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_m'>m</span><span class='op'>|</span> <span class='id identifier rubyid_m'>m</span><span class='period'>.</span><span class='id identifier rubyid_to_h'>to_h</span><span class='lbracket'>[</span><span class='symbol'>:type</span><span class='rbracket'>]</span> <span class='rbrace'>}</span>
|
2355
|
+
|
2356
|
+
<span class='lbrace'>{</span>
|
2357
|
+
<span class='label'>total_metrics:</span> <span class='ivar'>@metrics</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span><span class='comma'>,</span>
|
2358
|
+
<span class='label'>counter_metrics:</span> <span class='id identifier rubyid_metric_types'>metric_types</span><span class='lbracket'>[</span><span class='symbol'>:counter</span><span class='rbracket'>]</span><span class='op'>&.</span><span class='id identifier rubyid_size'>size</span> <span class='op'>||</span> <span class='int'>0</span><span class='comma'>,</span>
|
2359
|
+
<span class='label'>gauge_metrics:</span> <span class='id identifier rubyid_metric_types'>metric_types</span><span class='lbracket'>[</span><span class='symbol'>:gauge</span><span class='rbracket'>]</span><span class='op'>&.</span><span class='id identifier rubyid_size'>size</span> <span class='op'>||</span> <span class='int'>0</span><span class='comma'>,</span>
|
2360
|
+
<span class='label'>histogram_metrics:</span> <span class='id identifier rubyid_metric_types'>metric_types</span><span class='lbracket'>[</span><span class='symbol'>:histogram</span><span class='rbracket'>]</span><span class='op'>&.</span><span class='id identifier rubyid_size'>size</span> <span class='op'>||</span> <span class='int'>0</span><span class='comma'>,</span>
|
2361
|
+
<span class='label'>backend_uptime:</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_current'>current</span> <span class='op'>-</span> <span class='ivar'>@created_at</span><span class='comma'>,</span>
|
2362
|
+
<span class='label'>created_at:</span> <span class='ivar'>@created_at</span>
|
2363
|
+
<span class='rbrace'>}</span>
|
2364
|
+
<span class='kw'>end</span></pre>
|
2365
|
+
</td>
|
2366
|
+
</tr>
|
2367
|
+
</table>
|
2368
|
+
</div>
|
2369
|
+
|
2370
|
+
<div class="method_details ">
|
2371
|
+
<h3 class="signature " id="sync_to_cache!-instance_method">
|
2372
|
+
|
2373
|
+
#<strong>sync_to_cache!</strong> ⇒ <tt>Hash</tt>
|
2374
|
+
|
2375
|
+
|
2376
|
+
|
2377
|
+
|
2378
|
+
|
2379
|
+
</h3><div class="docstring">
|
2380
|
+
<div class="discussion">
|
2381
|
+
|
2382
|
+
<p>Synchronize in-memory metrics to Rails.cache using detected strategy</p>
|
2383
|
+
|
2384
|
+
<p>This method implements the core cache synchronization logic that adapts to the available Rails.cache store capabilities.</p>
|
2385
|
+
|
2386
|
+
|
2387
|
+
</div>
|
2388
|
+
</div>
|
2389
|
+
<div class="tags">
|
2390
|
+
|
2391
|
+
<div class="examples">
|
2392
|
+
<h4 class="tag_title">Examples:</h4>
|
2393
|
+
|
2394
|
+
|
2395
|
+
<h5 class="example_title"><div class='inline'>
|
2396
|
+
<p>Periodic sync (typically called from background job)</p>
|
2397
|
+
</div></h5>
|
2398
|
+
|
2399
|
+
<pre class="example code"><code><span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='id identifier rubyid_backend'>backend</span><span class='period'>.</span><span class='id identifier rubyid_sync_to_cache!'>sync_to_cache!</span>
|
2400
|
+
<span class='comment'># => { success: true, synced_metrics: 42, strategy: :distributed_atomic }</span></code></pre>
|
2401
|
+
|
2402
|
+
</div>
|
2403
|
+
|
2404
|
+
<p class="tag_title">Returns:</p>
|
2405
|
+
<ul class="return">
|
2406
|
+
|
2407
|
+
<li>
|
2408
|
+
|
2409
|
+
|
2410
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
2411
|
+
|
2412
|
+
|
2413
|
+
|
2414
|
+
—
|
2415
|
+
<div class='inline'>
|
2416
|
+
<p>Sync result with success status and metrics count</p>
|
2417
|
+
</div>
|
2418
|
+
|
2419
|
+
</li>
|
2420
|
+
|
2421
|
+
</ul>
|
2422
|
+
|
2423
|
+
</div><table class="source_code">
|
2424
|
+
<tr>
|
2425
|
+
<td>
|
2426
|
+
<pre class="lines">
|
2427
|
+
|
2428
|
+
|
2429
|
+
190
|
2430
|
+
191
|
2431
|
+
192
|
2432
|
+
193
|
2433
|
+
194
|
2434
|
+
195
|
2435
|
+
196
|
2436
|
+
197
|
2437
|
+
198
|
2438
|
+
199
|
2439
|
+
200
|
2440
|
+
201
|
2441
|
+
202
|
2442
|
+
203
|
2443
|
+
204
|
2444
|
+
205
|
2445
|
+
206
|
2446
|
+
207
|
2447
|
+
208
|
2448
|
+
209
|
2449
|
+
210
|
2450
|
+
211
|
2451
|
+
212
|
2452
|
+
213
|
2453
|
+
214
|
2454
|
+
215
|
2455
|
+
216
|
2456
|
+
217
|
2457
|
+
218
|
2458
|
+
219</pre>
|
2459
|
+
</td>
|
2460
|
+
<td>
|
2461
|
+
<pre class="code"><span class="info file"># File 'lib/tasker/telemetry/metrics_backend.rb', line 190</span>
|
2462
|
+
|
2463
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_sync_to_cache!'>sync_to_cache!</span>
|
2464
|
+
<span class='kw'>return</span> <span class='lbrace'>{</span> <span class='label'>success:</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='label'>error:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Rails.cache not available</span><span class='tstring_end'>'</span></span> <span class='rbrace'>}</span> <span class='kw'>unless</span> <span class='id identifier rubyid_rails_cache_available?'>rails_cache_available?</span>
|
2465
|
+
|
2466
|
+
<span class='id identifier rubyid_start_time'>start_time</span> <span class='op'>=</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_current'>current</span>
|
2467
|
+
|
2468
|
+
<span class='kw'>case</span> <span class='ivar'>@sync_strategy</span>
|
2469
|
+
<span class='kw'>when</span> <span class='symbol'>:distributed_atomic</span>
|
2470
|
+
<span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='id identifier rubyid_sync_with_atomic_operations'>sync_with_atomic_operations</span>
|
2471
|
+
<span class='kw'>when</span> <span class='symbol'>:distributed_basic</span>
|
2472
|
+
<span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='id identifier rubyid_sync_with_read_modify_write'>sync_with_read_modify_write</span>
|
2473
|
+
<span class='kw'>when</span> <span class='symbol'>:local_only</span>
|
2474
|
+
<span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='id identifier rubyid_sync_to_local_cache'>sync_to_local_cache</span>
|
2475
|
+
<span class='kw'>else</span>
|
2476
|
+
<span class='kw'>return</span> <span class='lbrace'>{</span> <span class='label'>success:</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='label'>error:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Unknown sync strategy: </span><span class='embexpr_beg'>#{</span><span class='ivar'>@sync_strategy</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span> <span class='rbrace'>}</span>
|
2477
|
+
<span class='kw'>end</span>
|
2478
|
+
|
2479
|
+
<span class='id identifier rubyid_final_result'>final_result</span> <span class='op'>=</span> <span class='id identifier rubyid_result'>result</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span>
|
2480
|
+
<span class='label'>duration:</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_current'>current</span> <span class='op'>-</span> <span class='id identifier rubyid_start_time'>start_time</span><span class='comma'>,</span>
|
2481
|
+
<span class='label'>timestamp:</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_current'>current</span><span class='period'>.</span><span class='id identifier rubyid_iso8601'>iso8601</span><span class='comma'>,</span>
|
2482
|
+
<span class='label'>instance_id:</span> <span class='ivar'>@instance_id</span>
|
2483
|
+
<span class='rparen'>)</span>
|
2484
|
+
|
2485
|
+
<span class='comment'># Coordinate with export system
|
2486
|
+
</span> <span class='id identifier rubyid_coordinate_cache_sync'>coordinate_cache_sync</span><span class='lparen'>(</span><span class='id identifier rubyid_final_result'>final_result</span><span class='rparen'>)</span>
|
2487
|
+
|
2488
|
+
<span class='id identifier rubyid_final_result'>final_result</span>
|
2489
|
+
<span class='kw'>rescue</span> <span class='const'>StandardError</span> <span class='op'>=></span> <span class='id identifier rubyid_e'>e</span>
|
2490
|
+
<span class='id identifier rubyid_log_sync_error'>log_sync_error</span><span class='lparen'>(</span><span class='id identifier rubyid_e'>e</span><span class='rparen'>)</span>
|
2491
|
+
<span class='lbrace'>{</span> <span class='label'>success:</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='label'>error:</span> <span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_message'>message</span><span class='comma'>,</span> <span class='label'>timestamp:</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_current'>current</span><span class='period'>.</span><span class='id identifier rubyid_iso8601'>iso8601</span> <span class='rbrace'>}</span>
|
2492
|
+
<span class='kw'>end</span></pre>
|
2493
|
+
</td>
|
2494
|
+
</tr>
|
2495
|
+
</table>
|
2496
|
+
</div>
|
2497
|
+
|
2498
|
+
</div>
|
2499
|
+
|
2500
|
+
</div>
|
2501
|
+
|
2502
|
+
<div id="footer">
|
2503
|
+
Generated on Tue Jul 1 16:47:38 2025 by
|
2504
|
+
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
2505
|
+
0.9.37 (ruby-3.2.4).
|
2506
|
+
</div>
|
2507
|
+
|
2508
|
+
</div>
|
2509
|
+
</body>
|
2510
|
+
</html>
|