Skip to content

[azsdk-cli] Add telemetry to sample translation#14271

Open
Copilot wants to merge 2 commits intomainfrom
copilot/add-telemetry-to-sample-translation
Open

[azsdk-cli] Add telemetry to sample translation#14271
Copilot wants to merge 2 commits intomainfrom
copilot/add-telemetry-to-sample-translation

Conversation

Copy link
Contributor

Copilot AI commented Mar 3, 2026

SampleTranslatorTool was missing the telemetry instrumentation already present in SampleGeneratorTool — no package info or sample count was captured for observability.

Changes

  • SampleTranslatorTool

    • Extended TranslateSamplesInternalAsync return tuple to include PackageInfo (target package)
    • Passes packageInfo to CreateSuccess so language, package_name, version, and package_type are promoted to telemetry tags via TelemetryProcessor
    • Sets response.Result = new { samples_count = result.TranslatedCount } matching the SampleGeneratorTool convention
  • SampleTranslatorToolTests

    • Added TranslateSamples_PopulatesTelemetryFields test verifying Language, PackageName, PackageType, Version, and samples_count are all correctly populated on a successful translation response
Original prompt

This section details on the original issue you should resolve

<issue_title>[azsdk-cli] Add telemetry to sample translation</issue_title>
<issue_description>Add telemetry to sample translation in the Azure SDK Agent</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…count)

Co-authored-by: deyaaeldeen <6074665+deyaaeldeen@users.noreply.github.com>
Copilot AI changed the title [WIP] Add telemetry to sample translation in Azure SDK [azsdk-cli] Add telemetry to sample translation Mar 3, 2026
@deyaaeldeen deyaaeldeen marked this pull request as ready for review March 3, 2026 21:00
@deyaaeldeen deyaaeldeen requested a review from a team as a code owner March 3, 2026 21:00
Copilot AI review requested due to automatic review settings March 3, 2026 21:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds missing telemetry-related fields to the SampleTranslatorTool response so sample translation operations provide the same observability signals as sample generation.

Changes:

  • Extends TranslateSamplesInternalAsync to return the target PackageInfo and passes it into PackageOperationResponse.CreateSuccess(...) so package metadata is populated on success responses.
  • Populates response.Result with samples_count to align with the SampleGeneratorTool response shape.
  • Adds a unit test ensuring Language, PackageName, PackageType, Version, and samples_count are present on a successful translation response.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
tools/azsdk-cli/Azure.Sdk.Tools.Cli/Tools/Package/Samples/SampleTranslatorTool.cs Includes target package metadata in success responses and adds samples_count into the result payload.
tools/azsdk-cli/Azure.Sdk.Tools.Cli.Tests/Tools/Package/Samples/SampleTranslatorToolTests.cs Adds coverage to verify the response carries the expected telemetry-relevant fields.

Comment on lines +169 to +177
var response = result.TranslatedCount == 0
? PackageOperationResponse.CreateSuccess(
$"No samples found to translate from {result.SourceLanguage}.",
nextSteps: ["Verify the source package has sample files", "Check the samples directory exists"]);
}

return PackageOperationResponse.CreateSuccess(
$"Successfully translated {result.TranslatedCount} sample(s) from {result.SourceLanguage} to {result.TargetLanguage}: {result.FileNames}",
nextSteps: ["Review the translated samples", "Test the samples to ensure they compile and run correctly"]);
packageInfo: result.PackageInfo,
nextSteps: ["Verify the source package has sample files", "Check the samples directory exists"])
: PackageOperationResponse.CreateSuccess(
$"Successfully translated {result.TranslatedCount} sample(s) from {result.SourceLanguage} to {result.TargetLanguage}: {result.FileNames}",
packageInfo: result.PackageInfo,
nextSteps: ["Review the translated samples", "Test the samples to ensure they compile and run correctly"]);
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

The success message for the TranslatedCount == 0 path always says "No samples found to translate", but TranslateSamplesInternalAsync can also return 0 when samples exist but none were written (e.g., Copilot returns an empty list, or all outputs already exist and overwrite is false). This can mislead users; consider returning additional state from TranslateSamplesInternalAsync (e.g., discovered count / skipped-existing count) or adjusting the message to reflect "no samples translated/written" rather than "no samples found".

Copilot uses AI. Check for mistakes.
Comment on lines +179 to +180
// Set samples_count for telemetry tracking (including 0 for failed translations)
response.Result = new { samples_count = result.TranslatedCount };
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

The comment says samples_count is set "including 0 for failed translations", but this assignment only happens on the success path (after TranslateSamplesInternalAsync returns). Failures returned from the validation/exception handlers won't include samples_count. Please update the comment (or set samples_count in failure responses as well if that’s required).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[azsdk-cli] Add telemetry to sample translation

3 participants