Skip to content

Add telemetry client only if it is enabled#1868

Merged
Aniruddh25 merged 4 commits intomainfrom
fixAppInsights
Nov 9, 2023
Merged

Add telemetry client only if it is enabled#1868
Aniruddh25 merged 4 commits intomainfrom
fixAppInsights

Conversation

@Aniruddh25
Copy link
Copy Markdown
Collaborator

Why make this change?

  • Saw this exception while running locally via VS:

image

  • it is triggered asynchronously when the grapqhql schema is being generated in the background
  • Also, noticed telemetry client is being added irrespective of it is enabled or not.

What is this change?

  • Add AppInsights Telemetry only when it is enabled.
  • Use TryAdd instead of simply doing an Add to the dictionary of global properties in the Initialize function that is used to initialize any telemetry object.
  • Depending on if the telemetry object had already been initialized with the 2 global properties we intend to add, they may or may not be already present. Examples of such telemetry objects include MetricsTelemetry, DependencyTelemetry etc.

How was this tested?

  • Reran the engine to verify the exception was gone upon starting.
  • Added asserts in TelemetryTests to verify the client is created only when telemetry is enabled.

@Aniruddh25
Copy link
Copy Markdown
Collaborator Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 6 pipeline(s).

Copy link
Copy Markdown
Contributor

@abhishekkumams abhishekkumams left a comment

Choose a reason for hiding this comment

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

Thanks for addressing this.

@Aniruddh25 Aniruddh25 enabled auto-merge (squash) November 8, 2023 19:40
@Aniruddh25 Aniruddh25 disabled auto-merge November 8, 2023 19:41
@Aniruddh25 Aniruddh25 enabled auto-merge (squash) November 8, 2023 20:13
@Aniruddh25
Copy link
Copy Markdown
Collaborator Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 6 pipeline(s).

Copy link
Copy Markdown
Contributor

@aaronburtle aaronburtle left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for adding quickly

@Aniruddh25 Aniruddh25 merged commit 8707c63 into main Nov 9, 2023
@Aniruddh25 Aniruddh25 deleted the fixAppInsights branch November 9, 2023 09:26
@Aniruddh25 Aniruddh25 added the port needed Describes if port to release branch is required label Nov 13, 2023
Aniruddh25 added a commit that referenced this pull request Nov 13, 2023
## Why make this change?

- Saw this exception while running locally via VS:


![image](https://github.com/Azure/data-api-builder/assets/3513779/3d2b827d-de56-4cbb-9982-fcf8e9f339ce)

- it is triggered asynchronously when the grapqhql schema is being
generated in the background
- Also, noticed telemetry client is being added irrespective of it is
enabled or not.

## What is this change?
- Add AppInsights Telemetry only when it is enabled.
- Use `TryAdd` instead of simply doing an `Add` to the dictionary of
global properties in the Initialize function that is used to initialize
any telemetry object.
- Depending on if the telemetry object had already been initialized with
the 2 global properties we intend to add, they may or may not be already
present. Examples of such telemetry objects include `MetricsTelemetry`,
`DependencyTelemetry` etc.

## How was this tested?

- Reran the engine to verify the exception was gone upon starting.
- Added asserts in TelemetryTests to verify the client is created only
when telemetry is enabled.
Aniruddh25 added a commit that referenced this pull request Nov 13, 2023
## Why make this change?

This is simply cherry-picking the following PRs before creating the next
stable 0.9 version:

- #1876
- #1821 
- #1854 
- #1851 
- #1872 
- #1868

---------

Co-authored-by: Sean Leonard <[email protected]>
Co-authored-by: Abhishek  Kumar <[email protected]>
Co-authored-by: neeraj-sharma2592 <[email protected]>
Co-authored-by: Neeraj Sharma (from Dev Box) <[email protected]>
Co-authored-by: aaronburtle <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

port needed Describes if port to release branch is required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants