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

Proper intended usage of ITelemetry.Context.GlobalProperties #923

Closed
ScottArbeit opened this issue Sep 22, 2018 · 9 comments
Closed

Proper intended usage of ITelemetry.Context.GlobalProperties #923

ScottArbeit opened this issue Sep 22, 2018 · 9 comments
Labels

Comments

@ScottArbeit
Copy link

Hi!

I'm changing over to using .GlobalProperties, and I have a quick question about the intention behind it.

In my ASP.NET Core app, I have a CustomTelemetryInitializer class, and in my Initialize() implementation I put about a dozen properties on each telemetry item. Three of those properties have constant values that will not change for the lifetime of the app instance; obviously those should go into .GlobalProperties.

The other properties I capture in Initialize() may change values between each new telemetry item being created (for instance, currentProcess.Threads.Count and currentProcess.HandleCount). So... the same property keys are on every telemetry item, but the property values are different.

Are those properties - the kind where I have the same keys on every item from my app, but values that change over time - intended for .GlobalProperties?

(I also populate ISupportProperties.Properties with details from each call site, obviously they're not global.)

I guess I'm asking if the "global" part of .GlobalProperties applies to the pair <key, value> or just the key. Just looking for the best way to take advantage of the new API surface and any indexing changes you make in the back-end.

Thanks!

@cijothomas
Copy link
Contributor

#820 - Can you take a look at this and see if it helps answer your question?

@ScottArbeit
Copy link
Author

Thank you... I did already read that, but I didn't find it clear how I should take advantage of it. (I love Application Insights, I'm just trying to use it correctly.) To me, what #820 says is, essentially, "we're making a change to the API to help the back-end behave differently... and here are a couple of ways that might happen", but it doesn't make it clear (to me, anyway) how I should use .GlobalProperties to fit with that new usage.

Here are some things I'm wondering about that hopefully give some orientation to the answer (and the documentation) that I'm looking for:

If I have the same key in .GlobalProperties on every telemetry item, but a changing value over time -- let's call it "medium cardinality", with clusters of values, but let's imagine that any given value will appear in less than 1% of the total telemetry items -- is that OK for what you're expecting the new back-end features to handle, or what the UI will show? I get that, whatever I do, you'll make it work, but will it work the way you're planning on? What does "high cardinality" vs. "low cardinality" mean in this context? Is there a specific percentage that a <key, value> pair should appear that makes the difference between whether I should use .GlobalProperties or .Properties?

Just putting my API Design hat on for a second (and I'm not suggesting a late name change, just thinking out loud)... calling it .GlobalProperties is part of what's confusing for me. What's "global" about it? What does that mean, exactly? What if only 70% of my telemetry items have a particular .GlobalProperties key in them... does that mean I'm using it wrong, and I should instead just use ISupportProperties.Properties?

If I use the same Application Insights instance for my back-end server AI telemetry, and my front-end browser AI telemetry, is that still OK? The things that I think of as "global" for my front-end are different from what I consider to be "global" for my ASP.NET Core back-end. Maybe it's more of a .ContextProperties construct? (Ugh, naming is hard. 🤔)

Or maybe I'm going to love the proposed new UI features to allow for fast filtering by keys in .GlobalProperties... in fact, I'll love them so much that "why wouldn't I just put all of my items in there and get that UI filtering feature on everything?!?" I expect that would mess up the algorithms you're choosing for each different property bag, but maybe not?

I'm sure you have a clear intention for this feature beyond what was in #820, but from the usage side, with no other documentation and no UI to look at, I'm still not clear about it. Do you have any examples you've worked through while developing .GlobalProperties, or customer pain stories that this solves, that help make it more clear?

Thanks... I really appreciate your time on this. 🙂

@cijothomas
Copy link
Contributor

@ScottArbeit Been busy with some deliverables. I will read this again and respond! Thanks for your patience.

@cijothomas
Copy link
Contributor

@ScottArbeit If the number of keys remains low, but the values vary a lot - its high cardinality and belong to ISupportProperties.Properties. GlobalProperties is intended for values which are low in cardinality.
I cannot yet give an exact answer to what is the number above which things become high - because, as of now, both Properties and GlobalProperties are serialized into same list in the wire-format, and AI back end does not make any distinction.

"Global" name was used to distinguish from a property from being applicable to just an individual telemetry item (eg: operation id etc.) vs entire application (eg: name of cloud instance).

We'll eventually change serialization formats and then changes in backend as well - I don't yet have a shareable timeline, but it'll most likely be in a 3.xx version of the SDK. (we are about to ship 2.8 in couple weeks).

Let me know if this helped with your question (atleast partially!). Do share your comments and feedbacks.

@zvolkov
Copy link

zvolkov commented Feb 26, 2019

Can someone please confirm it is safe to use ITelemetry.TelemetryContext.GlobalProperties to carry values that vary by say ASP.NET MVC Request? In other words, can someone confirm "Global" does not mean "App-Global" or "App-Domain"? If I have multiple web requests running in parallel, each one will have its own TelemetryContext and hence its own GlobalProperties, correct?

@cijothomas
Copy link
Contributor

While its safe to use GlobalProperties for things which vary by request, but it's best to use ISupportProperties.Properties, if the cardinality of values for the field is high.

@cijothomas
Copy link
Contributor

If I have multiple web requests running in parallel, each one will have its own TelemetryContext and hence its own GlobalProperties, correct? - This is correct. TelemetryContext is per TelemetryItem. (there is alsoa way to set TelemetryContext on TelemetryClient itself, which would be shared)

@zvolkov
Copy link

zvolkov commented Feb 27, 2019

Okay, this made it clear. The low cardinality of values is the main criteria. Thanks!

@github-actions
Copy link

This issue is stale because it has been open 300 days with no activity. Remove stale label or comment or this will be closed in 7 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants