Skip to content

Update trace-application.md #513

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Lin-ux-404
Copy link

Updated telemetry documentation reference

Replaced incorrect usage of a non-existent method get_connection_string() with the correct get_application_insights_connection_string() when retrieving the Application Insights connection string.


Context

I initially followed the docs:

project = AIProjectClient(
    credential=DefaultAzureCredential(),
    endpoint=os.getenv("AZURE_AI_FOUNDRY_ENDPOINT"),
)
tracer = trace.get_tracer(__name__)
connection_string = project.telemetry.get_connection_string()
configure_azure_monitor(connection_string=connection_string)

This resulted in the following error:

Traceback (most recent call last):  line 21, in <module>
    connection_string = project.telemetry.get_connection_string()
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'TelemetryOperations' object has no attribute 'get_connection_string'. Did you mean: '_connection_string'?

Investigation

I checked the source code of the SDK and found this in the TelemetryOperations class:

class TelemetryOperations:
    """
    .. warning::
        **DO NOT** instantiate this class directly.

        Instead, you should access the following operations through
        :class:`~azure.ai.projects.AIProjectClient`'s
        :attr:`telemetry` attribute.
    """

    _connection_string: Optional[str] = None

    def __init__(self, outer_instance: "azure.ai.projects.AIProjectClient") -> None:  # type: ignore[name-defined]
        self._outer_instance = outer_instance

    @distributed_trace
    def get_application_insights_connection_string(self) -> str:  # pylint: disable=name-too-long

Resolution

Switching to the correct method resolved the issue:

project = AIProjectClient(
    credential=DefaultAzureCredential(),
    endpoint=os.getenv("AZURE_AI_FOUNDRY_ENDPOINT"),
)

tracer = trace.get_tracer(__name__)

connection_string = project.telemetry.get_application_insights_connection_string()
configure_azure_monitor(connection_string=connection_string)

### Updated telemetry documentation reference

Replaced incorrect usage of a non-existent method `get_connection_string()` with the correct `get_application_insights_connection_string()` when retrieving the Application Insights connection string.

---

#### Context

I initially followed the docs:

```python
project = AIProjectClient(
    credential=DefaultAzureCredential(),
    endpoint=os.getenv("AZURE_AI_FOUNDRY_ENDPOINT"),
)
tracer = trace.get_tracer(__name__)
connection_string = project.telemetry.get_connection_string()
configure_azure_monitor(connection_string=connection_string)
```

This resulted in the following error:
```
Traceback (most recent call last):  line 21, in <module>
    connection_string = project.telemetry.get_connection_string()
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'TelemetryOperations' object has no attribute 'get_connection_string'. Did you mean: '_connection_string'?
```

#### Investigation
I checked the source code of the SDK and found this in the TelemetryOperations class:

```python
class TelemetryOperations:
    """
    .. warning::
        **DO NOT** instantiate this class directly.

        Instead, you should access the following operations through
        :class:`~azure.ai.projects.AIProjectClient`'s
        :attr:`telemetry` attribute.
    """

    _connection_string: Optional[str] = None

    def __init__(self, outer_instance: "azure.ai.projects.AIProjectClient") -> None:  # type: ignore[name-defined]
        self._outer_instance = outer_instance

    @distributed_trace
    def get_application_insights_connection_string(self) -> str:  # pylint: disable=name-too-long
```

#### Resolution
Switching to the correct method resolved the issue:

```python
project = AIProjectClient(
    credential=DefaultAzureCredential(),
    endpoint=os.getenv("AZURE_AI_FOUNDRY_ENDPOINT"),
)

tracer = trace.get_tracer(__name__)

connection_string = project.telemetry.get_application_insights_connection_string()
configure_azure_monitor(connection_string=connection_string)
```
Copy link
Contributor

@Lin-ux-404 : Thanks for your contribution! The author(s) and reviewer(s) have been notified to review your proposed change.

Copy link
Contributor

Learn Build status updates of commit 19fd0e0:

✅ Validation status: passed

File Status Preview URL Details
articles/ai-foundry/how-to/develop/trace-application.md ✅Succeeded

For more details, please refer to the build report.

@v-dirichards
Copy link
Contributor

@lgayhardt

Can you review the proposed changes?

Important: When the changes are ready for publication, adding a #sign-off comment is the best way to signal that the PR is ready for the review team to merge.

#label:"aq-pr-triaged"
@MicrosoftDocs/public-repo-pr-review-team

@prmerger-automator prmerger-automator bot added the aq-pr-triaged C+L Pull Request Review Team label label Aug 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants