Skip to content

Multitenant logs support - #62885

Merged
Harsimar Kaur (harsimar) merged 4 commits into
mainfrom
harskaur/multitenantLogs
Sep 10, 2026
Merged

Harsimar Kaur (harsimar) merged 4 commits into
mainfrom
harskaur/multitenantLogs

Conversation

@harsimar

Copy link
Copy Markdown
Member

Bare minimum implentation for multitenant logs support
Not in scope:

  • AAD

  • Live Metrics

  • appending the ikey/endpoint attrs via log scopes

  • No changes made to sampling code for trace based logs sampling, but there are tests that verify sampling behavior

Extend the trace multi-tenant routing mechanism to AzureMonitorLogExporter /
LogRecord: route logs to the correct ingestion endpoint based on the
microsoft.instrumentation_key / microsoft.ingestion_endpoint attributes,
reusing the existing signal-agnostic transmitter/storage/redirect plumbing.
Off by default behind the same EnableMultiTenantExport switch.

- TenantRouting: add raw-string TryGetRoute overload sharing validation.
- LogsHelper: add TryGetLogRoute, BuildLogTelemetryItem, and
  OtelToAzureMonitorLogsMultiTenant; consume routing tags via
  recognizeRoutingTags in ProcessLogRecordProperties/ExtractAvailabilityInfo.
- AzureMonitorLogExporter: multi-tenant gate + pooled EndpointRouteBatch export.
- Generalize event 61 message ("Telemetry is routed") and add CHANGELOG entry.
- Tests: MultiTenantLogRoutingTests (routing, parity, availability ordering,
  exporter gate, trace-based filtering, persist-on-shutdown Track path).
- Demo: MultiTenantLogDemo wired into Program.cs via "multitenant logs".

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: dacfc0c4-4e41-460d-a866-cffed26f9bff
Reword the "no routing attributes" comments to explain the mechanism
(routing attributes are stamped upstream only on records meant to be
routed) instead of asserting a deployment-specific assumption about how
many tenants enable observability. Comment-only; no behavior change.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: dacfc0c4-4e41-460d-a866-cffed26f9bff
GenerateLogs now cycles through the four shapes the log exporter can
produce - trace (MessageData), exception (ExceptionData), custom event
(EventData), and availability (AvailabilityData) - by attaching the
classifying microsoft.* attributes through a list-valued log state.
Enable IncludeFormattedMessage so event/availability bodies survive.

Verified end to end: routed, persisted envelopes carry ExceptionData,
EventData, MessageData, and AvailabilityData under the tenant iKeys.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: dacfc0c4-4e41-460d-a866-cffed26f9bff
Copilot AI balanced review requested due to automatic review settings September 10, 2026 18:12
@github-actions github-actions Bot added the Monitor - Exporter Monitor OpenTelemetry Exporter label Sep 10, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Failed log conversion can leave and transmit an empty endpoint group, and the changelog structure needs restoration.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds opt-in multi-tenant routing for logs alongside existing trace routing.

Changes:

  • Routes log telemetry by instrumentation key and endpoint attributes.
  • Adds exporter, sampling, shutdown, and conversion tests.
  • Adds a multi-tenant logging demo and diagnostics.
File summaries
File Description
MultiTenantLogRoutingTests.cs Tests log routing and exporter behavior.
MultiTenantTraceDemo.cs Shares HTTP policies with the log demo.
Program.cs Adds log demo selection and execution.
MultiTenantLogDemo.cs Generates routed multi-tenant logs.
TenantRouting.cs Shares route validation across signals.
LogsHelper.cs Converts and groups routed logs.
AzureMonitorExporterEventSource.cs Generalizes the enablement diagnostic.
AzureMonitorLogExporter.cs Adds opt-in multi-tenant export.
CHANGELOG.md Documents multi-tenant log support.
Review details
  • Files reviewed: 9/9 changed files
  • Comments generated: 3
  • Review effort level: Balanced

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/CHANGELOG.md
PR #62707 (multi-tenant trace export) merged 2026-09-09, after the
1.9.0 exporter release dated 2026-09-04, so its changelog entry was
misplaced under the already-released 1.9.0 section. Move it up to the
unreleased 1.10.0-beta.1 Features Added section alongside the logs entry.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: dacfc0c4-4e41-460d-a866-cffed26f9bff
@harsimar
Harsimar Kaur (harsimar) merged commit c73ee6b into main Sep 10, 2026
26 checks passed
@harsimar
Harsimar Kaur (harsimar) deleted the harskaur/multitenantLogs branch September 10, 2026 20:41
[NotNullWhen(true)] out string? instrumentationKey,
[NotNullWhen(true)] out string? ingestionEndpoint)
{
ingestionEndpoint = null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this comment is coming in post merge, still wanted to post it here for consideration.

Do we need to add any debugging/logging here so we can troubleshoot why data is not flowing to a destination. I'm sure we are going to be asked why data isn't flowing and w/o a clear way to identify misconfiguration, we will be in trouble.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Monitor - Exporter Monitor OpenTelemetry Exporter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants