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

Support additional loggers, add metrics dimensions #58

Merged
merged 24 commits into from
Aug 24, 2020

Conversation

wi-y
Copy link
Contributor

@wi-y wi-y commented Aug 7, 2020

No description provided.

src/func/Microsoft.Health.Fhir.Ingest.Host/Startup.cs Outdated Show resolved Hide resolved
{
EnsureArg.IsNotNull(builder, nameof(builder));

builder.Services.AddSingleton<ITelemetryLogger>(sp =>
Copy link
Member

Choose a reason for hiding this comment

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

src/func/Microsoft.Health.Fhir.Ingest.Host/Startup.cs Outdated Show resolved Hide resolved
/// <summary>
/// The latency between event ingestion and output to FHIR processor.
/// </summary>
public static Metric MeasurementIngestionLatency()
Copy link
Member

Choose a reason for hiding this comment

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

Reason for a method instead of a read only property? This class could be simplified with readonly static properties.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was thinking we may wanted to add to the Metric later for PaaS if we wanted to add more dimensions in PaaS that aren't applicable in OSS.

Copy link
Member

Choose a reason for hiding this comment

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

But the method still returns a Metric object. It's static so it can't be overridden. Not following how the extension would be different if this is property instead of a method. Could you clarify please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was hoping to add some dimensions to the Metric object before we log the metric.

So for example if we had a DeviceEventProcessingLatency metric, we currently have 3 dimensions (name, category, stage), but let's say we want to add a 4th dimension for internal use which isn't applicable to OSS. Right before logging the metric I was hoping to modify the metric object dimensions by setting a 4th dimension key/value if it did not already exist.

I'm not positive on this, but thought that making the metric readonly would prevent us from being able to modify the metric object.

/// <summary>
/// The latency between event ingestion and output to FHIR processor.
/// </summary>
public static Metric MeasurementIngestionLatency()
Copy link
Member

Choose a reason for hiding this comment

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

But the method still returns a Metric object. It's static so it can't be overridden. Not following how the extension would be different if this is property instead of a method. Could you clarify please?

src/func/Microsoft.Health.Fhir.Ingest.Host/Startup.cs Outdated Show resolved Hide resolved
src/func/Microsoft.Health.Fhir.Ingest.Host/Startup.cs Outdated Show resolved Hide resolved
Copy link
Member

@dustinburson dustinburson left a comment

Choose a reason for hiding this comment

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

I am good with committing. Added two questions.

<PackageReference Include="Microsoft.Azure.EventHubs.Processor" Version="4.1.0" />
<PackageReference Include="Microsoft.Azure.WebJobs" Version="3.0.14" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.EventHubs" Version="3.0.6" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Http" Version="3.0.2" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="3.0.8" />
<PackageReference Include="Microsoft.Azure.WebJobs.Logging.ApplicationInsights" Version="3.0.14" />
Copy link
Member

Choose a reason for hiding this comment

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

Curious, what is the different between these two packages?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My understanding based on reading the code in the webjobs git repo is that the package Microsoft.Azure.WebJobs.Logging.ApplicationInsights is specific to Azure Functions and basically an extension of Microsoft.ApplicationInsights. The Microsoft.Azure.WebJobs.Logging.ApplicationInsights package contains a few additional things such as getting the Role, Host, etc of the function app (which we don't really need) but also includes some of the things we do need such as the adaptive sampling.


if (instrumentationKey != null)
{
var configDescriptor = builder.Services.SingleOrDefault(tc => tc.ServiceType == typeof(TelemetryConfiguration));
Copy link
Member

Choose a reason for hiding this comment

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

Would you be able to detail the issue you were hitting with prior suggested line of code? I am find continuing as is but I think I might want to take a look. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am thinking that the serviceProvider doesn't get built correctly or I just don't understand what it is doing.

I hit this error: System.InvalidOperationException: 'Unable to resolve service for type 'Microsoft.Azure.WebJobs.Script.IEnvironment' while attempting to activate 'Microsoft.Azure.WebJobs.Script.Configuration.ApplicationInsightsLoggerOptionsSetup'.'

with:

var serviceProvider = builder.Services.BuildServiceProvider();
var tconfig = serviceProvider.GetService(typeof(TelemetryConfiguration));

or

var serviceProvider = builder.Services.BuildServiceProvider();
var tconfig = serviceProvider.GetService();

@wi-y wi-y merged commit 13f9052 into master Aug 24, 2020
@dustinburson dustinburson deleted the personal/wiyochum/support-additional-loggers branch November 8, 2022 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants