All notes

Observability Context Should Follow One User Action

Connect business identity, execution traces and low-cardinality metrics without collecting unnecessary input.

English edition, edited for length. Read the complete Chinese original.

Users reported that the report was never completed. The logs showed successful uploads, tasks enqueued, database timeouts, and retries, but there was no way to determine which records belonged to this particular operation. Each service had its own logs, but this doesn’t necessarily mean the system is observable. Without a clear relationship between the information, it’s only possible to guess manually.

You can start designing from a specific business action: a user creates a report, the backend reads the data, generates a file, and finally updates the download status. This requires answering two key questions: What happened during this action, and is the entire system handling similar actions reliably?

Division of Responsibilities for Business and Tracking Identifiers

The report identifier is used to find the same business object across multiple retries, while the tracking identifier is used to describe the execution path for a single attempt. A report may involve multiple tracking instances, and it’s not possible to force all retries into a single, infinitely long tracking path.

The log structure includes structured fields such as report identifier, task identifier, stage, attempt number, and error category. The context is tracked and propagated through synchronous calls; an asynchronous queue can record the parent context or establish a relationship, depending on the tracking system’s support for long-running tasks.

Do not use user email addresses as identifiers. Email addresses can change and are considered personal information. Copying them to each log entry expands the scope of access. Instead of storing the entire user profile on an observable platform, use controlled internal identifiers and, if necessary, look up the user through authorized business systems.

After a report request is created, the task may take several minutes to execute, and retries will initiate a new attempt. Each execution has its own tracking, with business report ID and task ID providing association. Tracking links can be used to indicate the source when necessary. All attempts are grouped within a span lasting several days, which may not align with the tool’s capabilities and can make it difficult to distinguish between waiting and working. Contextual propagation is implemented according to OpenTelemetry or the chosen system, and arbitrary headers are not used as a complete tracking protocol.

When validating the size and format of context within the queue payload from external input, it’s crucial to treat tracking tags as non-business-related data. User-influenced baggage may be propagated across multiple services, restricting allowed fields and retention ranges. It cannot contain email addresses, tokens, or the entire request body. Both convenience and minimal data can be satisfied simultaneously. Business objects identified in the logs are also subject to access control, and privacy is not completely compromised simply because they are not plaintext names.

After task takeover, retain the attempt number. Metrics can be used to track the number of recovery attempts. Logs are organized by business object to find all executions. Correlation identifiers help reconstruct facts, but do not guarantee idempotency. The status of orders or reports is still determined by persistent business records. Observability describes the system, but does not replace a reliable state machine.

Overall answers to metrics, individual answers to logs

The metrics are suitable for recording success rate, processing time, queue age, and failure classification. Labels should use a limited set, such as stages and error types, rather than individual report identifiers. High-cardinality labels will increase storage and query costs, and also make aggregation meaningless.

report_completed_total{result="success"}
report_duration_seconds{stage="render"}
report_queue_oldest_age_seconds

These names are merely illustrative; in practice, adherence to the conventions of the chosen monitoring system is essential. The distribution of durations, rather than the average, better reflects the “long tail,” but the aggregation method must be accurate. It is not possible to directly average the percentiles of multiple instances; typically, it is necessary to aggregate raw statistics, such as histograms, before calculating.

Log files record the context of a failed attempt. Avoid generating large objects for each successful loop, as this increases costs and obscures important information. Error logs should clearly indicate the stage of failure and the actions that can be taken. A single stack trace is often insufficient to explain the business impact.

Tracking the Real Waiting Time of Splits

The report’s duration is quite long, likely due to queuing, data reading, rendering, or uploading. Breaking down these stages into spans allows you to identify where the primary delays are occurring. Avoid wrapping every line of code within a span; excessive detail can actually increase the reading burden and cost.

The waiting time should be calculated separately and should not be measured from the start of execution. Otherwise, if a user waits for half an hour while the execution indicator shows only ten seconds, the monitoring system will give a misleading impression. The timestamps for the status and tracking times should also be clearly identified to avoid negative durations caused by clock discrepancies between nodes.

External calls should log the vendor, operation category, and result, rather than the complete request payload. Error responses may contain sensitive information and should be filtered before being logged. The retention period and access permissions for the tracking platform should be managed in the same way as business data.

The user-submitted results include queuing, processing, and uploading. The system guarantees end-to-end metric validation, including cost analysis for each stage. Each service uses a suitable timing source for measuring duration, and cross-node timestamps are synchronized and recorded with limitations, preventing values from being arbitrarily truncated to zero to mask clock issues. Queuing start and task execution start are separately saved to prevent the system from becoming overly congested and producing misleading metrics.

The completion conditions must align with the business agreement. The status field should be changed to “done,” but the object should not be readable and should not be counted as a success. The handling of user cancellation needs to be defined first. Separate counting should be used for repeated requests and repeated executions; if a task is successfully executed five times, it should not be counted as five user actions. The denominator for the metrics should come from stable business facts, providing an execution perspective, and these two should be reasonably different.

The histogram boundaries are chosen based on the task duration and service objectives. If they are too coarse, it may be impossible to determine when the deadline is approaching. If they are too fine, it will increase the cost. Percentiles across instances are calculated from aggregated distributions, and the pre-calculated percentiles are not averaged. The default values of the tool may not match the reporting task, and the monitoring design also needs to be tested with known samples to verify that the query results accurately reflect the actual distribution. If the chart appears smooth, it is not a correct statistical representation.

Faults Cannot Be Hidden by Sampling

Full-scale tracking can be expensive, so sampling may be used. However, low-proportion random sampling may miss rare failures, and tail sampling can retain errors and high-latency tracking after execution, at the cost of increased buffering and coordination.

Regardless of the approach chosen, key business metrics should not be directly derived from the number of samples tracked. The success rate must be known in relation to the total population, and sampling bias can distort seemingly accurate percentages. Log sampling should also clearly indicate the location where the sampling occurred to avoid misinterpreting the absence of records as a lack of execution.

Prioritize retaining information with errors and business relevance during peak times, rather than discarding all logs arbitrarily. Observability requires a degradation strategy; otherwise, the more the application malfunctions, the more likely it is that relevant information will be lost.

A request without tracking may occur due to sampling failures, reporting errors, or simply not being executed. Therefore, it’s impossible to directly determine the cause of the failure. Key status information can be obtained through queries in the business system, while complete metrics provide an overall view. Sample logs provide the reason for failures. Retaining tail sampling requires judgment after the process is complete, and long-running tasks and cross-service data collection also incur buffering costs. When choosing a solution, it’s important to consider its recording capabilities and limitations. No solution can guarantee the free storage of all necessary information.

Example error samples may be biased towards certain instances or networks. When analyzing, combine with complete counts. When the monitoring platform fails, apply budget-based diagnostics, without indefinite buffering while waiting for recovery. Logs and tracking reports should have retry capabilities with capacity and deadlines to avoid magnifying diagnostic traffic during incidents. The discard strategy should prioritize saving limited key categories, and allow diagnostics to degrade their own visibility.

The permissions and retention periods cover the platform, export, and local copies. After troubleshooting, temporary fields are automatically added and expire, along with cleanup. Logs with encrypted storage cannot be used to indefinitely collect private content, and secure storage and data minimization have distinct responsibilities. Each field should be clearly described, and the maintainer should be able to explain why it is needed, rather than simply saying “it might be useful in the future.”

Action Required: Alert Target

“More than 100 errors” doesn’t specify who is affected, nor does it indicate whether on-call support is required. It’s possible to set targets for report completion, and then configure alerts based on the backlog of errors and their rate. The thresholds should be based on user commitments and system baselines, rather than simply copying numbers from another project.

Each alert includes a troubleshooting entry, the scope of impact, and recovery instructions. Repeated alerts need to be aggregated, and maintenance windows need to be suppressed. Alerts for which no action is taken will ultimately reduce the credibility of all alerts.

First, investigate the oldest and most critical tasks and errors to categorize them. Then, choose to implement rate limiting, fix dependencies, or restore the executioner.

Next, for error rate alerts, compare the deployed version with the scope.

The operation manual records entry points and security queries to prevent on-duty personnel from temporarily obtaining all production data during an incident.

The alert names explain the impact on users, and the associated charts and logs allow you to trace the issue from a general overview to a specific object.

The system aggregates and does not hide new stages, such as extending a single timeout to a complete failure, requiring re-notification. Recovery confirmation ensures that the business returns to the target range, not just restarting the process. The tester must be able to identify the cause within a limited time, and a small number of high-value charts are more effective than dozens of dashboards that no one reads. Statistics and investigative paths together create observability, not just installing an SDK.

First, use an incident log to verify the completeness of the connections.

The request for report R17 was accepted at the gateway, and task J6 joined the queue. The first execution of A1 timed out while reading data, and the second execution of A2 was successful. These four identifiers do not represent four distinct business actions. It is possible to define a set of minimum fields for each event: event type, business object, execution attempt, occurrence time, record time, deployment version, and a category of results that can explain the current stage. Record time is used to identify late reporting, and occurrence time is used for sorting facts; these should not be confused.

When investigating, first use R17 to find the creation record and the final state, then use J6 to find the scheduling record, and finally use A1 and A2 to track the execution. If the only log data uploaded is the tracking ID, without any reports or task relationships, losing the parent tracking record will also result in losing the entry point. The solution is to ensure that persistent task records save the necessary associated information, rather than duplicating the entire business object in all logs. The query permissions for these records are consistent with the business system, and the observability platform only receives the fields required for the investigation.

The name of the event should clearly express the fact that has already occurred. upload_started does not mean the file is downloadable, job_received does not mean the work has started, and retry_scheduled does not mean a retry actually executes. Each event should specify the triggering conditions and the responsible module, to avoid different services using the same “completed” to represent different states. Business completion still requires confirmation from an authoritative state. Logs can only provide supporting evidence, and should not override database facts simply because a success string is observed.

Testing does not necessarily require asserting every debugging log. Instead, focus on key events, construct a flow from initial failure to successful recovery, and check associated chains, stage semantics, and privacy fields. Then, simulate a reporter failure to confirm that business operations do not rely on log writing to complete, while also verifying that the number of lost records can be observed. If auditing requirements mandate that certain records must not be lost, use an auditing channel with the appropriate guarantees, rather than allowing ordinary asynchronous logs to take on responsibilities they are not equipped to handle.

Tag management needs to handle both normal and malicious inputs.

Originally, a routing indicator only had two labels: “report-create” and “report-download”. If the request path is used directly, file identifiers, query parameters, and random scan paths will all generate new time series. By normalizing the actual path into a routing template, unmatched requests are unified into a limited category, and individual samples from this category are recorded separately for troubleshooting. Do not convert URLs into hash tags solely to preserve all input; different inputs still produce different values, and the cardinality problem remains unresolved.

Error messages are also a common trap. Supplier messages may contain order numbers or user text, which cannot be used as indicator tags. The adapter layer maps known errors to a limited set of categories, and unknown errors are classified as “unknown.” The controlled logs retain filtered diagnostic information. When adding new supplier errors, it is necessary to check whether they are incorrectly classified as successful, whether they expose input, or whether they cause a sudden increase in the number of tags.

Limiting field length only controls the size of individual records, not the types of tags. Both have their own budget settings. Deployment versions can be used for comparison, but a long history of SHA commits will also increase the sequence. Evaluate based on retention window and query requirements to avoid combining arbitrary branch names, instance UUIDs, and user IDs into a single tag for all metrics. It is also necessary to know the additional cost that results from scaling.

The tracking context across organizational boundaries cannot directly determine the priority or access permissions for internal sampling. External inputs can provide context, but they must undergo parsing, length restrictions, and trust policy enforcement. Some systems allow visitors to request sampling, and the team should clearly define whether to accept such requests to prevent a public interface from forcing full tracking at a high cost. Sampling control does not affect business authorization; both should be handled separately in code and configuration.

Monitoring Changes Also Require Publication and Rollback

I plan to change the report_duration metric from execution time to end-to-end user time. Keeping the original name will cause historical charts to show inexplicable jumps. First, introduce a clear, new metric, and then observe both the old and new metrics to verify that the differences actually come from queueing time. After confirming this, migrate the alerts and dashboards. Before deleting the old metric, check the alerts, runbooks, and exported queries. Don’t just search the application source code.

The dashboard should clearly define the units, statistical window, filtering range, and the meaning of missing data. The absence of data could indicate a failed request or a data collection outage. Displaying zero successful attempts with a duration will lead to misinterpretations. When validating charts with known samples, such as two successful, one timeout, and one still within the deadline, check the denominator and failure categories. Identifying rule errors using these small samples is easier than guessing on the production line.

When releasing a version, it’s also important to consider long-running tasks. These tasks start in an older version and are completed after the new version takes over. It’s necessary to record the version used for each attempt, and not just rely on the final instance version to determine the root cause of any issues. Changes to configurations, models, or templates can also affect the results, so it’s best to save a limited and interpretable version identity in the execution log. The purpose of the version fields is not to store complete configurations or keys in the log.

When adding new collection fields, first check the field values in a limited environment. This should not only check the field name, but also the actual data within the field. If a field named “category” contains complete, sensitive text, it still poses a risk to privacy. After deployment, monitor time series growth, the size of individual events, and reporting failures to ensure that the costs are within the design. Changes can also be reverted, and the old version should ignore the new field to prevent updates to the monitoring structure from hindering business releases.

During the incident, detailed tracking is temporarily enabled, requiring clear specification of the target, time range, and maximum number. After debugging, it automatically closes and deletes any unnecessary exported copies. If troubleshooting requires access across multiple tenants, approval and query ranges are handled separately, and it does not assume that all original data can be accessed simply because the maintainer has access to the platform. Platform permissions, business query permissions, and emergency authorization jointly determine what can be seen.

Incorporate investigation paths as part of the release acceptance process: Does the new stage have a stable name, can asynchronous boundaries connect to task identities, can records generated in older versions still be queried, and can failed samples be pinpointed to the correct actions? This approach prevents having to fill in gaps only after an incident occurs, and also eliminates the need to record all details in advance. The key is to maintain a small number of critical facts as stable and readily available.

The investigative path must lead from the problem to a verifiable conclusion.

After the user provides the report ID, the business system confirms the current status. The logs are searched for all attempts, and metrics are used to determine the scope of the impact. The primary focus is on tracking and explaining the root cause. The conclusion includes the reason, affected versions, and evidence of recovery, providing not just a stack trace. If only sampling tracking is available without logs, the missing information is clearly identified and supplemented with persistent state data, without fabricating non-existent stages. Observability supports reasoning and does not automatically replace investigations.

The recovery process starts with the user’s goals: new tasks are completed on schedule, old backlogs are addressed, files can be downloaded, and failed states can be acted upon. Restarting the process and clearing the queue are both methods and signals, but cannot be used independently as proof of recovery. Even if the dead-letter queue is still large, an empty normal queue may simply indicate that tasks have been moved. Combine metrics with specific business reconciliation to avoid misleading charts that hide the reality of incomplete tasks.

To address false alarms, it’s crucial to review noise and missed detections. Short, transient movements that might disrupt the on-duty personnel, or prolonged degradation that goes unnoticed, should be addressed through historical playback. Changes to thresholds should be aligned with the version, not arbitrarily reduced to avoid false positives at the end of the month. The operating manual should be updated as the system evolves, and broken links or insufficient permissions should be identified during drills, as these can prevent alarms from being triggered or acted upon.

Monitoring queries can be expensive, and they are limited by time, route, and version filters, preventing a comprehensive scan of the entire history. Sensitive context queries use authorized systems, while public dashboards only display aggregated data. Debug output is kept separate from long-term metrics, and privacy is not reduced by limiting the scope of monitoring; instead, it ensures that the necessary information is available at the appropriate boundaries.

The final deliverable should be a fault simulation that a new user can execute, along with a record of the required steps and limitations. If reliance on a single author’s verbal explanation of all events is necessary, the system’s meaning will not be stable. The system should provide clear responsibility, including business identifiers, limited metrics, stage tracking, and actionable alerts, rather than expecting tools to automatically integrate after being installed separately.

Rendering failed due to injection. Identify all attempts using report identifiers. Determine if the issue only affects a single task based on metrics. Track and locate external waiting. Verify that the logs do not contain incomplete emails, tokens, or report bodies. Simulate queue buildup to ensure that alerts provide sufficient processing time before impacting business commitments.

Observable deliverables are not just dashboards, but a repeatable investigative process. The ability of a new team member to explain a failure within a limited timeframe is often a better measure of design quality than the number of charts produced.

References