-
Notifications
You must be signed in to change notification settings - Fork 205
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
Added check for TelemetryConfiguration#getInstrumentationKey emptiness #516
Added check for TelemetryConfiguration#getInstrumentationKey emptiness #516
Conversation
Without this change it is impossible to load instrumentation key from active configuration if it was updated after TelemetryClient creation.
c59cdf2
to
c407311
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gavlyukovskiy change looks fine to me. Just one question as you mentioned that you need to check if instrumentration key is updated after initialization, could there be a case when this (Strings.isNullOrEmpty(configuration.getInstrumentationKey()) && Strings.isNullOrEmpty(getContext().getInstrumentationKey())) condition return false but should return true. I mean in case of non spring boot environment?
I don't think it's real scenario, but it could happen when instrumentation key was not set at the moment of |
I don't know the ideal solution here. May be this might work for the time being as it is practically very rare for such a situation to happen. However, we might need to think on creating some kind of Factory for generating TelemetryClient objects instead of using new. In this way we might be able to make sure that instrumentation key and configuration value is always retained. @gavlyukovskiy thoughts? |
As far as Anyhow this seems to me like a bug, because mechanism to reload key from
and this code is never executed because of |
@gavlyukovskiy If I understand this correctly - you are saying that most of the modules are initialized from SpringBoot with empty key where as TelemetryConfiguration would have Instrumentation key set by spring boot so the whole purpose then would be to inject the empty clients with key from configuration. In this context |
Yes, this is the only reason basically. Honestly I don't follow intention of using |
I think the reason behind storing instrumentation key in TelemetryContext is because this holds the meta-data which is sent to AI service with each telemetry instance and it also contains iKey. According to you this method should be trimmed to following
correct? We might wan't to take that route eventually, but it would be better to play the safer game for the time being and go with the changes you have commited unless there is a clear understanding that we do not break anything with this change. Let me know your thoughts. |
@gavlyukovskiy , @dhaval24 |
@littleaj Hi, I added such test in PR #518 - ApplicationInsightsTelemetryAutoConfigurationTests#shouldReloadInstrumentationKeyOnTelemetryClient Without spring boot specifics it looks like this:
|
@gavlyukovskiy I think it would make sense to move this PR against spring-boot-starter branch as well. Please merge latest master and with this changes and convert the PR to point to "spring-boot-starter" branch. |
Without this change it is impossible to load instrumentation key from active configuration if it was updated after
TelemetryClient
creation.I need this in order to pick up instrumentation key that was set from spring configuration.