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

Adding compiler data to AppInsights #404

Merged
merged 22 commits into from
Jul 27, 2021

Conversation

eddynaka
Copy link
Contributor

@eddynaka eddynaka commented Jul 7, 2021

No description provided.

@eddynaka eddynaka force-pushed the users/ednakamu/application-insights-compiler-data branch from 3af6b99 to d7d01f9 Compare July 12, 2021 23:35
@lgtm-com
Copy link

lgtm-com bot commented Jul 15, 2021

This pull request fixes 2 alerts when merging fd254b4 into cbae8ad - view on LGTM.com

fixed alerts:

  • 2 for Dereferenced variable may be null

@eddynaka eddynaka marked this pull request as ready for review July 15, 2021 12:16
@lgtm-com
Copy link

lgtm-com bot commented Jul 15, 2021

This pull request fixes 2 alerts when merging b0f5106 into ad9e840 - view on LGTM.com

fixed alerts:

  • 2 for Dereferenced variable may be null

@microsoft microsoft deleted a comment from lgtm-com bot Jul 15, 2021
@microsoft microsoft deleted a comment from lgtm-com bot Jul 15, 2021
@microsoft microsoft deleted a comment from lgtm-com bot Jul 15, 2021
@microsoft microsoft deleted a comment from lgtm-com bot Jul 15, 2021
@microsoft microsoft deleted a comment from lgtm-com bot Jul 15, 2021
@microsoft microsoft deleted a comment from lgtm-com bot Jul 15, 2021
@lgtm-com
Copy link

lgtm-com bot commented Jul 15, 2021

This pull request fixes 2 alerts when merging aedb1eb into 350fcf6 - view on LGTM.com

fixed alerts:

  • 2 for Dereferenced variable may be null

@michaelcfanning
Copy link
Member

michaelcfanning commented Jul 16, 2021

    private const string SECTIONNAME_DEBUG_INFO = "__debug_info";

these strings are neither alphabetized nor are they sorted by line length.

can we sort by line length? makes things more readable.


In reply to: 881621666


In reply to: 881621666


In reply to: 881621666


Refers to: src/BinaryParsers/MachOBinary/SingleMachOBinary.cs:16 in aedb1eb. [](commit_id = aedb1eb, deletion_comment = False)


[Option(
"repository-uri",
HelpText = "RepositoryUri is required to rule BA4001 and BA4002.")]
Copy link
Member

Choose a reason for hiding this comment

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

RepositoryUri is required to rule BA4001 and BA4002

Whenever you show an opaque rule id to the user, you should add the readable name. Not everyone can remember what BA4001 is. Also, you've described a fact here 'this data is required to run rule BA4001.ReportPECompilerData' but you haven't described what that data is.

What is this data? Does it make sense that we require a single repo URL for a scan run??

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 changed the helptext. Let me know what do you think.

About your question...I thought about it, and I could not find anything better based on this:
https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml

my idea was to find one pre-defined variable that any pipeline would be able to get.


[Option(
"pipeline-name",
HelpText = "PipelineName is required to rule BA4001 and BA4002.")]
Copy link
Member

@michaelcfanning michaelcfanning Jul 16, 2021

Choose a reason for hiding this comment

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

PipelineName

same note, what is this data? you don't describe it. #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated the helptext, pls, review :)

Console.Write($"{file},");
Console.Write($"{context?.Hashes?.Sha256},");
Console.WriteLine();
context.CompilerDataLogger.Write(compiler.Compiler.ToString(), compiler.Version.ToString(), language, file);
Copy link
Member

@michaelcfanning michaelcfanning Jul 16, 2021

Choose a reason for hiding this comment

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

CompilerDataLogger

why is it ok that some data has gotten dropped? such as the sha256 has? #ByDesign

Copy link
Contributor Author

Choose a reason for hiding this comment

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

where I create the CompilerDataLogger, i pass the context. from it I retrieve information such as hash. With that, i can remove from here and just pass the data that i dont have during construction of compilerDataLogger

Console.Write(context.TargetUri.LocalPath + ",");
Console.WriteLine($",,,,,,{context?.Hashes?.Sha256},{target.PdbParseException.Message}");
string errorMessage = target.PdbParseException.Message;
context.CompilerDataLogger.WriteException(errorMessage);
Copy link
Member

@michaelcfanning michaelcfanning Jul 16, 2021

Choose a reason for hiding this comment

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

CompilerDataLogger

what about the hash data? #ByDesign

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the hash is constructed with the CompilerDataLogger, so we don't need to worry here.


s_telemetryClient.TrackEvent(CompilerEventName, properties: new Dictionary<string, string>
{
{ "repositoryUri", repositoryUri ?? string.Empty },
Copy link
Member

@michaelcfanning michaelcfanning Jul 16, 2021

Choose a reason for hiding this comment

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

repositoryUri

you say in your help comments that this data is required, but it doesn't look like it's required. it's optional.

i think you meant you say that this data is only consumed by the compiler reporting rules, and not relevant otherwise. #Closed

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 changed the relevant code to throw an argumentNullException in case repositoryUri or pipelineName is null/empty.

With that, i cleaned the code

{
{ "repositoryUri", repositoryUri ?? string.Empty },
{ "pipelineName", pipelineName ?? string.Empty },
{ "target", this.localPath },
Copy link
Member

@michaelcfanning michaelcfanning Jul 16, 2021

Choose a reason for hiding this comment

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

localPath

why are we sending absolute paths? is this right? might this data expose some unwanted information, like a user alias? #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

made a change to transform the localPath to a relativeFilePath base on the targetFileSpecifiers

{ "pipelineName", pipelineName ?? string.Empty },
{ "target", this.localPath },
{ "compilerName", compilerDataParts[0] },
{ "compilerBackEndVersion", compilerDataParts[1] },
Copy link
Member

@michaelcfanning michaelcfanning Jul 16, 2021

Choose a reason for hiding this comment

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

compilerDataParts[1]

look at these 'magic constants' where we have special knowledge that backend version is in the first piece.

that tends to be pretty fragile, it might be better for this helper to break out all this data and require the caller to parse into the format.
#Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed!

}
else
{
Console.Write($"{repositoryUri},");
Copy link
Member

@michaelcfanning michaelcfanning Jul 16, 2021

Choose a reason for hiding this comment

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

Write

Note that it'd be more performant to concatenate all this information into a single string and then pass it to WriteLine.
#Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link
Member

@michaelcfanning michaelcfanning left a comment

Choose a reason for hiding this comment

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

🕐

@eddynaka
Copy link
Contributor Author

    private const string SECTIONNAME_DEBUG_INFO = "__debug_info";

fixed.


In reply to: 881621666


Refers to: src/BinaryParsers/MachOBinary/SingleMachOBinary.cs:16 in aedb1eb. [](commit_id = aedb1eb, deletion_comment = False)

@lgtm-com
Copy link

lgtm-com bot commented Jul 16, 2021

This pull request fixes 2 alerts when merging 9d21968 into be2289a - view on LGTM.com

fixed alerts:

  • 2 for Dereferenced variable may be null

@lgtm-com
Copy link

lgtm-com bot commented Jul 17, 2021

This pull request fixes 2 alerts when merging 7ce6027 into be2289a - view on LGTM.com

fixed alerts:

  • 2 for Dereferenced variable may be null

@lgtm-com
Copy link

lgtm-com bot commented Jul 17, 2021

This pull request fixes 2 alerts when merging 5112e4a into be2289a - view on LGTM.com

fixed alerts:

  • 2 for Dereferenced variable may be null

@lgtm-com
Copy link

lgtm-com bot commented Jul 26, 2021

This pull request fixes 2 alerts when merging 4fb5fbc into be2289a - view on LGTM.com

fixed alerts:

  • 2 for Dereferenced variable may be null

@lgtm-com
Copy link

lgtm-com bot commented Jul 26, 2021

This pull request fixes 2 alerts when merging a6a3632 into be2289a - view on LGTM.com

fixed alerts:

  • 2 for Dereferenced variable may be null

@lgtm-com
Copy link

lgtm-com bot commented Jul 27, 2021

This pull request fixes 2 alerts when merging 843eeed into be2289a - view on LGTM.com

fixed alerts:

  • 2 for Dereferenced variable may be null

@lgtm-com
Copy link

lgtm-com bot commented Jul 27, 2021

This pull request fixes 2 alerts when merging 2ddf392 into be2289a - view on LGTM.com

fixed alerts:

  • 2 for Dereferenced variable may be null

@lgtm-com
Copy link

lgtm-com bot commented Jul 27, 2021

This pull request fixes 2 alerts when merging 0c7b53b into be2289a - view on LGTM.com

fixed alerts:

  • 2 for Dereferenced variable may be null

@lgtm-com
Copy link

lgtm-com bot commented Jul 27, 2021

This pull request fixes 2 alerts when merging ed8cb64 into be2289a - view on LGTM.com

fixed alerts:

  • 2 for Dereferenced variable may be null

Copy link
Member

@michaelcfanning michaelcfanning left a comment

Choose a reason for hiding this comment

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

:shipit:

@eddynaka eddynaka merged commit aa1f867 into main Jul 27, 2021
@eddynaka eddynaka deleted the users/ednakamu/application-insights-compiler-data branch July 27, 2021 21:57
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.

2 participants