Skip to content
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

Expose TelemetryClient.TelemetryConfiguration publically. #581

Closed
macrogreg opened this issue Jul 6, 2017 · 3 comments
Closed

Expose TelemetryClient.TelemetryConfiguration publically. #581

macrogreg opened this issue Jul 6, 2017 · 3 comments

Comments

@macrogreg
Copy link
Contributor

TelemetryClient brings together 3 concepts: Properties of items sent through it (Context), information about how and where to send the items (TelemetryConfiguration) and APIs to do the sending (TrackXxx(..) methods). Although both of the former aspects are required to create a client (TelemetryConfiguration.Active is used as default, but implicitly, that information is still encapsulated), only the Context is exposed outside of Core.

This is unfortunate: A consumer of a TelemetryClient may want to access information about how and where the client will deliver data. For example, metrics are aggregated across all clients within the same configuration, but separately between pipeline configurations. So, aggregation logic needs to be able to ask a client, what its telemetry configuration instance is.

The proposed change is to make the existing internal TelemetryClient.TelemetryConfiguration property public.

@SergeyKanzhelev
Copy link
Contributor

It was explicitly made private so there will be no confusion and undesired consequences. When one changes anything in TelemetryClient.Configuration the change can affect other clients. This can be unexpected.

We also never had a real life scenarios where this was needed and not enough just to keep configuration object around.

@macrogreg
Copy link
Contributor Author

I see this as a yet another of the TelemetryClient layering. :(
My goal is to build an extension method outside of Core that does something like that (very simplified):

public static void TrackMetricValue(this TelemetryClient client, string metric, double value)
{
client.TelemetryConfiguration.GetMetricAggregator(metric).TrackValue(value);
}

If there is an alternative way to achieve this effect, please let me know so I can explore it.

@macrogreg macrogreg reopened this Jul 6, 2017
@macrogreg
Copy link
Contributor Author

I am looking at this method:

    /// <summary>
    /// This method is an internal part of Application Insights infrastructure. Do not call.
    /// </summary>
    /// <param name="telemetry">Telemetry item to initialize.</param>
    [EditorBrowsable(EditorBrowsableState.Never)]
    public void Initialize(ITelemetry telemetry)
    {
            ...

We could consider a similar approach.

@Dmitry-Matveev Dmitry-Matveev added this to the Future milestone Oct 11, 2017
TimothyMothra pushed a commit that referenced this issue Oct 25, 2019
rajkumar-rangaraj added a commit that referenced this issue Jul 20, 2020
Fix #581 (Changed TelemetryConfiguration property of TelemetryClient from internal to public.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants