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

Exceptions in static blocks blocks not caught/recorded #295

Open
yevster opened this issue Jun 24, 2019 · 2 comments · May be fixed by #702
Open

Exceptions in static blocks blocks not caught/recorded #295

yevster opened this issue Jun 24, 2019 · 2 comments · May be fixed by #702
Assignees
Milestone

Comments

@yevster
Copy link

yevster commented Jun 24, 2019

When an exception occurs in a static initialization, it is not logged in AppInsights.

Investigative information

Please provide the following:

  • Timestamp: 2019-06-21T17:48:38.384
  • Invocation ID: 48d86a7c24b1354196e9c0c9b6ee7d19
  • Region: Central US

Repro steps

Here's a sample function to reproduce:

package com.yevster;

import java.io.IOException;
import java.net.MalformedURLException;
import java.util.Optional;

import com.microsoft.azure.functions.ExecutionContext;
import com.microsoft.azure.functions.HttpMethod;
import com.microsoft.azure.functions.HttpRequestMessage;
import com.microsoft.azure.functions.HttpResponseMessage;
import com.microsoft.azure.functions.HttpStatus;
import com.microsoft.azure.functions.annotation.AuthorizationLevel;
import com.microsoft.azure.functions.annotation.FunctionName;
import com.microsoft.azure.functions.annotation.HttpTrigger;

public class ProtoFunction {
	static {
		//Puke!
		Optional.empty().orElseThrow(()->new RuntimeException("Life isn't fair!"));
	}
	
	@FunctionName("prototype")
	public HttpResponseMessage run(@HttpTrigger(name = "req", methods = {
			HttpMethod.GET }, authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<byte[]>> request,
			final ExecutionContext context) throws MalformedURLException, IOException {
	
		return request.createResponseBuilder(HttpStatus.OK).header("Content-Type", "text/html").body("<html><body><h1>Rejoice! All is well!</h1></body></html>").build();
	}
}

And here's what AppInsights shows when queried for all exceptions and trace messages after invocation of that function:

noexceptionlogged.jpg

Expected behavior

Provide a description of the expected behavior.

The exception thrown from the static block is recorded in App Insights.

Actual behavior

The exception thrown from the static block is not recorded in App Insights.

Known workarounds

Do not use any static code.

@pragnagopa pragnagopa added this to the Triaged milestone Jul 5, 2019
@pragnagopa pragnagopa added the P1 label Jul 5, 2019
@kulkarnisonia16 kulkarnisonia16 added P2 and removed P1 labels Sep 18, 2019
@kulkarnisonia16
Copy link

kulkarnisonia16 commented Sep 18, 2019

@amamounelsayed - Check if this happens in other languages. Also, check if this will be part of appInsights work.

@maschoene
Copy link

I just want to add, that (at least) when using @ServiceBusQueueTrigger, the output will only be that the function timeouted without any reason or hint that a class initialization failed. Support only suggested upgrading function runtime to 4.x (does not help), check logs (nothing to see) and verify Application Insights (nothing to see)

grafik

@kaibocai kaibocai assigned kaibocai and unassigned amamounelsayed Feb 14, 2023
@kaibocai kaibocai linked a pull request Feb 14, 2023 that will close this issue
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants