Integration Governance and Operations
Lesson opener
In one line: An integration you cannot trace is an integration you cannot repair without guessing.
Why it matters: Northline's doubled receipt took a day to explain. The webhook log said "OK," the ERP log used a different id, and nobody stored the event id next to the receipt id. Two teams argued about whose system had lied.
Before this lesson: AI agent and Copilot integrations.
What you will be able to do
- Define a correlation id that follows one business action across systems.
- Log the fields that explain a failure, and leave secrets out.
- Use retries and idempotency together so a repeat is visible and safe.
- Write an illustrative service target as the company's choice, with the measurement beside it.
Prerequisites
Lessons 2, 6, 8, and 10. No monitoring product is required.
Monitoring, logging, tracing, retries, idempotency, targets, audit
Monitoring watches the signals you already defined. For Northline's illustrative board: count of calls by status class, age of the newest successful batch, count of webhook events stored once, count of assistant writes waiting for approval. A green mark without a number is not a signal.
Logging. Each call logs time, correlation id, method, path, status, and duration. It does not log Authorization, API keys, or bank account numbers. An error log may include the validation field names, not the secret that failed.
Tracing. A correlation id is an identifier you create at the start of a business action and pass in a header. This course uses the header name X-Correlation-Id as Northline's illustrative choice. It is a common pattern. It is not a header RFC 9110 requires. Every log line for that action repeats it, so the webhook row, the ERP receipt, and the batch row can be found together.
Retries follow lesson 6. The log records the attempt number. A retry without an attempt number looks like a second business event.
Idempotency. The server stores the key or the event id with the result. The trace shows one business result and one or more HTTP attempts. Those are different counts. Confusing them is how a double post hides inside "we retried."
Service targets. An SLA (service level agreement) is a promise two parties write down. Northline's illustrative internal target is: 99 of 100 item reads in a day return within 5 seconds, measured at the caller. That is 99/100, not a universal "99.9% uptime" you may copy onto a contract. If you have a supplier contract, quote that contract. Do not invent a legal uptime duty.
Auditability. A person who was not on the incident can answer: what was asked, who approved a write, what status came back, and whether a repeat created a second document. The audit row from lesson 10 is part of this. Retention of those rows is a decision for the company and, where personal data is involved, for the privacy contact. This course does not set a retention period.
def trace_summary(attempts):
business = {row["idempotency_key"]: row["status"] for row in attempts}
return {"http_attempts": len(attempts), "business_results": len(business)}
rows = [
{"idempotency_key": "W-501", "status": 503, "attempt": 1},
{"idempotency_key": "W-501", "status": 201, "attempt": 2},
]
assert trace_summary(rows) == {"http_attempts": 2, "business_results": 1}The dict keeps the last status for the key. Two attempts, one business result. If the server had created two orders, you would see two keys or two resource ids. The trace is how you notice.
Teacher walkthrough: one doubled-receipt alarm
Illustrative.
- Webhook delivery 1 stores
evt-1, correlation idc-77, receipt R-19, and replies 202. - Delivery 2 of
evt-1logs the same correlation id if the sender echoed it, or a new delivery id with the sameevent_id. The handler does not create R-20. - The ERP log for R-19 includes
c-77. - The board shows http attempts 2 and business receipts 1.
- Validation: searching
c-77orevt-1finds every line, and on-hand moved once.
A second workplace case
A 5-second target is missed because the client waited with no timeout and the metric never closed. The call is not "slow." It is unfinished. The metric records a timeout as a failure to meet the target. It does not drop the call from the denominator.
Failure example: logging the token to "be safe"
Symptom: Debug logs include Authorization: Bearer .... The log tool is readable by the analytics team. That team can call the ERP as the integration.
Diagnosis: The secret was copied into a system with a wider audience than the secret store. The root cause is a log line that treats the header as ordinary metadata.
Correction: Remove the header from the logger. Rotate the token. Restrict the log store. Review a sample of new lines for the word Bearer.
Validation: A new error line has correlation id, path, and status, and a search for Bearer in that day's integration log finds nothing.
Guided practice: read a small trace
Scenario: Three log lines share correlation id c-80. Figures are illustrative.
- POST
/receiptsattempt 1, status 503, keyR-30. - POST
/receiptsattempt 2, status 201, keyR-30, resource R-30. - POST
/receiptsattempt 1, status 201, keyR-31, resource R-31.
Hints:
- Count HTTP attempts and business keys separately.
- Say whether this is a double post.
Complete solution:
There are 3 HTTP attempts and 2 business results, R-30 and R-31. R-30 was a retry of one key and is one receipt. R-31 is a different receipt, not a duplicate of R-30. The trace is healthy if the business expected two receipts. It is a double post only if the operator intended one receipt and somehow issued two keys. Validation is the two resource ids in the ERP, matching the two keys, and one extra 503 that did not create a third receipt.
Independent practice
Write the log and target for one integration.
Acceptance criteria:
- You list the log fields and the fields you exclude.
- You name the correlation header as your choice or the provider's documented header.
- You show one retry as multiple attempts and one business result.
- You state a target as a fraction you could count, labelled as yours or the contract's.
- You say who is called when the fraction is missed.
- You do not invent a legal retention period.
Common mistakes
- One log per system with no shared id.
- Counting retries as extra orders.
- A target with no denominator.
- Logging secrets, then calling the log store "internal" as if that removed the copy.
Quick check
- What is a correlation id for?
- Which header does Northline use, and is it required by HTTP?
- Two HTTP attempts and one idempotency key. How many business results?
- What is Northline's illustrative read target?
- What do you do after a token lands in a log?
Answers:
- To find every log line of one business action across systems.
X-Correlation-Id. It is Northline's choice, not a header HTTP requires.- One, if the server honoured the key.
- 99 of 100 item reads in a day return within 5 seconds, measured at the caller. It is illustrative.
- Remove it from the logging path, rotate the token, and check new lines.
Lesson summary
Monitor counts you can recompute. Log without secrets. Tie attempts to one correlation id and one idempotency key. A service target is a fraction the company or a contract defines, with the misses kept in the denominator.
Bridge to the next lesson
The last lesson assembles the whole path: ERP, APIs, a warehouse, Power BI, Copilot, and agents, with the inventory, the risks, and the rubric you use to judge the pack.